Documentation 
Estimate nonlinear mixed effects with stochastic EM algorithm
sbionlmefitsa will be removed in a future release. Use sbiofitmixed instead.
results = sbionlmefitsa(modelObj, pkModelMapObject, pkDataObject, InitEstimates)
results = sbionlmefitsa(modelObj, pkModelMapObject, pkDataObject, CovModelObj)
results = sbionlmefitsa(..., Name,Value)
results = sbionlmefitsa(..., optionStruct)
[results, SimDataI, SimDataP]
= sbionlmefitsa(...)
Note: This function requires nlmefitsa in Statistics Toolbox™ (Version 7.0 or later). 
results = sbionlmefitsa(modelObj, pkModelMapObject, pkDataObject, InitEstimates) performs estimations using the Stochastic Approximation ExpectationMaximization (SAEM) algorithm for fitting population data with the SimBiology^{®} model, modelObj, and returns the estimated results in the results structure.
results = sbionlmefitsa(modelObj, pkModelMapObject, pkDataObject, CovModelObj) specifies the relationship between parameters and covariates using CovModelObj, a CovariateModel object. The CovariateModel object also provides the parameter transformation.
results = sbionlmefitsa(..., Name,Value) performs estimations using the SAEM algorithm, with additional options specified by one or more Name,Value pair arguments.
Following is an alternative to the previous syntax:
results = sbionlmefitsa(..., optionStruct) specifies optionStruct, a structure containing fields and values, that are the namevalue pair arguments accepted by nlmefitsa. The defaults for optionStruct are the same as the defaults for the namevalue pair arguments used by nlmefitsa, with the exceptions explained in Input Arguments.
[results, SimDataI, SimDataP] = sbionlmefitsa(...) returns simulation data of the SimBiology model, modelObj, using the estimated values of the parameters.
modelObject 
SimBiology model object used to fit observed data.  
pkModelMapObject 
PKModelMap object that defines the roles of the model components used for estimation. For details, see PKModelMap object.
 
pkDataObject 
PKData object that defines the data to use in fitting and the roles of the columns used for estimation. pkDataObject must define target data for at least two groups. For details, see PKData object.
 
InitEstimates 
Vector of initial estimates for the fixed effects. The first P elements of InitEstimates correspond to the fixed effects for each P element of pkModelMapObject.Estimated. Additional elements correspond to the fixed effects for covariate factors. The first P elements of InitEstimates are transformed as specified by the ParamTransform namevalue pair argument (log transformed by default). For details on specifying initial estimates, see Set Initial Estimates.  
CovModelObj 
CovariateModel object that defines the relationship between parameters and covariates. For details, see CovariateModel object.  
optionStruct 
Structure containing fields and values that are namevalue pair arguments accepted by the nlmefitsa function. The defaults for optionStruct are the same as the defaults for the arguments used by nlmefitsa, with the exceptions noted in NameValue Pair Arguments. If you have Parallel Computing Toolbox™, you can enable parallel computing for faster data fitting by setting the namevalue pair argument 'UseParallel' to true in the statset options structure as follows: parpool; % Open a parpool for parallel computing opt = statset(...,'UseParallel',true); % Enable parallel computing results = sbionlmefitsa(...,'Options',opt); % Perform data fitting

Specify optional commaseparated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.
The sbionlmefitsa function uses the namevalue pair arguments supported by the nlmefitsa function.
These nlmefitsa namevalue pair arguments are hardcoded in sbionlmefitsa, and therefore, you cannot set them:
FEParamsSelect
FEConstDesign
FEGroupDesign
FEObsDesign
REConstDesign
REGroupDesign
REObsDesign
Vectorization
If you provide a CovariateModel object as input to sbionlmefitsa, then these nlmefitsa namevalue pairs are computed from the covariate model, and therefore, you cannot set them:
FEGroupDesign
ParamTransform
REParamsSelect
You can set all other nlmefitsa namevalue pair arguments. For details on these arguments, see the nlmefitsa reference page.
Be aware that the defaults for these nlmefitsa namevalue pair arguments differ when used by sbionlmefitsa:
'FEGroupDesign' 
Numeric array specifying the design matrix for each group. For details, see Specify a Nonlinear, MixedEffects Model. Default: repmat(eye(P),[1 1 nGroups]), where P = the number of estimated parameters, and nGroups = the number of groups in the observed data.  
'ParamTransform' 
Vector of integers specifying how the parameters are distributed. For details, see Specify Parameter Transformations.
Default: Vector of ones, which specifies all parameters are log transformed.  
'OptimFun' 
String specifying the optimization function used in maximizing the likelihood. Default: fminunc, if you have Optimization Toolbox™ installed. Otherwise, the default is fminsearch.  
'Options' 
Structure containing multiple fields, including DerivStep, a scalar or vector specifying the relative difference used in the finite difference gradient calculation, and FunValCheck, a logical specifying whether to check for invalid values, such as NaN or Inf, from modelfun. Default: The default for DerivStep is the lesser of 1e4, or the value of the SolverOptions.RelativeTolerance property of the configuration set associated with modelObj, with a minimum of eps^(1/3). The default for FunValCheck is off. 
Tip SimBiology software includes the sbiofitstatusplot function, which you can specify in the OutputFcn field of the Options namevalue pair input argument. This function lets you monitor the status of fitting. 
results 
Structure containing these fields:

SimDataI 
SimData object containing data from simulating the model using the estimated parameter values for individuals. This object includes observed states and logged states. 
SimDataP 
SimData object containing data from simulating the model using the estimated parameter values for the population. This object includes observed states and logged states. 
Model object  nlmefitsa  PKData object  PKModelDesign object  PKModelMap object  sbiofitstatusplot  sbionlinfit  sbionlmefit  SimData object