Matrix of generalized partial correlation coefficients, always leaving out control variables, if any.
Matrix of generalized partial correlation coefficients, always leaving out control variables, if any.
This function calls parcor_ijk function which uses original data to compute generalized partial correlations between Xi and Xj
where j can be any one of the remaining variables in the input matrix mtx. Partial correlations remove the effect of variables xk other than Xi and Xj. Calculation further allows for the presence of control variable(s) (if any) to remain always outside the input matrix and whose effect is also removed in computing partial correlations.
parcorMtx(mtx, ctrl =0, dig =4, verbo =FALSE)
Arguments
mtx: Input data matrix with p columns. p is at least 3 columns.
ctrl: Input vector or matrix of data for control variable(s), default is ctrl=0 when control variables are absent
dig: The number of digits for reporting (=4, default)
verbo: Make this TRUE for detailed printing of computational steps
Returns
A p by p `out' matrix containing partials r*(i,j | k). and r*(j,i | k).
Note
We want to get all partial correlation coefficient pairs removing other column effects. Vinod (2018) shows why one needs more than one criterion to decide the causal paths or exogeneity.
Examples
set.seed(234)z=runif(10,2,11)# z is independently createdx=sample(1:10)+z/10#x is partly indep and partly affected by zy=1+2*x+3*z+rnorm(10)# y depends on x and z not vice versamtx=cbind(x,y,z)parcorMtx(mtx)## Not run:set.seed(34);x=matrix(sample(1:600)[1:99],ncol=3)colnames(x)=c('V1','v2','V3')parcorMtx(x)## End(Not run)
Vinod, H. D. 'Matrix Algebra Topics in Statistics and Economics Using R', Chapter 4 in Handbook of Statistics: Computational Statistics with R, Vol.32, co-editors: M. B. Rao and C.R. Rao. New York: North Holland, Elsevier Science Publishers, 2014, pp. 143-176.