Search code examples
rrstudioeconomics

How do I plot the second coefficient (not including the intercept into a plot) can I choose which coefficient to draw with abline?


I am running a time series regression by doing:

ts(Regression.data, frequency = 12, start=c(2012,10))

and then running:

attach(Regression.data)
model <- lm(logsalesUK ~ time(Date) + Exchangerate)
plot(Exchangerate, logsalesUK)

I would like to return the regression line using:

abline(model)

However this returns the date regression line. Can someone explain to me how to choose the exchange rate regression line to the plot?

---bonus question---

Is this time series regression taking into account the seasonality specified in the ts function? (see above)


Solution

  • You can extract the coefficients you need from model and feed them into abline explicitly:

    abline(model$coefficients[["(Intercept)"]], model$coefficients[["Exchangerate"]])