Description Usage Arguments Value Note Author(s) Examples
View source: R/standardized-class.R
To put new data into the same standardized space as the data in the
standardized
object,
predict
can be used with the standardized
object as the first
argument. The predict
method also allows logicals response
,
fixed
, and random
to be used to specify which elements of the
original data frame are present in newdata
. A regression model
fit with the formula
and data
elements of a
standardized
object cannot be used to
directly predict the response variable for new data. The new data must
first be placed into the standardized space. If offsets were included
in the formula
argument used to create the standardized
object,
then when fixed = TRUE
the offset variables must be in newdata
.
If an offset was passed to the offset
argument in the call to
standardize
, then the offset cannot be passed to predict
.
1 2 3 4 5 6 7 8 9 |
object |
An object of class |
newdata |
Data to be placed into the same standardized space as the
data in the call to |
response |
A logical (default |
fixed |
A logical (default |
random |
A logical (default |
... |
Ignored with a warning. |
A data.frame with the newdata
standardized using the
pred
element of the standardized
object.
You may see a warning "contrasts dropped from factor <x>" for each factor when predicting new data with a fitted model object, but this warning can be ignored (the actual predictions will still be correct).
Christopher D. Eager <eager.stats@gmail.com>
1 2 3 4 5 6 7 8 9 10 | ## Not run:
train <- subset(mydata, train)
test <- subset(mydata, !train)
train.s <- standardize(y ~ x1 + f1 + (1 | g1), train)
mod <- lmer(train.s$formula, train.s$data)
test.s <- predict(train.s, test, response = TRUE)
preds <- predict(mod, newdata = test.s) # can ignore warning about dropped contrasts
res <- test.s$y - preds
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.