Learn R Programming

saemix (version 3.3)

saemixModel: Function to create an SaemixModel object

Description

This function creates an SaemixModel object. The two mandatory arguments are the name of a R function computing the model in the SAEMIX format (see details and examples) and a matrix psi0 giving the initial estimates of the fixed parameters in the model, with one row for the population mean parameters and one row for the covariate effects (see documentation).

Usage

saemixModel(
  model,
  psi0,
  description = "",
  modeltype = "structural",
  name.response = "",
  name.sigma = character(),
  error.model = character(),
  transform.par = numeric(),
  fixed.estim = numeric(),
  covariate.model = matrix(nrow = 0, ncol = 0),
  covariance.model = matrix(nrow = 0, ncol = 0),
  omega.init = matrix(nrow = 0, ncol = 0),
  error.init = numeric(),
  name.modpar = character(),
  simulate.function = NULL,
  verbose = TRUE
)

Value

An SaemixModel object (see saemixModel).

Arguments

model

name of the function used to compute the structural model. The function should return a vector of predicted values given a matrix of individual parameters, a vector of indices specifying which records belong to a given individual, and a matrix of dependent variables (see example below).

psi0

a matrix with a number of columns equal to the number of parameters in the model, and one (when no covariates are available) or two (when covariates enter the model) giving the initial estimates for the fixed effects. The column names of the matrix should be the names of the parameters in the model, and will be used in the plots and the summaries. When only the estimates of the mean parameters are given, psi0 may be a named vector.

description

a character string, giving a brief description of the model or the analysis

modeltype

a character string, giving model type (structural or likelihood)

name.response

the name of the dependent variable

name.sigma

a vector of character string giving the names of the residual error parameters

error.model

type of residual error model (valid types are constant, proportional, combined and exponential). Defaults to constant

transform.par

the distribution for each parameter (0=normal, 1=log-normal, 2=probit, 3=logit). Defaults to a vector of 1s (all parameters have a log-normal distribution)

fixed.estim

whether parameters should be estimated (1) or fixed to their initial estimate (0). Defaults to a vector of 1s

covariate.model

a matrix giving the covariate model. Defaults to no covariate in the model

covariance.model

a square matrix of size equal to the number of parameters in the model, giving the variance-covariance matrix of the model: 1s correspond to estimated variances (in the diagonal) or covariances (off-diagonal elements). Defaults to the identity matrix

omega.init

a square matrix of size equal to the number of parameters in the model, giving the initial estimate for the variance-covariance matrix of the model.

error.init

a vector of size 2 giving the initial value of a and b in the error model. Defaults to 1 for each estimated parameter in the error model

name.modpar

names of the model parameters, if they are not given as the column names (or names) of psi0

simulate.function

for non-Gaussian data models, defined as modeltype='likelihood', the name of the function used to simulate from the structural model. The function should have the same header as the model function, and should return a vector of simulated values given a matrix of individual parameters, a vector of indices specifying which records belong to a given individual, and a matrix of dependent variables (see example in the documentation, section discrete data examples)

verbose

a boolean, controlling whether information about the created should be printed out. Defaults to TRUE

Author

Emmanuelle Comets emmanuelle.comets@inserm.fr, Audrey Lavenu, Marc Lavielle.

Details

This function is the user-friendly constructor for the SaemixModel object class.

References

E Comets, A Lavenu, M Lavielle M (2017). Parameter estimation in nonlinear mixed effect models using saemix, an R implementation of the SAEM algorithm. Journal of Statistical Software, 80(3):1-41.

E Kuhn, M Lavielle (2005). Maximum likelihood estimation in nonlinear mixed effects models. Computational Statistics and Data Analysis, 49(4):1020-1038.

E Comets, A Lavenu, M Lavielle (2011). SAEMIX, an R version of the SAEM algorithm. 20th meeting of the Population Approach Group in Europe, Athens, Greece, Abstr 2173.

See Also

SaemixData,SaemixModel, saemixControl,saemix

Examples

Run this code

model1cpt<-function(psi,id,xidep) { 
	  dose<-xidep[,1]
	  tim<-xidep[,2]  
	  ka<-psi[id,1]
	  V<-psi[id,2]
	  CL<-psi[id,3]
	  k<-CL/V
	  ypred<-dose*ka/(V*(ka-k))*(exp(-k*tim)-exp(-ka*tim))
	  return(ypred)
}

saemix.model<-saemixModel(model=model1cpt,
  description="One-compartment model with first-order absorption", 
  psi0=matrix(c(1.,20,0.5,0.1,0,-0.01),ncol=3, byrow=TRUE,
  dimnames=list(NULL, c("ka","V","CL"))),transform.par=c(1,1,1),
  covariate.model=matrix(c(0,1,0,0,0,0),ncol=3,byrow=TRUE),fixed.estim=c(1,1,1),
  covariance.model=matrix(c(1,0,0,0,1,0,0,0,1),ncol=3,byrow=TRUE),
  omega.init=matrix(c(1,0,0,0,1,0,0,0,1),ncol=3,byrow=TRUE),error.model="constant")

Run the code above in your browser using DataLab