This is so simple, I'm embarrassed. Nevertheless...
I used a data frame with 841 rows (called rdrdata.train) to generate an
lm object. I then tried ti use predict.lm on another data frame
containing new data with which I wanted to test the performance of my lm
object. My new data has 361 rows (same predictors).
I get an error message that says
Problem in model.matrix.default(delete.response(Terms), ..: Length of
rdrdata.train[, 2] (variable 1) is 841 != length of others (361)
Use traceback() to see the call stack
I didn't think that newdata had to have the same number of rows as the
data set used to build the lm. What am I missing?
Kim Elmore
|