# Formulate a 2-Level-Model with ARIMA on Level 1

I have a dataset where I have two levels:

-level 1: Individuals create many observations as a time-series (e.g. daily footsteps)

-level 2: Information about the individuals (e.g. employment)

I want to model the individual time-series observations with ARIMA where I am especially interested in the effect of one specific regressor, say $$\beta$$ (e.g. weather). In second level, I want to model how information about the individual moderates the effect of $$\beta$$ (e.g. does employment decrease the effect of weather on daily foodsteps?)

I am not sure how to build the model: I could integrate individual information as an interactio term on the regressor and estimate one ARIMA for all individuals. I could also estimate seperate ARIMA models and regress the level 2 information on the corresponding $$\beta$$, see Using estimated parameters as dependent variables .

However, I am not sure about the hierarchical structure of the data. As I am using time-series, the correlation within an individual's oberservations is already accounted for (e.g. footsteps on day $$t$$ correlate with footsteps on day $$t-1$$). Also, I do not care about the direct effect of level-2 information on my DV.

Which kind of model implements the hierarchical structure more convenient and allows for arima models? Is there a useful R package you can recommend?

Thanks for support

• I think I could give a hint on the model specification (in particular on the interaction), but, before doing that, i need to get a better understanding of your sentence "I want to model the individual time-series observations with ARIMA where I am especially interested in the effect of one specific regressor, say β (e.g. weather)". So my question is... cont – Fr1 Sep 4 '19 at 11:48
• So you have a time-series of daily footsteps over time for each individual, that is assumed to follow an ARIMA. Then you want to add exogenous regressors like weather. And you want to assess how such $\beta$ with respect to weather varies based on the different characteristics of individuals. Is that correct? – Fr1 Sep 4 '19 at 11:50
• Do you have weather data at an hourly level ? It is possible to form an hourly model using deterministic patterns e.g. day-of-the-week , week-of-the-month , month-of-the-year, holiday effects et al AND arima structure. It is also possible to predict daily activity and use daily totals as an additional predictor for each hourly model. If you have data please post it specifying the start date and the country as holiday effects change based upon the country. – IrishStat Sep 4 '19 at 12:36
• @Fr1 yes, you are correct. – Jan PK Sep 4 '19 at 12:49
• @IrishStat It is just an example to understande the problem. The question in general is about how to model the moderating relationship between level 2 variables on a parameter estimate from a level 1 model. – Jan PK Sep 4 '19 at 12:53

This is more a hint than a true definitive answer, but I think it may be useful to shed light on a very important point.

So let's firstly describe a very simplified approach. A very simplified approach might be to fit an ARIMAX model on each univariate time series of footsteps, where the ext covariates may be the weather (say $$\beta_{i}$$ is the beta of each individual to the external covariate "weather") and possibly others, and then perform a second-level cross-sectional regression on the $$\beta_{i}$$ against indivdual-specific independent variables. That would be a very simplified and intuitive two-stage approach. is it wrong? Well it is not wrong per se, the problem is that, however, it is a two-stage procedure and is exposed to the various problems of using a two-stage procedure and a univariate model instead of a one-stage multivariate procedure that may reduce the standard error. So it is a reasonable appraoch, but it is simplified and, as such, it will likely have more standard error because, at each step, it will not necessarily maximize the amount of info used to estimate the coefficients (consider for example the difference between the use of several distinct univariate regressions and the seemingly unrelated regression approach (SUR)).

So how to estimate everything in a shot and in a multivariate model? Well here the thing gets a bit complex. I will provide here a suggestion for this more structured solution aimed at introducing this kind of models (then you will be free to visualize the exact specification that best suites your needs).

Consider the following MARSS. Go to pag.21 where they show the multivariate version with external covariates for both the $$x$$ and the $$y$$. You will have something like (I simplify the notation a little bit here):

$$\begin{matrix} y_t & = & Zx_t + Ad_{t} + \epsilon_{t} \\ x_{t+1} & = & Bx_{t}+ Uc_{t} + u_{t} \end{matrix}$$

For visual simplicity, let's now add a lagged term on the right hand side of y, and change the term $$Zx_{t}$$ into $$Z_{t}x_{t}$$, so that Z can be time-varying:

$$\begin{matrix} y_t & = & Z_{t}x_{t} + Ad_{t} + \Gamma y_{t-1} + \epsilon_{t} \\ x_{t+1} & = & Bx_{t}+ Uc_{t} + u_{t} \end{matrix}$$

where

• $$Z_{t}$$ is restricted to be diagonal and stores on its diagonal the weather seen for each individual (if it is the same for everyone, then the entries along the diagonal are constant) at each observed time period t

• $$x_{t}$$ is the vector whose i-th entry is the beta of the footsteps of the i-th individual of the vector $$y_{t}$$ to the weather seen by the corresponding individual (i-th element on the diagonal of $$Z_{t}$$ for each period t).

As you may notice, the weather stored on $$Z_{t}$$ is treated like an external variable whose value is given for each t (other external common covariates for all the individuals in $$y_{t}$$ may be stored in the vector $$d_{t}$$ of the term $$Ad_{t}$$). And clearly you can model the time-varying nature of the coefficients in $$x_{t}$$ based on their past values (term $$Bx_{t}$$) and even possible external covariates for $$x_{t}$$ (term $$Uc_{t}$$). For example, one external covariate may be the proximity of the individual to a park, expressed on a ranked basis in comparison to the other individuals in the sample. You can add any covariates here to explore the relationship between those variables and the sensitivity of each individual in $$y_{t}$$ to the weather in $$Z_{t}$$.

The unknowns in your model (to be estimated via MLE/EM Algorithm) will be the matrixes of coefficients denoted in capital letters, along with the covariance matrixes of the residual terms $$\epsilon_{t}$$ and $$u_{t}$$. Since you have a lot of parameters, the risk is to overfit. So you can restrict the those matrixes of unknowns to be diagonal to reduce such risks (clearly you are free to play with your model specification and choose the one that best suites your needs). And of course you can use the traditional Information Criteria for State Space Models. See for example here.