| Contents | Index |
[BETA,PSI,STATS,B]
= nlmefitsa(X,Y,GROUP,V,MODELFUN,BETA0)
[BETA,PSI,STATS,B]
= nlmefitsa(X,Y,GROUP,V,MODELFUN,BETA0,'Name',Value)
[BETA,PSI,STATS,B] = nlmefitsa(X,Y,GROUP,V,MODELFUN,BETA0) fits a nonlinear mixed-effects regression model and returns estimates of the fixed effects in BETA. By default, nlmefitsa fits a model where each model parameter is the sum of a corresponding fixed and random effect, and the covariance matrix of the random effects is diagonal, i.e., uncorrelated random effects.
The BETA, PSI, and other values this function returns are the result of a random (Monte Carlo) simulation designed to converge to the maximum likelihood estimates of the parameters. Because the results are random, it is advisable to examine the plot of simulation to results to be sure that the simulation has converged. It may also be helpful to run the function multiple times, using multiple starting values, or use the 'Replicates' parameter to perform multiple simulations.
[BETA,PSI,STATS,B] = nlmefitsa(X,Y,GROUP,V,MODELFUN,BETA0,'Name',Value) accepts one or more comma-separated parameter name/value pairs. Specify Name inside single quotes.
Definitions:
In the following list of arguments, the following variable definitions apply:
n — number of observations
h — number of predictor variables
m — number of groups
g — number of group-specific predictor variables
p — number of parameters
f — number of fixed effects
By default, nlmefitsa fits a model where each model parameter is the sum of a corresponding fixed and random effect. Use the following parameter name/value pairs to fit a model with a different number of or dependence on fixed or random effects. Use at most one parameter name with an 'FE' prefix and one parameter name with an 'RE' prefix. Note that some choices change the way nlmefitsa calls MODELFUN, as described further below.
The default model is equivalent to setting both FEConstDesign and REConstDesign to eye(p), or to setting both FEParamsSelect and REParamsSelect to 1:p.
Additional optional parameter name/value pairs control the iterative algorithm used to maximize the likelihood:
'CovPattern' |
Specifies an r-by-r logical or numeric matrix PAT that defines the pattern of the random effects covariance matrix PSI. nlmefitsa computes estimates for the variances along the diagonal of PSI as well as covariances that correspond to non-zeroes in the off-diagonal of PAT. nlmefitsa constrains the remaining covariances, i.e., those corresponding to off-diagonal zeroes in PAT, to be zero. PAT must be a row-column permutation of a block diagonal matrix, and nlmefitsa adds non-zero elements to PAT as needed to produce such a pattern. The default value of PAT is eye(r), corresponding to uncorrelated random effects. Alternatively, specify PAT as a 1-by-r vector containing values in 1:r. In this case, elements of PAT with equal values define groups of random effects, nlmefitsa estimates covariances only within groups, and constrains covariances across groups to be zero. |
'Cov0' |
Initial value for the covariance matrix PSI. Must be an r-by-r positive definite matrix. If empty, the default value depends on the values of BETA0. |
'ComputeStdErrors' |
true to compute standard errors for the coefficient estimates and store them in the output STATS structure, or false (default) to omit this computation. |
'ErrorModel' |
A string specifying the form of the error term. Default is 'constant'. Each model defines the error using a standard normal (Gaussian) variable e, the function value f, and one or two parameters a and b. Choices are
If this parameter is given, the output STATS.rmse field has the value
|
'ErrorParameters' |
A scalar or two-element vector specifying starting values for parameters of the error model. This specifies the a, b, or [a b] values depending on the ErrorModel parameter. |
'LogLikMethod' |
Specifies the method for approximating the log likelihood. Choices are:
|
'NBurnIn' |
Number of initial burn-in iterations during which the parameter estimates are not recomputed. Default is 5. |
'NChains' |
Number c of "chains" simulated. Default is 1. Setting c>1 causes c simulated coefficient vectors to be computed for each group during each iteration. Default depends on the data, and is chosen to provide about 100 groups across all chains. |
'NIterations' |
Number of iterations. This can be a scalar or a three-element vector. Controls how many iterations are performed for each of three phases of the algorithm:
Default is [150 150 100]. A scalar is distributed across the three phases in the same proportions as the default. |
'NMCMCIterations' |
Number of Markov Chain Monte Carlo (MCMC) iterations. This can be a scalar or a three-element vector. Controls how many of three different types of MCMC updates are performed during each phase of the main iteration:
Default is [2 2 2]. A scalar value is treated as a three-element vector with all elements equal to the scalar. |
'OptimFun' |
Either 'fminsearch' or 'fminunc', specifying the optimization function to be used during the estimation process. Default is 'fminsearch'. Use of 'fminunc' requires Optimization Toolbox. |
'Options' |
A structure created by a call to statset. nlmefitsa uses the following statset parameters:
|
'ParamTransform' |
A vector of p values specifying a transformation function f() for each of the p parameters: XB = ADESIGN*BETA + BDESIGN*B PHI = f(XB) Each element of the vector must be one of the following integer codes specifying the transformation for the corresponding value of PHI:
|
'Replicates' |
Number REPS of estimations to perform starting from the starting values in the vector BETA0. If BETA0 is a matrix, REPS must match the number of columns in BETA0. Default is the number of columns in BETA0. |
'Vectorization' |
Determines the possible sizes of the PHI, XFUN, and VFUN input arguments to MODELFUN. Possible values are:
The default for 'Vectorization' is 'SinglePhi'. In all cases, if V is empty, nlmefitsa calls MODELFUN with only two inputs. |
Fit a model to data on concentrations of the drug indomethacin in the bloodstream of six subjects over eight hours:
load indomethacin model = @(phi,t)(phi(:,1).*exp(-phi(:,2).*t)+phi(:,3).*exp(-phi(:,4).*t)); phi0 = [1 1 1 1]; % log transform for 2nd and 4th parameters xform = [0 1 0 1]; [beta,PSI,stats,br] = nlmefitsa(time,concentration,... subject,[],model,phi0,'ParamTransform',xform)

