I have a dataset with data from thousands of individuals with measurement of a parameter X measured yearly the last 9 years.
Basicly they are in a dataframe df
id,year,x,feature
A,2016,376,female
A,2015,391,female
A,2014,376,female
A,2013,373,female
A,2012,347,female
A,2011,330,female
B,2016,398,male
B,2015,391,male
B,2014,410,male
B,2013,393,male
B,2012,408,male
B,2011,288,male
C,2016,2464,male
C,2015,2465,male
C,2014,2500,male
C,2013,2215,male
C,2012,2228,male
C,2011,1839,male
etc.
I want to estimate different models on these timeseries
like predict(x(t)) = f(x(t-1),x(t-2),...,x(t-n),feature, id (taken as a random factor))
I can see how to use ts for autoregressive modelling but it will calculate thosands of indvidual models, and I want a global prediction (with its inherent problems) based on the time history and the features.
lm is not a good idea since the data is highly autocorrelated. Any good ideas?
