# You need to have MASS installed to successfully run this example
if (requireNamespace("MASS")) {
epilepsy<-MASS::epil
saemix.data<-saemixData(name.data=epilepsy, name.group=c("subject"),
name.predictors=c("period","y"),name.response=c("y"),
name.covariates=c("trt","base", "age"), units=list(x="2-week",y="",covariates=c("","","yr")))
## Poisson model with one parameter
countPoi<-function(psi,id,xidep) {
y<-xidep[,2]
lambda<-psi[id,1]
logp <- -lambda + y*log(lambda) - log(factorial(y))
return(logp)
}
saemix.model<-saemixModel(model=countPoi,description="Count model Poisson",modeltype="likelihood",
psi0=matrix(c(0.5),ncol=1,byrow=TRUE,dimnames=list(NULL, c("lambda"))), transform.par=c(1))
# \donttest{
saemix.options<-list(seed=632545,save=FALSE,save.graphs=FALSE, displayProgress=FALSE)
poisson.fit<-saemix(saemix.model,saemix.data,saemix.options)
# }
}
Run the code above in your browser using DataLab