[R-sig-ME] multiple random effects and correlation structure in nlme

Karl Jarvis karljarvis at gmail.com
Thu Nov 5 17:32:49 CET 2015


Thierry,
Thanks for your reply. 

I hadn’t used “cost” as a fixed effect because I thought it had to be considered random. I have 10 simulated landscapes composed a combination of costs 1 and 4 in random fractal patterns. My “cost” column refers to the cost at regular points across the landscapes. Because they were randomly generated, I thought that meant that they should be random effects. But if that’s not the case, that could simplify things.

If I run it this way,
    lme(fixed = He ~ barr + mort + cost, random = ~ N | lr, data = ibr4, 
             correlation = corExp(form = ~ x + y | lr), method = “ML”,
             control=lmeControl(opt = "nlminb"))

It gives this error:
Error in lme.formula(fixed = He ~ barr + mort + cost, random = ~N | lr,  : 
  nlminb problem, convergence error code = 1
  message = iteration limit reached without convergence (10)

And if I change the optimizer to “optim” it gives me this error:
Error in logLik.reStruct(object, conLin) : 
  NA/NaN/Inf in foreign function call (arg 3)

However, it works for me to run it this way, with barr and mort merged into one grouping factor “road”, nested in “land":
    lme(fixed = He ~ barr + mort + cost, random = ~ N | land, data = ibr4, 
             correlation = corExp(form = ~ x + y | land/road), method = “ML”,
             control=lmeControl(opt = "nlminb"))

    lme(fixed = He ~ barr + mort + cost, random = ~ N | land/road, data = ibr4, 
             correlation = corExp(form = ~ x + y | land/road), method = “ML”,
             control=lmeControl(opt = "nlminb”))

I know that “land" has a much greater influence on “N" than either “barr” or “mort” does, but I know that all 3 (land, barr, and mort) affect N. But AIC tells me that “land” works better as a grouping factor than land/road. So maybe I shouldn’t worry about nesting in that case and can ignore the issues with trying to cross the factors. Does that make sense, or do you have other ideas about getting it to work? 
Karl

> On Nov 5, 2015, at 1:45 AM, Thierry Onkelinx <thierry.onkelinx at inbo.be> wrote:
> 
> Dear Karl,
> 
> You have only 2 levels of cost. So it better to move that to the fixed effects. Then you'll have only one random effect.
> 
> Best regards,
> 
> Thierry
> 
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest 
> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance 
> Kliniekstraat 25
> 1070 Anderlecht
> Belgium
> 
> To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher
> The plural of anecdote is not data. ~ Roger Brinner 
> The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey
> 
> 2015-11-04 23:50 GMT+01:00 Karl Jarvis <karljarvis at gmail.com <mailto:karljarvis at gmail.com>>:
> Hi all,
> I am trying to build a model that includes two random effects while also using a correlation structure to account for spatial autocorrelation. It’s a full factorial study on simulations of wildlife where individuals are spread across landscapes, so one of the random effects (N) is crossed.
> 
> If I use nlme I can do this by reusing creating a new group factor by pasting the three crossed factors together (would be land:barr:mort in lme4), which I call ‘lr'. The parameter estimates are similar, so it seems ok. (Link to the data frame: https://drive.google.com/open?id=0B096pYMrPnKAdC1FdWhCR3Z4bjg <https://drive.google.com/open?id=0B096pYMrPnKAdC1FdWhCR3Z4bjg><https://drive.google.com/open?id=0B096pYMrPnKAdC1FdWhCR3Z4bjg <https://drive.google.com/open?id=0B096pYMrPnKAdC1FdWhCR3Z4bjg>> )
>         ibr4 <- read.csv(“~/ibr4.csv”)
>         m1 <- lme(A ~ barr + mort, random = list(~cost | land, ~N | lr), data=ibr4, method = “ML”)
> 
> Once I try to do that along with a correlation structure, it complains that there are incompatible formulas for ‘random’ and ‘correlation’.
>         m2 <- lme(A ~ barr + mort, random = list(~cost | land, ~N | lr), data=ibr4, method = “ML”,
>         correlation = corExp(form = ~ x+y | lr))
> 
> I think it’s because it doesn’t know how to relate lr to land, because it complains the same way when the only random effect is '~cost | land’. However, when one random effect is in the model with a correlation structure nested as ~x+y | land/barr/mort, it does work. But it doesn’t seem to ever accept multiple random effects together with a correlation structure. I know Pinheiro and Bates say in their book (p.163) that you can build a crossed random-effects structure with pdBlocked and pdIdent, but (1) it’s not clear to me how to do this for a single random effect, and (2) it’s not clear to me that you could include multiple random effects in such a structure. Am I misunderstanding how correlation structures and/or random effects work? Let me know if you need more information about my data.
> 
> Thanks,
> Karl
>         [[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-mixed-models at r-project.org <mailto:R-sig-mixed-models at r-project.org> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models <https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models>

	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list