UPDATE JUNE 2016:
Please see Ben's blog entry describing his current thoughts on accomplishing this in lme4
: Braindump 01 June 2016
If you prefer Bayesian methods, the brms
package's brm
supports some correlation structures: CRAN brms page. (Note especially: "As of brms version 0.6.0, the AR structure refers to autoregressive effects of residuals to match the naming and implementation in other packages such as nlme. Previously, the AR term in brms referred to autoregressive effects of the response. The latter are now named ARR effects and can be modeled using argument r in the cor_arma and cor_arr functions.")
ORIGINAL ANSWER JULY 2013:
(Converted from a comment.)
I would say lmer
would be pretty good with a random effect of year and a random effect of customer (let's say you only have one measurement per customer per year);
lmer(y~1 + (1|year) + (1|customer), ...)
would fit the (intercept-only) model
$$
Y_{ij} \sim \text{Normal}(a + \epsilon_{\text{year},i} + \epsilon_{\text{customer},j}, \sigma^2_0)
$$
where $\epsilon_{\text{year}}$ and $\epsilon_{\text{customer}}$ are zero-mean Normal variates with their own specific variances.
This is a pretty boring model, you might want to add an overall (fixed-effect) trend of time and also consider a random time-by-customer interaction (i.e. random slopes). I think
lmer(y~year + (1|year) + (year|customer), ...)
should fit the model
$$
Y_{ij} \sim \text{Normal}((a + \epsilon_{\text{customer},j}) + (b + \epsilon_{\text{year} \times \text{customer},j}) \cdot \text{year} + \epsilon_{\text{year},i}, \sigma^2_0)
$$
(using year
in this way is an exception to the usual rule of not including an input variable as both a fitted and a random effect in the same model; provided it's a numeric variable, year
gets treated as continuous in the fixed effect and the year:customer
(random) interaction and as categorical in the random effect ...)
Of course you might want to add year-level, customer-level, and observation-level covariates which would soak up some of the relevant variance (e.g. add average consumer price index to explain why years were bad or good ...)
Ideally you would also want to allow for temporal autocorrelation within each customer's time series, which is at the moment not possible with lmer
, but you could check the temporal autocorrelation function to see if that was important ...
Caveat: I don't know that much about standard approaches for handling panel data; this is based just on my knowledge of mixed models. Commenters (or editors) should feel free to chime in if this seems to violate standard/best practices in econometrics.
lmer
still does not handle the variety of correlation and variance structures thatlme
does, and as I understand the situation, it probably never will. $\endgroup$lmer
's ability to handle panel dataset? Or can I get away without making specific correlation assumptions? $\endgroup$lmer
to handle them ... Hong, can you add a brief explanation to the question that describes the necessary statistical properties in a little more detail, or gives pointers? $\endgroup$lmer
would be pretty good with a random effect of year and a random effect of customer (let's say you only have one measurement per customer per year); if you are fitted an overall (fixed-effect) trend of time you should also consider a random time-by-customer interaction (i.e. random slopes). Ideally you would also want to allow for temporal autocorrelation within each customer's time series, which is at the moment not possible with lmer, but you could check the temporal autocorrelation function to see if that was important ... $\endgroup$