0

I want to write a random effect model for this regression :

randeffect<- lmer(effort~bs+bso+fe+st+maj+exp+hw+(randomeslope/randomgroupe))

I am beginner in r and actually don't know which code even lmer is useful for random effect model or not, moreover each of the independent variables are generated randomly, so they are not in the one data frame! My data are :

hw<- sample(0:1, 1000, replace =T)
exp<- sample(0:1, 1000, replace = T)
maj<- sample(0:1,1000,replace = T)
st<- sample(0:1,1000,replace = T)
fe<- sample(0:1,1000,replace = T)
effort <-sample(0:4, 1000,replace= T)

bso <- function(effort){
case_when(effort == 0~ 4500,
        effort == 1~ 4300,
        effort == 2~ 3700,
        effort == 3~ 4700, TRUE ~ 5300)
}
bs <- function(effort){
case_when(effort == 0~ 2500,
        effort == 1~ 3300,
        effort == 2~ 3700,
        effort == 3~ 3700, TRUE ~ 3300)
 }
 bs<-bs(effort)
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • For a how to guide see https://bbolker.github.io/mixedmodels-misc/glmmFAQ.html#model-specification or https://stats.stackexchange.com/questions/13166/rs-lmer-cheat-sheet – user20650 Jan 31 '21 at 14:50
  • ... when applying this it will be much easier if you combine all your data into one data.frame before starting to estimate models. – user20650 Jan 31 '21 at 14:51
  • how can I merge them ? – Marzieh Karimi Jan 31 '21 at 16:15
  • I don't know -- you have not shown any data. Please have a read of https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example which describes ways to write questions which will help you get an answer. I also think this is different enough from your question on specifying random effects to warrant a new question. – user20650 Jan 31 '21 at 16:18
  • I have added my data , do you have any idea for that ? – Marzieh Karimi Jan 31 '21 at 16:36

0 Answers0