% Plot the data along with an overall "population" fit
clf
phi = [beta(1), exp(beta(2)), beta(3), exp(beta(4))];
h = gscatter(time,concentration,subject);
xlabel('Time (hours)')
ylabel('Concentration (mcg/ml)')
title('{\bf Indomethacin Elimination}')
xx = linspace(0,8);
line(xx,model(phi,xx),'linewidth',2,'color','k')
% Plot individual curves based on random effect estimates
for j=1:6
phir = [beta(1)+br(1,j), exp(beta(2)+br(2,j)), ...
beta(3)+br(3,j), exp(beta(4)+br(4,j))];
line(xx,model(phir,xx),'color',get(h(j),'color'))
end

In order to estimate the parameters of a nonlinear mixed effects model, we would like to choose the parameter values that maximize a likelihood function. These values are called the maximum likelihood estimates. The likelihood function can be written in the form
![]()
where
y is the response data
β is the vector of population coefficients
σ2 is the residual variance
∑ is the covariance matrix for the random effects
b is the set of unobserved random effects
Each p() function on the right-hand-side is a normal (Gaussian) likelihood function that may depend on covariates.
Since the integral does not have a closed form, it is difficult to find parameters that maximize it. Delyon, Lavielle, and Moulines [1] proposed to find the maximum likelihood estimates using an Expectation-Maximization (EM) algorithm in which the E step is replaced by a stochastic procedure. They called their algorithm SAEM, for Stochastic Approximation EM. They demonstrated that this algorithm has desirable theoretical properties, including convergence under practical conditions and convergence to a local maximum of the likelihood function. Their proposal involves three steps:
Simulation: Generate simulated values of the random effects b from the posterior density p(b|Σ) given the current parameter estimates.
Stochastic approximation: Update the expected value of the log likelihood function by taking its value from the previous step, and moving part way toward the average value of the log likelihood calculated from the simulated random effects.
Maximization step: Choose new parameter estimates to maximize the log likelihood function given the simulated values of the random effects.
[1] Delyon, B., M. Lavielle, and E. Moulines, Convergence of a stochastic approximation version of the EM algorithm, Annals of Statistics, 27, 94-128, 1999.
[2] Mentré, France, and Marc Lavielle, Stochastic EM algorithms in population PKPD analyses, 2008.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |