[R] problem with predict()
Liaw, Andy
andy_liaw at merck.com
Fri Jun 21 21:35:09 CEST 2002
> From: Czerminski, Ryszard [mailto:ryszard at arqule.com]
>
> --- first problem
>
> If I store 'simulated' data in data frames:
> # train.data <- data.frame(matrix(rnorm(164*119), nrow = 164))
> # test.data <- data.frame(matrix(rnorm(35*119), nrow = 35))
> it still works the same way i.e. the code below works fine
> for simulated data and fails for 'real' data the only
> difference being in actual numeric values stored in data
> structures of the same shape and type.
>
> Any suggestions why this happens ?
As Prof. Ripley hinted, check the names of the data frames. For your "real"
data, do
names(train)
names(test)
to see how they are different.
> --- second problem
>
> > As Andy Liaw pointed out, xr is a matrix. Take a look at
> the names of
> > train. Hint: they do not contain `x'.
>
> Following your hint I am guessing that the fact that names do
> not contain
> 'x'
> explains why lm(y~., train) form works and lm(y~x, train) fails
> and "lm(y~., train)" means roughly: correlate column "y" to
> all other colums
>
> Where I can find more detail specification of this syntax ?
> In help(lm) I find this paragraph:
>
> Models for `lm' are specified symbolically. A typical model has
> the form `response ~ terms' where `response' is the (numeric)...
>
> which does not quite cover this case.
Reading the `An Introduction to R' manual, especially parts of Chapter 5.
(The `.' shorthand is explained in section 11.5.)
Andy
------------------------------------------------------------------------------
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