# Can I include time as an independent variable in a panel data model?

I have panel data (different countries across different years) and I am trying to do both a trend analysis and a panel regression.

The trend analysis part: I want to see if there is a trend in high body mass index measured in DALYS (dependent variable) over time (independent variable) from 2000-2019, by assessing the relationship between DALYs and time.

The panel regression part: I also want to see if there is a relationship between DALYs (dependent) and sociodemographic index and unemployment level (independent variables).

Can I do all the work (trend analysis and panel regression) by including the time period as an independent variable with the other independent ones in one model? And try different models and compare them? And for instance after obtaining a regression coefficient for time, I can assess if DALYs is decreasing, increasing, or is stable across time.

I am using R software.

• You certainly can, but here's an intentionally (and hopefully fertile) provocative thought: unless you are modeling something like the radioactive decay of atoms, "time" as an explanatory variable probably means something like "I haven't theorized my data generating process very deeply, and am just lumping a bunch stuff together into a 'time' variable." Contrast with dynamic models (time-varying explanatory variables, including previous DALY values, etc.) such as the time series analysis that @TannerPhillips suggests. Oct 14, 2021 at 15:10
• Hello, thank you for your advice. I wanted to regress DALYs on time after reading many papers that used time as the independent variable, and here I quote my reason from one of the papers: " Our goal is to determine whether apparent trends over time are statistically significant. To make this determination, we must characterize the association between a single predictor variable (time) and a and a single outcome variable (rates of a disease or condition)." Source: An Introduction to Time-Trend Analysis John W. Ely, MD, MSPH; Jeffrey D. Dawson, ScD; Jon H. Lemke, PhD; Jon Rosenberg, MD Oct 14, 2021 at 18:05
• My question (and my answer) here should give pause to those wanting to ignore autoregressive relationships: DALYs$_t$ must be a function of DALYs$_{t-1}$. Oct 14, 2021 at 18:45

Short answer: Sure, give it a shot. However, you are assuming that the time variable is linear. So either increasing or decreasing over time. This most likely isn't going to hold. This is fundamentally the reason time series analysis exists; time trends tend not to be linear, they are noisy. You can add higher-order variables with the lm() function so it allows the relationship to be parabolic or even more "wavy" with cubed terms or higher. But at some point this leads to meaningless overfit that isn't useful.

• Hello sir Tanner Philips, please excuse my lack of knowledge, thank you for answering my question. As I am new to this issue, can you suggest me specific terms to search about in order to solve my problem using the parabolic trend suggestion, and narrow down my search? For instance after searching a lot I began to understand that it's a type of polynomial regression and there are types like 2nd 3rd order and so on. Oct 14, 2021 at 17:56
• Sure. You can use the standard r lm() function. So you might have a model like: lm(DALYS~Demographic+Unemployment+poly(time,degree=2)). The degree is just the number of time you allow the variable to "curve". degree of two means parabolic, i.e. one curve, quadratic means 2 curves etc. Anything above quadratic is generally viewed skeptically. Oct 14, 2021 at 18:09
• Thank you very much! Oct 14, 2021 at 18:12