A. Pearson correlation
Data
A1. Scatterplot
A2. Pearson correlation coefficient (along with significance).
B. Partial correlation coefficient
Data
B1. Scatterplot and correlation coefficient
B2. Partial correlation coefficient
The above example is contained in the paragraph 4.1 of the book "Στατιστική ανάλυση με τη γλώσσα R" (in Greek, ISBN: 978-960-93-9445-1) published in Thessaloniki, 2017.
Data
advert = c(4.69, 6.41, 5.47, 3.43, 4.39, 2.15, 1.54, 2.67, 1.24, 1.77, 4.46, 1.83, 5.15, 5.25, 1.72, 3.04, 4.92, 4.85, 3.13, 2.29, 4.9, 5.75, 3.61, 4.62)
sales = c(12.23, 11.84, 12.25, 11.1, 10.97, 8.75, 7.75, 10.5, 6.71, 7.6, 12.46, 8.47, 12.27, 12.57, 8.87, 11.15, 11.86, 11.07, 10.38, 8.71, 12.07, 12.74, 9.82, 11.51)
A1. Scatterplot
plot(advert, sales, xlab = "Advertisement", ylab = "Sales")
A2. Pearson correlation coefficient (along with significance).
cor.test(sales, advert)
B. Partial correlation coefficient
Data
funding = c(155.33, 177.34, 165.09, 154.28, 185.56, 186.96, 198.63, 172.14, 198.25, 193.9, 157.03, 158.07, 182.09, 173.2, 151.84, 182.9, 197.09, 163.86, 192.3, 172.03, 166.97, 187.86, 184.23, 166.86, 174.64, 159.5, 153.18, 169.46, 169.9, 161.57, 183.99, 187.98, 195.88, 154.76, 177.6, 163.02, 190.34, 179.27, 192.2, 181.23, 159.41, 167.47, 151.38, 195.56, 162.69, 173.17, 176.52, 200.73, 190.53, 180.12)
disease = c(158.34, 157.23, 162.92, 130.59, 202.81, 221.43, 189.22, 166.42, 203.07, 198.57, 161.79, 168.82, 180.41, 178.52, 157.77, 212.44, 198.9, 174.25, 212.07, 149.45, 190.35, 198.38, 172.99, 186.81, 179.42, 148.46, 133.64, 152.11, 183.13, 163.32, 176.52, 178.6, 207.62, 143.88, 159.74, 172.06, 188.55, 202.31, 190.16, 201.54, 153.99, 153.99, 122.39, 184.35, 154.44, 179.7, 167.49, 164.54, 184.12, 178.94)
visits = c(152.13, 167.84, 162.21, 146.69, 186.93, 188.16, 195.39, 175.5, 197.04, 190.16, 156.47, 159.21, 185.65, 176.5, 156.97, 181.62, 205.51, 167.09, 192.71, 165.02, 162.07, 186.16, 189, 166.93, 171.45, 157.3, 150.41, 171.18, 168.88, 151.86, 185.03, 184.52, 197.07, 153.74, 184.18, 155.93, 197.91, 187.9, 194.07, 186.68, 150.64, 164.11, 148.32, 193.66, 162.36, 172.7, 172.51, 196.14, 191.1, 174.83)
B1. Scatterplot and correlation coefficient
cor.test(funding, disease)
plot(funding, disease, xlab = "Funding", ylab = "Reported diseases", cex = 1.5, cex.lab = 1.5, cex.axis = 1.5)
B2. Partial correlation coefficient
library(ppcor)
pcor.test(funding, disease, visits)
The above example is contained in the paragraph 4.1 of the book "Στατιστική ανάλυση με τη γλώσσα R" (in Greek, ISBN: 978-960-93-9445-1) published in Thessaloniki, 2017.
Comments
Post a Comment