# How to create a time series variable

Here's an example of my data set. I have not included the actual responses.

The "ID"-tag identifies a particular subject. The "year"-tag identifies what year the subject entered the experiment. The "longevity" tag identifies the duration that the subject was part of the experiment. "Locality" and "Sex/Size" are covariates for the subject.

For example, the first row indicates that the subject 3960 entered the experiment in 1993, and had data measured in the period from day 245 in 1993 to day 332 in 1993. This "data" is the response $Y$ (not shown in above picture), and the idea is to do a regression using our covariates.

When the days exceed 365, that means that the longevity crossed over into the next year.

My question is, does it make sense to create a time series variable, and use it as another covariate, to model a "trend" effect + account for temporal autocorrelation? And if so, how would you create it?

For example, the earliest data in the data set is day 245 in 1994. Would you set this data equal to 0, and then for every response, you would take the corresponding difference between this day and the baseline, and use a "counter"?

• You could use a julian calendar. – Jaood May 3 '17 at 17:45