Dimitri Liakhovitski
2013-Mar-20 22:14 UTC
[R] Dealing with missing values in princomp (package "psych")
Hello! I am running principle components analysis using princomp function in pacakge psych. mypc <- princomp(mydataforpc, cor=TRUE) Question: I'd like to use pairwise deletion of missing cases when correlations are calculated. I.e., I'd like to have a correlation between any 2 variables to be based on all cases that have valid values on both variables. What should my na.action be in this case? Thank you very much! -- Dimitri Liakhovitski [[alternative HTML version deleted]]
Dimitri Liakhovitski
2013-Mar-20 22:59 UTC
[R] Dealing with missing values in princomp (package "psych")
Just a small correction. I am running it like this: mypc <- princomp(~.,data=q7a.forfa, cor=TRUE, na.action=na.omit) With na.omit it works. But I have way too many unsystematically missing values on different variables. I tried na.action = na.pass, but it's not working: Error in cov.wt(z) : 'x' must contain finite values only Can it be that princomp does not allow pairwise deletion of misisng values? Thank you! Dimitri On Wed, Mar 20, 2013 at 6:14 PM, Dimitri Liakhovitski < dimitri.liakhovitski@gmail.com> wrote:> Hello! > I am running principle components analysis using princomp function in > pacakge psych. > > mypc <- princomp(mydataforpc, cor=TRUE) > > Question: I'd like to use pairwise deletion of missing cases when > correlations are calculated. I.e., I'd like to have a correlation between > any 2 variables to be based on all cases that have valid values on both > variables. > > What should my na.action be in this case? > > Thank you very much! > -- > Dimitri Liakhovitski >-- Dimitri Liakhovitski [[alternative HTML version deleted]]
Bert Gunter
2013-Mar-20 23:04 UTC
[R] Dealing with missing values in princomp (package "psych")
Well, you can do this, but there's no guarantee that the resulting correlation matrix will be positive definite. And what would principle components based on this mean even if it is positive definite? -- Bert On Wed, Mar 20, 2013 at 3:14 PM, Dimitri Liakhovitski < dimitri.liakhovitski@gmail.com> wrote:> Hello! > I am running principle components analysis using princomp function in > pacakge psych. > > mypc <- princomp(mydataforpc, cor=TRUE) > > Question: I'd like to use pairwise deletion of missing cases when > correlations are calculated. I.e., I'd like to have a correlation between > any 2 variables to be based on all cases that have valid values on both > variables. > > What should my na.action be in this case? > > Thank you very much! > -- > Dimitri Liakhovitski > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[alternative HTML version deleted]]