I have weekly observations of revenues from the sale of different products, separately for different countries, like so:
df <- data.frame(year=rep(c(2002,2003), each=16),
week=rep(1:4,4),
product=rep(c('A','B'), each=8, times=2),
country=rep(c('usa','germany'), each=4, times=4),
revenue=abs(rnorm(32)))
That means observations of revenues are only unique for a combination of year-week-country-product
I would now like to estimate a model that includes fixed effects for the interaction of country and year and for each product but cannot figure out how to do this:
- estimating via
summary(lm(revenue~factor(paste(country,year)) + factor(product) + ..., data=df))fails for lack of memory because my data set is rather larger than the example above, which means I have to estimate something on the order of 1000 fixed effects - as far as I understand it panels are better estimated using the
plmpackage but my case doesn't seem to fit neatly within the standard framework of a panel in which observations differ only across one time and one cross-sectional dimension each and fixed effects are estimated for each. I can generate a time index fromyearandweekbut that (a) still leaves me with two cross-sectional dimensions and (b) will give me fixed effects for eachyear-weekinteraction, which is rather more fine than I want it to be.
Are there any ways of estimating this with plm or are there other packages which do this sort of thing? I know I could demean the data within the groups described above, estimate via lm and then do a df-correction, but I'd rather avoid this.