I am building a linear regression model to predict 2015 values. I have data from 2013 and 2014. My question is, how can I use both the data from 2013 and 2014 to train my linear regression model in R? I have:
model1 = lm(x ~ y, data = data2013)
model2 = lm(x ~ y, data = data2014)
predictions1 = predict(model1, testdata)
predictions2 = predict(model2, testdata)
I was wondering if I could build a more accurate model using all the data I have. It would be something like this:
model1&2 = lm(x ~ y, data = data2013 & 2014)
Thank you in advance,
If the columns are exactly the same, you should be able to do something like this:
data_2013_and_2014 <- rbind(data2013, data2014)
new_model <- lm(x ~ y, data = data_2013_and_2014)
Lookup ?rbind
for more details.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.