[R] lm-step: use train-data model to validate test-data
Amoy Yang
amoy_y at yahoo.com
Mon Feb 22 21:38:25 CET 2016
I have model-data named as: model that is split as model.T(train) and model.V(test or validation). The least square model (from lm to step) is built withmodel.T and I like to see how model.T is robust by comparing predicted model.V toactual model.V. How do I get score for model.V based on model built on model.T? The code highlighted below does not get what I expected.Please advise! Thanks!
# score the model
score.T <- data.frame(predict(step, model.T)) # get predicted score for train data
score.V <- data.frame(predict(step, model.V)) # for test data but seems incorrect
# get the actual values
actual.T <- data.frame(model.T$sales)
actual.V <- data.frame(model.V$sales) # comparison for model.T
comp.T=cbind(actual.T,round(score.T,digit=2))
plot(comp.T) # comparison for model.V (use Model.T to predict Model.V for true validation
comp.V=cbind(actual.V,round(score.V,digit=2))
plot(comp.V)
[[alternative HTML version deleted]]
More information about the R-help
mailing list