[R] Can we fit this model in nlme or lme4?

Haoda Fu fuhds at yahoo.com.cn
Tue Mar 29 03:10:12 CEST 2011


Hi,

I was wondering if the following model can be fitted by nlme/lme4. The difficult part is that the error term is combined with other parameters.
The model that we need to fit is as below and the R codes to generate data is provided as well. Many thanks!!!

# Y_{ijk} = (E_0 + Emax*dose_i/(ED_50+dose_i) + S_{ij} + e_{ijk})*(1-exp(k*X_{ijk}))/(1-exp(k*d));
## Parameters to be estimated E0, Emax, ED50, sigma_S, sigma_e, kn

Patients <- 100; # 100 patients
nVisit <- 12; # total 12 visit
d <- 6; # 6 month study
dose <- c(0,5,10,20,40,100,200);
visits <- seq(6/12,6,by = 6/12);
# true parameters
E0 <- 2;
Emax <- 20;
ED50 <- 10;
sigma_S <- 5;
sigma_e <- 4;
k <- -1;

dataM <- matrix(NA, nrow = nPatients*nVisit, ncol= 4);
for(iter in 1:nPatients){
  dose_i <- sample(dose,1);
  S_i <- rep(rnorm(n=1, mean=0, sd=sigma_S),nVisit); # random effect for this patients 
  e_i <- rnorm(n=nVisit, mean=0, sd=sigma_e);
  response_i <- (E0+Emax*dose_i/(ED50+dose_i)+S_i+e_i)*(1-exp(k*visits))/(1-exp(k*d));
  patients_i <- cbind(rep(iter,nVisit),rep(dose_i,nVisit),visits,response_i);
  dataM[(nVisit*(iter-1)+1):(nVisit*(iter-1)+nVisit),] <- patients_i;
  }

colnames(dataM) <- c("PatientID","Dose","VisitTime","Response")


Best,
Haoda



More information about the R-help mailing list