0

I need to make a mixed model of a ecological dataset. I need to find the response in wing length of a species to 2 types of managment (intensive and extensive). So the model would be something like length~managment. The dataset provided has 2 sites in every managment type (so 4 in total) and every site has 10 subpopulations in it (so 40 subpopulations). So managment would be the fixed effect and site and subpopulation would be the random effects. The problem is the data set numbered the subpopulation 1-10 in every site. So different sites would have the same subpopulations, which in not true. I can't fit a decent model, because R now tells me the variation caused by subpopulation is too low to be considerable. I want to know how I can easily change the subpopulation numbering to be unique for each site.

  • 2
    It sounds like you have two problems, one is your own science problem, the other is an R question. You'll likely get help with R here. It would help if you showed your data structure, eg `dset <- data.frame(length=c(...your data...), management=c(rep('I',20),rep('E',20),site=lapply(1:4,rep,10) %>% unlist,subpop=rep(1:10,4))`, your model, eg `m <- glm(length~management,dset)`, and the error. To make a unique value for subpop you can try `dset$subpop <- dset$subpop + 1000*dset$site` or if site is a string `...+1000*as.numeric(as.factor(dset$site))`. – PeterK Dec 04 '20 at 14:06
  • Please make this question *reproducible*. This includes sample code you've attempted (including listing non-base R packages, and any errors/warnings received), sample *unambiguous* data (e.g., `data.frame(x=...,y=...)` or the output from `dput(head(x))`), and intended output given that input. Refs: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. – r2evans Dec 04 '20 at 14:28
  • I agree with PeterK, and suggest that at least part of your dilemma might be a better fit for [stats.se]. – r2evans Dec 04 '20 at 14:28
  • Problem solved btw. I forgot I could nest data. Thanks for the help – StackUnderflow Dec 06 '20 at 10:29

0 Answers0