Let's say mtcars
contain 3 independent datasets: cyl=4
, cyl=6
and cyl=8
.
I'd like to use two of the groups as my training set, and cyl=4 as the testing set. The aim is to check how well my model performs on the test data:
training <- mtcars[mtcars$cyl!=4,]
testing <- mtcars[mtcars$cyl==4,]
Model:
m <- lm(mpg ~ disp + wt, data=training)
pred.test <- predict(m, testing)
mean.err <- mean((pred.test - testing$mpg)^2)
But what does that tell me about generalizability? How can I determine if mean.err
(or any other value) is a reasonable number? Or is what I'm doing in the example above not the way to test generalizability?
mpg
. It depends on your application -- not on any statistical theory. $\endgroup$