# NOT RUN {
data(yield.saemix)
saemix.data<-saemixData(name.data=yield.saemix,header=TRUE,name.group=c("site"),
name.predictors=c("dose"),name.response=c("yield"),
name.covariates=c("soil.nitrogen"),units=list(x="kg/ha",y="t/ha",covariates=c("kg/ha")))
# Model: linear + plateau
yield.LP<-function(psi,id,xidep) {
x<-xidep[,1]
ymax<-psi[id,1]
xmax<-psi[id,2]
slope<-psi[id,3]
f<-ymax+slope*(x-xmax)
#' cat(length(f)," ",length(ymax),"\n")
f[x>xmax]<-ymax[x>xmax]
return(f)
}
saemix.model<-saemixModel(model=yield.LP,description="Linear plus plateau model",
psi0=matrix(c(8,100,0.2,0,0,0),ncol=3,byrow=TRUE,dimnames=list(NULL,
c("Ymax","Xmax","slope"))),covariate.model=matrix(c(0,0,0),ncol=3,byrow=TRUE),
transform.par=c(0,0,0),covariance.model=matrix(c(1,0,0,0,1,0,0,0,1),ncol=3,
byrow=TRUE),error.model="constant")
saemix.options<-list(algorithms=c(1,1,1),nb.chains=1,seed=666,
save=FALSE,save.graphs=FALSE)
# Plotting the data
plot(saemix.data,xlab="Fertiliser dose (kg/ha)", ylab="Wheat yield (t/ha)")
# }
Run the code above in your browser using DataLab