# http://cran.r-project.org/ AND DOWNLOAD THE R LATEST RELEASE: R-2.x.y.
# http://www.staff.ul.ie/mackenzieg/Assess/R_Integration_Tools/r_integration_tools.html 'Crash Course' in R

library(foreign)
library(car)
library(lattice)
library(stats)
x <- read.spss("promises.sav")
x1 <- data.frame(x)
x4 <- na.omit(x1)
plot(c(1,10),c(21,65), axes=F, type="n",
main="Promises made and kept", xlab="Number Kept", ylab="Number Made")
axis(1, at=c(0,1,2,3,4,5,6,7,8,9,10))
axis(2, at=c(0,10,15,20,25,30,35,40,45,50,55,60,65))
points(x1$kept,x1$made,pch=0)
z <- lm(x1$made ~ x1$kept)
abline(z,lty=3)

# comparing semi-partial correlations using raw regression coefficients in the same sample
* Cohen (1983): semi-partial correlation difference can be made using difference in raw regression coefficients

x <- read.spss("crime data in usa.sav")
x1 <- data.frame(x)
x4 <- na.omit(x1)
fit1 <- lm(x1$crime~x1$age + x1$educatio)
s1 <- summary(fit1)$coefficients
db <- (s1[3,1]-s1[2,1])
s2 <- vcov(fit1)
sd <- sqrt(s2[2,2]+s2[3,3]-2*s2[2,3])
df <- (fit1$df.residual)
td <- db/sd
2*pt(-abs(td), df)



