Description Usage Arguments Details Value Numerical Jacobians of f and g Note Author(s) References See Also Examples
Estimates population parameters in a linear or non-linear mixed effects model based on stochastic differential equations by use of maximum likelihood and the Kalman filter.
1 | PSM.estimate(Model, Data, Par, CI = FALSE, trace = 0, control=NULL, fast=TRUE)
|
Model |
A list containing the following elements:
|
Data |
An unnamed list where each element contains
data for one individual. Each element in
|
Par |
A list containing the following elements:
|
CI |
Boolean. If true, the program estimates 95% confidence
intervals, standard deviation and correlation matrix for the
parameter estimates based on the Hessian of the likelihood function. The
Hessian is estimated by |
trace |
Non-negative integer. If positive, tracing information on the progress of the optimization is produced. Higher values produces more tracing information. |
control |
A list of control parameters for the optimization of the likelihood function. The list has one required component, namely:
The remaining components in the list are given as the control argument for the chosen optimizer. See corresponding help file for further detail. |
fast |
Boolean. Use compiled Fortran code for faster estimation. |
The first stage model describing intra-individual variations is for linear models defined as
dx = (A(phi)*x + B(phi)*u)dt + SIG(phi)*dw
y = C(phi)*x + D(phi)*u + e
and for non-linear models as
dx = f(x,u,t,phi)dt + SIG(u,t,phi)dw
y = g(x, u, t, phi) + e
where e ~ N(0,S(x, u, t)) and w is a standard Brownian motion.
The second stage model describing inter-individual variations is defined as:
phi = h(eta,theta,Z)
where eta ~ N(0,OMEGA), θ are the fixed effect parameters and Z are covariates for individual i. In a model without random-effects the function h is only used to include possible covariates in the model.
A list containing the following elements:
NegLogL |
Value of the negative log-likelihood function at optimum. |
THETA |
Population parameters at optimum |
CI |
95% confidence interval for the estimated parameters |
SD |
Standard deviation for the estimated parameters |
COR |
Correlation matrix for the estimated parameters |
sec |
Time for the estimation in seconds |
opt |
Raw output from |
Automatic numerical approximations of the Jacobians of f
and
g
can be used in PSM. In the folliwing, the name of the model
object is assumed to be MyModel
.
First define the
functions MyModel$Functions$f
and
MyModel$Functions$g
. When these are defined in MyModel the
functions df
and dg
can be added to the model object by
writing as below:
1 2 3 4 5 6 7 8 |
This way of defining df
and dg
forces a numerical
evaluation of the Jacobians using the numDeriv package. It may
be usefull in some cases, but it should be stressed that it will
probably give at least a ten-fold increase in estimation times.
For further details please also read the package vignette pdf-document
by writing vignette("PSM")
in R.
Stig B. Mortensen and Soeren Klim
Please visit http://www.imm.dtu.dk/psm or refer to
the main help page for PSM
.
PSM
, PSM.smooth
,
PSM.simulate
, PSM.plot
, PSM.template
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | #detailed examples are provided in the package vignette
#Theophylline data from Boeckmann et al (1994)
#objective: recover the administered doses
library(datasets)
data(Theoph)
#reshape data to PSM format
TheophPSM = list()
for(i in 1:length(unique(Theoph$Subject))){
TheophPSM[[i]] = with(
Theoph[Theoph$Subject == i,],
list(Y = matrix(conc, nrow=1), Time = Time)
)
}
#specify a simple pharmacokinetic model comprised of
#2 state equations and 1 observation equation
#initial value of 1 state eq. varies randomly across individuals
mod = vector(mode="list")
mod$Matrices = function(phi) {
list(
matA=matrix(c(-phi$ka, 0, phi$ka, -phi$ke), nrow=2, ncol=2, byrow=TRUE),
matC=matrix(c(0, 1), nrow=1, ncol=2)
)
}
mod$h = function(eta, theta, covar) {
phi = theta
phi$dose = theta$dose * exp(eta[1])
phi
}
mod$S = function(phi) {
matrix(c(phi$sigma), nrow=1, ncol=1)
}
mod$SIG = function(phi) {
matrix(c(0, 0, 0, phi$omega), nrow=2, ncol=2, byrow=TRUE)
}
mod$X0 = function(Time, phi, U) {
matrix(c(phi$dose, 0), nrow=2, ncol=1)
}
mod$ModelPar = function(THETA) {
list(theta=list(dose = THETA["dose"], ka = THETA["ka"], ke = THETA["ke"],
omega = THETA["omega"], sigma = THETA["sigma"]),
OMEGA=matrix(c(THETA["BSV_dose"]), nrow=1, ncol=1)
)
}
#specify the search space of the fitting algorithm
parM = c(ka = 1.5, ke = 0.1, dose = 10, omega = .3, sigma = 1,
BSV_dose = 0.015)
pars = list(LB=parM*.25, Init=parM, UB=parM*1.75)
#fit model and predict data
fit = PSM.estimate(mod, TheophPSM, pars, trace = 1, fast = TRUE,
control=list(optimizer="optim", maxit=1))
pred = PSM.smooth(mod, TheophPSM, fit$THETA)
#visualize recovery performance
true_dose = tapply(Theoph$conc, Theoph$Subject, mean)
true_dose = true_dose[order(as.numeric(names(true_dose)))]
est_dose = fit$THETA["dose"] * exp(unlist(lapply(pred, function(x) x$eta)))
plot(true_dose, est_dose,
xlab="actually administered dose", ylab= "recovered dose")
abline(lm(est_dose ~ true_dose), lty=2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.