Advanced Statistics - Biology 6030
Bowling Green State University, Fall 2017
If two independent samples are obtained, then we can ask whether
they correlate to some extent. Correlation coefficients measure the
strength of the linear relationship between these two variables
and read the content from file "Golf.txt" which lists divorce rates and
number of golf courses for 20 US cities. The obtain Pearson's Product
Moment Correaltion Coefficient ...
> Golf <- read.table("http://caspar.bgsu.edu/~courses/stats/Labs/Datasets/Golf.txt", header=TRUE)
or simply obtain the correlation matrix for all variables contained in the dataframe, in this case using the method for rank correlations
> cor(Golf, method = "spearman")
For a more comprehensive view of the associations between variables create a correlation matrix with library Deducer, then print the results ...
> Golf.corrMat<-cor.matrix(variables=d(Golf$GolfCourses,Golf$DivorceRate), test=cor.test, method='pearson', alternative="two.sided")
Create scatterplot of the correaltion matrix with added linear model for fit ...
> qscatter_array(d(GolfCourses,DivorceRate),d(GolfCourses,DivorceRate),data=Golf) + geom_smooth(method="lm")
or a sweet one with ggpairs from library GGally ...