Unformatted text preview:

CovariancePearson rSpearman'sCovariance Pearson r Spearman’s ρCovariance and Pearson rDr. J. Kyle RobertsSouthern Methodist UniversitySimmons School of Education and Human DevelopmentDepartment of Teaching and LearningCovariance Pearson r Spearman’s ρBivariate Data•Up until now, we have only been looking at univariatemeasures. Now we will begin looking at bivariate measures ofrelationship.•Typically, we have two measures (although there are more)that we frequently consult.•Covariance•Pearson r•IMPORTANT: Correlation does not imply causation!Covariance Pearson r Spearman’s ρFormula for the Covariance•Covariance is sometimes referred to as the sum of thecross-products.•The covariance tells us if there is any relationship between thetwo variables.•A positive value means that as one variable goes “up” theother variable tends to also go “up.”COVxy=P(xi− x)(yi− y)n − 1Covariance Pearson r Spearman’s ρComputing COVxyfor a Given Variable SetX Y x y xy1 1 -1.5 -2 32 2 -0.5 -1 0.53 3 0.5 0 04 6 1.5 3 4.5Sum 8COVxy=Pxyn − 1=84 − 1= 2.667> cov(1:4, c(1, 2, 3, 6))[1] 2.666667Covariance Pearson r Spearman’s ρCorrelation•A correlation is a symmetric, scale-invariant measure of the(linear) association between two random variables.•The correlation is completely symmetric between the twovariables. We do not assume that one is the predictor and theother is the response. In most cases we assume that bothvariables are being driven by an unobserved, “hidden” or“lurking” variable.•In other words correlation between variables is an observed orempirical trait. It does not imply causation.Covariance Pearson r Spearman’s ρPearson correlation•The Pearson correlationr =P(xi− ¯x)(yi− ¯y)pP(xi− ¯x)2P(yi− ¯y)2=COVxySDxSDyis the most common measure of correlation.•Both r and ρ are dimensionless and restricted to [−1, 1].•A correlation (theoretical or empirical) of 0 implies no lineardependence of the variables. If you assume a bivariate normaldistribution it also implies independence of X and Y .•A correlation of ±1 implies a perfect linear dependencebetween the variables.Covariance Pearson r Spearman’s ρHeuristic Data Generation> set.seed(12346)> cov.mat <- matrix(c(225, 200, 30, 200, 225, 15,+ 30, 15, 225), 3, 3, dimnames = list(c("reading",+ "spelling", "math"), c("reading", "spelling",+ "math")))> studknow <- data.frame(mvrnorm(40, c(80, 78, 64),+ cov.mat))> head(studknow)reading spelling math1 103.46649 100.33448 43.757032 75.77614 75.87772 62.430453 94.60047 95.59099 38.274534 56.87628 49.39053 48.184285 62.71829 60.47098 76.074166 115.98872 107.98283 57.91762Covariance Pearson r Spearman’s ρScatterplot matrix of heuristic measures> print(splom(~studknow, aspect = 1, type = c("g",+ "p")))Scatter Plot Matrixreading9010011012090 100 110 1206070809060 70 80 90●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●spelling100120100 120608060 80●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●math608060 80204020 40Covariance Pearson r Spearman’s ρA parallel coordinate plotAn alternative graphical presentation of these three variables iscalled a parallel coordinate plot, because the axes for the variablesare parallel, not perpendicular. The corresponding positions onconsecutive pairs of axes are joined. Parallel lines indicateagreement of the scales; crossing lines indicate disagreement.> print(parallel(~studknow))readingspellingmathMin MaxCovariance Pearson r Spearman’s ρComputing Pearson r•We can now compute the statistic for Pearson r across all ofour measures with:> cor(studknow)reading spelling mathreading 1.0000000 0.9288218 -0.1995084spelling 0.9288218 1.0000000 -0.1789046math -0.1995084 -0.1789046 1.0000000•The Pearson r also answers the question for us of “How welldoes a single line represent the bivariate relationship betweenthese two vectors of data?”•By plotting this, we can see how this is true.Covariance Pearson r Spearman’s ρPlotting of bivariate relationships●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●60 80 100 12060 70 80 90 100 110r = 0.929studknow$spellingstudknow$reading●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●20 30 40 50 60 70 80 9060 80 100 120r = −0.179studknow$mathstudknow$spelling●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●60 70 80 90 100 11020 30 40 50 60 70 80 90r = −0.200studknow$readingstudknow$mathCovariance Pearson r Spearman’s ρA Single Line Representing Relationships> ex1 <- c(1, 2, 3, 4)> ex2 <- c(1, 2, 3, 5)> ex3 <- c(1, 4, 5, 2)●●●●1.0 1.5 2.0 2.5 3.0 3.5 4.01 2 3 4 5r = 0.983ex1ex2●●●●1.0 1.5 2.0 2.5 3.0 3.5 4.01 2 3 4 5r = 0.283ex1ex3●●●●1 2 3 4 51 2 3 4 5r = 0.107ex2ex3Covariance Pearson r Spearman’s ρSquare Before You Compare!•The Pearson r is on a ordinal scale.•This means that an r of 0.6 is greater than an r of 0.5, butwe do not know how much greater.•In order to convert this to an interval scale, we must squarethe r.•Therefore, two variables that have a 0.6 r have a 11%stronger relationship than two variables with a 0.5 r.0.62− 0.52= 0.36 − 0.25 = 0.11Covariance Pearson r Spearman’s ρAlternative measures of correlation (Spearman)•The Pearson correlation assumes that the marginaldistributions of the variables are more-or-less normal.•Spearman’s ρ uses only the ranks of the observations for eachvariable. As such, results are often similar to r, but slightlydifferent since r also takes into account relative distance.ρ = 1 −6Pd2n(n2− 1)•where n is the number of paired ranks and d is the differencebetween the paired ranks.> cor(studknow, method = "spearman")reading


View Full Document

SMU PHYS 7311 - Covariance and Pearson R

Download Covariance and Pearson R
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Covariance and Pearson R and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Covariance and Pearson R 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?