# Applying Simple Linear Regression Model on Time Series

I have a dataframe for two variables for a period of 22 years. The independent variable refers to the GDP per capita while the independent variable refers to Gross Debt per capita. I'm trying to build a model to analyse the relationship between the two variables using the simple linear model. I was wondering if I should make the variables stationary before fitting the model. And if so, what would be the appropriate function in R that can apply 'lm' on time series object? I got a bit confused as I saw some books and tutorials for regressing economic indicators (with time intervals) where the the independent and dependant variables were not tested against stationarity assumption before building the model. Are there any insights in this regard?

## 1 Answer

Sadly some textbooks leave this topic out. As you can already see it is difficult to use Linear Regression Models for non-stationary time series. Have a look Here

In economic data, what happens at is often related to what happened at t–1. If that is true of the disturbance terms in our regression, then we have serial correlation.Your parameters beta might be consistent BUT your standard errors are not reliable. Because of that you can´t trust any tests including the t-test.

A solution would be to test for stationarity and if it occurs you could differentiate your data. This could solve the problem.

But be aware of the fact that the problem of omitted variables persists. Just when I think about GDP, I think of many other variables that could have an influence, which could distort your estimate again.

• Thank you so much for this insight. But in case I make sure that the time series for the two variables are stationary, how can I apply simple linear regression on them in R given that the object of the variable is ts? The function lm did not work for me! – Rami_Kh Dec 17 '18 at 11:26
• What exactly didnt work? Can you show your code? – Martin Dec 17 '18 at 12:04