dat = read.table('fat.txt') X1 = dat[,1] X2 = dat[,2] X3 = dat[,3] Y = dat[,4] fit1 = lm(Y~X1) fit2 = lm(Y~X2) fit12 = lm(Y~X1+X2) fit21 = lm(Y~X2+X1) fit = lm(Y~X1+X2+X3) SSE1 = deviance(fit1) SSE2 = deviance(fit2) SSE12 = deviance(fit12) SSE123 = deviance(fit) ####Coefficient of partial determination SSR1.2 = deviance(fit2)-deviance(fit12) SSE2 = deviance(fit2) RY1.2 = SSR1.2/SSE2 ###another way of calculating e1 = residuals(lm(Y~X2)) e2 = residuals(lm(X1~X2)) cor(e1,e2)^2