Let's say I have the following lagged data frame and am trying to predict income for 9/10 using data from 9/09.

dat = data.frame(main_date=c("09/01/2013","09/02/2013","09/03/2013","09/04/2013","09/05/2013","09/06/2013",
                 income=c(rnorm(10)), status=c(rnorm(10)), avg_temp=c(rnorm(10)))

mod = lm(income ~ status + avg_temp, data=dat)

(-0.00848) + (0.4272*(0.641)) + (-0.651*(-1.274))

I have my data frame and run a linear model. Then I grab estimates and july data points for my two predictors and calculate for Y manually. However, I was wonder if R had a built in process for generating predictions of this nature or could provide insights into finding an "automated" process for performing this task in R.


If I understand your question, what you're looking for is ?predict, or fitted(mod), depending on whether you have july datapoints or not.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.