# load example data
data(selection.example.data)
# give me only those rows that have full information
new.dat = selection.example.data[!is.na(selection.example.data$Performance),]
cor.mat = cor(new.dat[,c("R", "Biodata", "Performance")])
# correct assuming direct selection on R, indirect on biodata, and a dv of performance
corrected = caseIII(rxy=cor.mat[1,3], rzy=cor.mat[2,3],
rxz=cor.mat[1,2], uz = sd(new.dat$R)/sd(selection.example.data$R))
corrected
## do a simulation to show it works
cor.mat = matrix(c(1, .3, .4,
.3, 1, .5,
.4, .5, 1), nrow=3)
data = mvrnorm(100000, mu=c(0,0,0), Sigma = cor.mat)
### restrict the data
data[data[,1]<.5, 2:3] = NA
caseIII(data=data, x=2, y=3, z=1)
Run the code above in your browser using DataLab