Reputation: 6035
I have two non-empty dataframes: training
and testing
. Each of these dataframes has two columns: Y
and X
, in this order. I have applied linear regression analysis to training
as follows:
m <- lm(Y ~ X, data = training)
I would like to apply the coefficients resulting from this fitting to the data in testing
to obtain the same types of information available in the object m
for purposes of further analysis and data visualization. How can I do this?
Upvotes: 2
Views: 3867
Reputation: 4926
See the predict.lm
function:
Y_pred = predict(m, newdata = testing)
Upvotes: 2