0

I have a huge dataframe (31584 rows) which consists of crop yield data collected over multiple districts and years.

Each district is nested within a State and each State is nested within an ACZ or climate zone.

I want to build a mixed model using yield as response and 11 climate variables (one of which is a drought index)

I also have another grouping variable which classifies the irrigation level as low, medium or high.

I specified my model as follows:

mod <- lmer(crop.yield ~ # 11 climate variables + year + (1|ACZ) + (1|state) + (1 + year|district) +  (1 + drought|irrigation), REML = FALSE, data = dat)

If I understand it correctly, I am specifying that the year trend changes from district to district. Simiarly, the effect of drought also changes according to irrigation level. I hope my understanding is correct.

I need some advise on how to make my lme4 fitting faster. When I run the above command, it is taking too much time to run. It's been one hour now and the command is still running. I need some suggestion on how to make it faster?

89_Simple
  • 3,393
  • 3
  • 39
  • 94
  • You could test your model on a subset of your data first to see if it returns reasonable results. A thing I noticed in your question is a possible multicolinearity between "drought index" and "irrigation level" which could make your model non-identifiability. – moooh Jun 25 '18 at 13:38
  • The author of the package didn't have any suggestions [here](https://stackoverflow.com/questions/32177542/speed-up-lmer-function-in-r). – Dan Jun 25 '18 at 13:40
  • You might need to choose a different statistical model that scales better with your data. You should probably ask for help at [stats.se] where statistical questions are on topic. This isn't really a programming question because there's not just a `run.faster=TRUE` flag for functions like this. Not sure what you were expecting. – MrFlick Jun 25 '18 at 13:41
  • 1
    Possible duplicate: https://stackoverflow.com/questions/32177542/speed-up-lmer-function-in-r – MrFlick Jun 25 '18 at 13:42
  • okay. Thank you everyone for your advise. – 89_Simple Jun 25 '18 at 13:46

0 Answers0