[R] problem with predict()
Liaw, Andy
andy_liaw at merck.com
Fri Jun 21 19:06:24 CEST 2002
The problem is that xr and xs are both matrices in his example, not vectors.
Andy
> -----Original Message-----
> From: Peter Dalgaard BSA [mailto:p.dalgaard at biostat.ku.dk]
> Sent: Friday, June 21, 2002 1:03 PM
> To: Liaw, Andy
> Cc: 'Czerminski, Ryszard'; r-help at stat.math.ethz.ch
> Subject: Re: [R] problem with predict()
>
>
> "Liaw, Andy" <andy_liaw at merck.com> writes:
>
> > You still don't get the point. Please read Peter
> Dalgaard's reply and the
> > help page for predict.lm carefully, and try to understand
> the `Detail'
> > section. See the example below:
> [snip]
>
> > > This looks promissing; however I get an error:
> > >
> > > > train <- data.frame(y=yr, x=xr)
> > > > test <- data.frame(y=ys, x=xs)
> > > > myfit <- lm(y ~ x, train)
> > > Error in eval(expr, envir, enclos) : Object "x" not found
>
> But there's nothing wrong with that code as far as I can see?? I don't
> get an error from it:
>
> > xr <- rnorm(10)
> > yr <- rnorm(10)
> > ys <- rnorm(5)
> > xs <- rnorm(5)
> > train <- data.frame(y=yr, x=xr)
> > test <- data.frame(y=ys, x=xs)
> > myfit <- lm(y ~ x, train)
> > predict(myfit,test)
> 1 2 3 4 5
> -0.03809295 0.11422384 0.35570765 0.55436954 0.22979523
>
>
> Something must have gone wrong with the creation of "train".
>
> --
> 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
>
------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please immediately return this by e-mail and then delete it.
==============================================================================
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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