data(toenail.saemix)
saemix.data<-saemixData(name.data=toenail.saemix,name.group=c("id"), name.predictors=c("time","y"),
name.response="y", name.covariates=c("treatment"),name.X=c("time"))
binary.model<-function(psi,id,xidep) {
tim<-xidep[,1]
y<-xidep[,2]
inter<-psi[id,1]
slope<-psi[id,2]
logit<-inter+slope*tim
pevent<-exp(logit)/(1+exp(logit))
pobs = (y==0)*(1-pevent)+(y==1)*pevent
logpdf <- log(pobs)
return(logpdf)
}
saemix.model<-saemixModel(model=binary.model,description="Binary model",
modeltype="likelihood",
psi0=matrix(c(-5,-.1,0,0),ncol=2,byrow=TRUE,dimnames=list(NULL,c("theta1","theta2"))),
transform.par=c(0,0), covariate.model=c(0,1),
covariance.model=matrix(c(1,0,0,1),ncol=2))
# \donttest{
saemix.options<-list(seed=1234567,save=FALSE,save.graphs=FALSE, displayProgress=FALSE,
nb.chains=10, fim=FALSE)
binary.fit<-saemix(saemix.model,saemix.data,saemix.options)
plot(binary.fit, plot.type="convergence")
# }
Run the code above in your browser using DataLab