# Example showing similar behavior of linear and non-linear
# semi-partial associations when the data is truly linear
# Y is the response variable, X is the explanatory variable, and C is the control
# k is a factor that controls how much of Y is taken from X and how much from C
k <- 0.5
C = rnorm(1000)
X = rnorm(1000)
Y = C*(1-k) + X*k + rnorm(1000)*0.1
# if you have rgl you can plot the data
# plot3d(X,C,Y)
# compute the semi-partial association
spa(Y,X,C)
# if you have ppcor then you can compute the linear semi-partial correlation as well
# spcor.test(Y,X,C)$estimate^2Run the code above in your browser using DataLab