10 participants underwent a weight loss programme, like so:
mydata<-as.data.frame(matrix(c(140,125,120,115,110,110,110,105,100,90,85,100,140,70,100,
100,140,120,220,190,90,100,120,60,90,110,130,110,120,140,NA,65,110,50,NA,90,120,NA,130,
150,NA,60,NA,45,NA,NA,110,NA,160,NA),nrow=10,dimnames=list(c(1:10),c("IQ","Weight.year.1"
,"Weight.year.2","Weight.year.3","Weight.year.4"))))
I wonder if IQ predicts weight loss success.
I should not compute the delta, i.e. lm((Weight.year.1-Weight.year.4)~IQ,data=mydata)
, since heavier people have more potential to lose weight, and results would be biased. It also fails due to many missings.
One idea is to compute and use the person-specific coefficients, i.e. sapply(1:10,function(i){lm(t(mydata[i,2:5])~c(1:4))$coefficients[2]})
, which, however, still is related to baseline weight.
I am looking to give it a new try with random intercepts, but sadly I do not quite understand how to code this in R. Does anyone know of code to run such an analysis? Any help would be greatly appreciated!!
Kindest regards.
Aucun commentaire:
Enregistrer un commentaire