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?
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.