Partial and semi-partial correlation

> 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"))
> tests

   sat clep gpa
1  500   30 2.8
2  550   32 3.0
3  450   28 2.9
4  400   25 2.8
5  600   32 3.3
6  650   38 3.3
7  700   39 3.5
8  550   38 3.7
9  650   35 3.4
10 550   31 2.9
> attach(tests)
> pairs(cbind(sat, clep, gpa), lower.panel = panel.cor, pch = 18)

> options(digits=4)
> cor(tests)
        sat   clep    gpa
sat  1.0000 0.8745 0.7180
clep 0.8745 1.0000 0.8763
gpa  0.7180 0.8763 1.0000
> 

> cor(tests)^2
        sat   clep    gpa
sat  1.0000 0.7648 0.5156
clep 0.7648 1.0000 0.7679
gpa  0.5156 0.7679 1.0000
> 

Regression GPA against SAT

tests.lm.gpa.sat <- lm(gpa ~ sat, data = tests)
summary(tests.lm.gpa.sat)

Call:
lm(formula = gpa ~ sat, data = tests)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.23544 -0.12184  0.00316  0.02943  0.56456 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)   
(Intercept) 1.7848101  0.4771715   3.740   0.0057 **
sat         0.0024557  0.0008416   2.918   0.0193 * 
---
Signif. codes:  
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.2365 on 8 degrees of freedom
Multiple R-squared:  0.5156,	Adjusted R-squared:  0.455 
F-statistic: 8.515 on 1 and 8 DF,  p-value: 0.01935

Also, correlation between SAT, GPA = 0.7180 (see the above cor output)

tmp1 <- data.frame(cbind(tests.lm.gpa.sat$fitted.values, tests.lm.gpa.sat$residuals))
tmp.gpa.sat <- as.data.frame(cbind(sat, gpa, tmp1$X1, tmp1$X2))
colnames(tmp.gpa.sat) <- c("sat", "gpa", "pred", "resid")
tmp.gpa.sat
   sat gpa     pred        resid
1  500 2.8 3.012658 -0.212658228
2  550 3.0 3.135443 -0.135443038
3  450 2.9 2.889873  0.010126582
4  400 2.8 2.767089  0.032911392
5  600 3.3 3.258228  0.041772152
6  650 3.3 3.381013 -0.081012658
7  700 3.5 3.503797 -0.003797468
8  550 3.7 3.135443  0.564556962
9  650 3.4 3.381013  0.018987342
10 550 2.9 3.135443 -0.235443038

Note that correlation between sat and gpa = 0.718,
correlation between gpa and pred = the same as the above,
correlation between pred and resid = 0

round(cor(tmp.gpa.sat), digits = 3)
        sat   gpa  pred resid
sat   1.000 0.718 1.000 0.000
gpa   0.718 1.000 0.718 0.696
pred  1.000 0.718 1.000 0.000
resid 0.000 0.696 0.000 1.000