User Tools

Site Tools


partial_and_semipartial_correlation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
partial_and_semipartial_correlation [2019/05/23 10:27] – [regression gpa against sat] hkimscilpartial_and_semipartial_correlation [2019/05/26 23:04] – [Semipartial cor] hkimscil
Line 323: Line 323:
  
 ====== Semipartial cor ====== ====== Semipartial cor ======
 +<code>> tests <- read.csv("http://commres.net/wiki/_media/r/tests_cor.csv")
 +> colnames(tests) <- c("ser", "sat", "clep", "gpa")
 +> tests <- subset(tests, select=c("sat", "clep", "gpa"))
 +> attach(tests)
 +> cors <- cor(tests)
 +> round(cors,3)
 +       sat  clep   gpa
 +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:
 +     Min       1Q   Median       3Q      Max 
 +-101.860  -19.292    1.136   28.306   54.132 
 +
 +Coefficients:
 +            Estimate Std. Error t value Pr(>|t|)    
 +(Intercept)  -19.421    114.638  -0.169  0.86967    
 +clep          17.665      3.464   5.100  0.00093 ***
 +---
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +Residual standard error: 48.2 on 8 degrees of freedom
 +Multiple R-squared:  0.7648, Adjusted R-squared:  0.7353 
 +F-statistic: 26.01 on 1 and 8 DF,  p-value: 0.0009303
 +
 +> res.lm.sat.clep <- lm.sat.clep$residuals
 +
 +> install.packages("ppcor")
 +> 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      3Q     Max 
 +-0.3756 -0.2694 -0.0092  0.2514  0.4686 
 +
 +Coefficients:
 +                  Estimate Std. Error t value Pr(>|t|)    
 +(Intercept)      3.1600000  0.1069377  29.550 1.86e-09 ***
 +res.lm.sat.clep -0.0007015  0.0024806  -0.283    0.785    
 +---
 +Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
 +
 +Residual standard error: 0.3382 on 8 degrees of freedom
 +Multiple R-squared:  0.009898, Adjusted R-squared:  -0.1139 
 +F-statistic: 0.07997 on 1 and 8 DF,  p-value: 0.7845
 +</code>
 +
 +From the above: Multiple R-squared: 0.009898
 +From the below: spcor.gpa.sat.clep$estimate^2: 0.009897835
 +
 <code>> spcor.gpa.sat.clep <- spcor.test(gpa,sat,clep) <code>> spcor.gpa.sat.clep <- spcor.test(gpa,sat,clep)
 > spcor.gpa.sat.clep > spcor.gpa.sat.clep
Line 330: Line 393:
 [1] 0.009897835 [1] 0.009897835
 > </code> > </code>
 +
 +
  
 ====== e.g., ====== ====== e.g., ======
partial_and_semipartial_correlation.txt · Last modified: 2023/05/31 08:56 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki