From p.dalgaard at biostat.ku.dk  Tue Jul 15 08:21:16 2003
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard BSA)
Date: Tue Jul 15 09:21:19 2003
Subject: [Rd] "na.action" parameter in princomp() (PR#3481)
In-Reply-To: <200307150622.h6F6MeJH024405@pubhealth.ku.dk>
References: <200307150622.h6F6MeJH024405@pubhealth.ku.dk>
Message-ID: <x2u19o8d77.fsf@biostat.ku.dk>

jerome@hivnet.ubc.ca writes:

> Setting the parameter na.action=na.omit should remove
> incomplete records in princomp. However this does not
> seem to work as expected. See example below.
> 
> Sincerely,
> Jerome Asselin
> 
> 
> data(USArrests)
> princomp(USArrests, cor = TRUE) #THIS WORKS
> 
> USArrests[1,3] <- NA
> princomp(USArrests, cor = TRUE, na.action=na.omit) #THIS FAILS!
> #Error in cov.wt(z) : x must contain finite values only

You're not reading the help page properly. na.action is for formula
specification only:

Usage:

     princomp(formula, data = NULL, subset, na.action, ...)
     princomp(x, cor = FALSE, scores = TRUE, covmat = NULL,
              subset = rep(TRUE, nrow(as.matrix(x))), ...)

This works:

princomp(~.,data=USArrests, cor = TRUE, na.action=na.omit) 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907


[Rd] "na.action" parameter in princomp() (PR#3481)
Peter Dalgaard BSA