[R] problem with predict()

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Fri Jun 21 14:32:53 CEST 2002


"Czerminski, Ryszard" <ryszard at arqule.com> writes:

> > Does xs contain a variable called xr?
> 
> No - it does not.
> 
> I was expecting that if I use model built using
> (yr,xr) data with 164 cases and 118 variables
> to predict on a test data (xs) with 35 cases
> > # dim(xr) = 164 118 ; dim(xs) = 35 118
> I should get vector of 35 responses from predict(),
> but I am getting instead 164 responses.
> > # length(ys) = 35 ; length(ps) = 164
> 
> If I go through example provided with help(predict.lm)
> I get expected number of responses (13).
> This is however only 1D example.
> 
> I am sure I am missing something and probably not using
> predict() correctly, but I am at loss what it is...

Your model formula was yr ~ xr, if there's no "xr" in the newdata
argument, I rather strongly suspect that the xr in the global
workspace is getting used for predictions, and that one is 164
elements long.... 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list