partial_and_semipartial_correlation
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
partial_and_semipartial_correlation [2019/05/23 10:27] – [regression gpa against sat] hkimscil | partial_and_semipartial_correlation [2019/05/26 23:04] – [Semipartial cor] hkimscil | ||
---|---|---|---|
Line 323: | Line 323: | ||
====== Semipartial cor ====== | ====== Semipartial cor ====== | ||
+ | < | ||
+ | > colnames(tests) <- c(" | ||
+ | > tests <- subset(tests, | ||
+ | > attach(tests) | ||
+ | > cors <- cor(tests) | ||
+ | > round(cors, | ||
+ | | ||
+ | sat 1.000 0.875 0.718 | ||
+ | clep 0.875 1.000 0.876 | ||
+ | gpa 0.718 0.876 1.000 | ||
+ | > lm.sat.clep <- lm(sat ~ clep, data = tests) | ||
+ | > summary(lm.sat.clep) | ||
+ | |||
+ | Call: | ||
+ | lm(formula = sat ~ clep, data = tests) | ||
+ | |||
+ | Residuals: | ||
+ | | ||
+ | -101.860 | ||
+ | |||
+ | Coefficients: | ||
+ | Estimate Std. Error t value Pr(> | ||
+ | (Intercept) | ||
+ | clep 17.665 | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | |||
+ | Residual standard error: 48.2 on 8 degrees of freedom | ||
+ | Multiple R-squared: | ||
+ | F-statistic: | ||
+ | |||
+ | > res.lm.sat.clep <- lm.sat.clep$residuals | ||
+ | > | ||
+ | > install.packages(" | ||
+ | > library(ppcor) | ||
+ | Loading required package: MASS | ||
+ | |||
+ | > # regression test for semipartial correlation (holding clep constant) | ||
+ | > spcor.gpa.sat.clep <- lm(gpa ~ res.lm.sat.clep) | ||
+ | > summary(spcor.gpa.sat.clep) | ||
+ | |||
+ | Call: | ||
+ | lm(formula = gpa ~ res.lm.sat.clep) | ||
+ | |||
+ | Residuals: | ||
+ | Min 1Q Median | ||
+ | -0.3756 -0.2694 -0.0092 | ||
+ | |||
+ | Coefficients: | ||
+ | Estimate Std. Error t value Pr(> | ||
+ | (Intercept) | ||
+ | res.lm.sat.clep -0.0007015 | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | |||
+ | Residual standard error: 0.3382 on 8 degrees of freedom | ||
+ | Multiple R-squared: | ||
+ | F-statistic: | ||
+ | </ | ||
+ | |||
+ | From the above: Multiple R-squared: 0.009898 | ||
+ | From the below: spcor.gpa.sat.clep$estimate^2: | ||
+ | |||
< | < | ||
> spcor.gpa.sat.clep | > spcor.gpa.sat.clep | ||
Line 330: | Line 393: | ||
[1] 0.009897835 | [1] 0.009897835 | ||
> </ | > </ | ||
+ | |||
+ | |||
====== e.g., ====== | ====== e.g., ====== |
partial_and_semipartial_correlation.txt · Last modified: 2023/05/31 08:56 by hkimscil