Performs a quantile regression for a NLMEM using the Stochastic-Approximation of the EM Algorithm (SAEM) for an unique or a set of quantiles.
QRNLMM(y,x,groups,initial,exprNL,covar=NA,p=0.5,precision=0.0001,MaxIter=500,
M=20,cp=0.25,beta=NA,sigma=NA,Psi=NA,show.convergence=TRUE,CI=95,verbose=TRUE)
The function returns a list with two objects
A two elements list with the matrices teta
and se
containing the point estimates and standard error estimate for all parameters along all iterations.
The second element of the list is res
, a list of 13 elements detailed as
quantile(s) fitted.
number of iterations.
attained criteria value.
the proposed nonlinear function.
fixed effects estimates.
random effects weights (\(b_i\)).
scale parameter estimate for the error term.
Random effects variance-covariance estimate matrix.
Standard Error estimates.
Table containing the inference for the fixed effects parameters.
Log-likelihood value.
Akaike information criterion.
Bayesian information criterion.
Hannan-Quinn information criterion.
vector containing the fitted values
vector containing the residuals.
processing time.
the response vector of dimension \(N\) where \(N\) is the total of observations.
vector of longitudinal (repeated measures) covariate of dimension \(N\). For example: Time, location, etc.
factor of dimension \(N\) specifying the partitions of the data over which the random effects vary.
an numeric vector, or list of initial estimates
for the fixed effects. It must be provide adequately (see details
section) in order to ensure a proper convergence.
expression containing the proposed nonlinear function. It can be of class character
or expression
. It must have a defined structure defined in the details
section in order to be correctly read by the derivate R function deriv
.
a matrix of dimension \(N \times r\) where \(r\) represents the number of covariates.
unique quantile or a set of quantiles related to the quantile regression.
the convergence maximum error.
the maximum number of iterations of the SAEM algorithm. Default = 500.
Number of Monte Carlo simulations used by the SAEM Algorithm. Default = 20. For more accuracy we suggest to use M=20
.
cut point \((0 \le cp \le 1)\) which determines the percentage of initial iterations with no memory.
fixed effects vector of initial parameters, if desired.
dispersion initial parameter for the error term, if desired.
Variance-covariance random effects matrix of initial parameters, if desired.
if TRUE
, it will show a graphical summary for the convergence of the estimates of all parameters for each quantile in order to assess the convergence.
Confidence to be used for the Confidence Interval when a grid of quantiles is provided. Default=95.
if TRUE
, an output summary is printed.
Christian E. Galarza <chedgala@espol.edu.ec> and Victor H. Lachos <hlachos@uconn.edu>
This algorithm performs the SAEM algorithm proposed by Delyon et al. (1999), a stochastic version of the usual EM Algorithm deriving exact maximum likelihood estimates of the fixed-effects and variance components. Covariates are allowed, the longitudinal (repeated measures) coded x
and a set of covariates covar
.
\(About initial values:\) Estimation for fixed effects parameters envolves a Newton-Raphson step. In adition, NL models are highly sensitive to initial values. So, we suggest to set of intial values quite good, this based in the parameter interpretation of the proposed NL function.
\(About the nonlinear expression:\) For the NL expression exprNL
just the variables x
, covar
, fixed
and random
can be defined. Both x
and covar
represent the covariates defined above. The fixed effects must be declared as fixed[1]
, fixed[2]
,..., fixed[d]
representing the first, second and \(d\)th fixed effect. Exactly the same for the random effects and covariates where the term fixed
should be replace for random
and covar
respectively.
For instance, if we use the exponential nonlinear function with two parameters, each parameter represented by a fixed and a random effect, this will be defined by
$$y_{ij} = (\beta_1 + b_1)\exp^{-(\beta_2 + b_2)x_{ij}}$$
and the exprNL
should be a character or and expression defined by
exprNL = "(fixed[1]+random[1])*exp(-(fixed[2]+random[2])*x)"
or
exprNL = expression((fixed[1]+random[1])*exp(-(fixed[2]+random[2])*x))
.
If we are interested in adding two covariates in order to explain on of the parameters, the covariates covar[1]
and covar[2]
must be included in the model. For example, for the nonlinear function
$$y_{ij} = (\beta_1 + \beta_3*covar1_{ij} + b_1)\exp^{-(\beta_2 + \beta_4* covar2_{ij} + b_2)x_{ij}}$$
the exprNL
should be
exprNL = "(fixed[1]+fixed[3]*covar[1]+random[1])*exp(-(fixed[2]+fixed[4]*covar[2]+random[2])*x)"
or
exprNL = expression((fixed[1]+fixed[3]*covar[1]+random[1])*exp(-(fixed[2]+
fixed[4]*covar[2]+random[2])*x))
.
Note that the mathematical function exp
was used. For derivating the deriv
R function recognizes in the exprNL
expression the arithmetic operators +, -, *, / and ^, and the single-variable functions exp
, log
, sin
, cos
, tan
, sinh
, cosh
, sqrt
, pnorm
, dnorm
, asin
, acos
, atan
, gamma
, lgamma
, digamma
and trigamma
, as well as psigamma
for one or two arguments (but derivative only with respect to the first).
\(General details:\) When a grid of quantiles is provided, a graphical summary with point estimates and Confidence Intervals for model parameters is shown and also a graphical summary for the convergence of these estimates (for each quantile), if show.convergence=TRUE
.
If the convergence graphical summary shows that convergence has not be attained, it's suggested to increase the total number of iterations MaxIter
.
About the cut point parameter cp
, a number between 0 and 1 \((0 \le cp \le 1)\) will assure an initial convergence in distribution to a solution neighborhood for the first cp
*MaxIter
iterations and an almost sure convergence for the rest of the iterations. If you do not know how SAEM algorithm works, these parameters SHOULD NOT be changed.
This program uses progress bars that will close when the algorithm ends. They must not be closed before, if not, the algorithm will stop.
Galarza, C.E., Castro, L.M., Louzada, F. & Lachos, V. (2020) Quantile regression for nonlinear mixed effects models: a likelihood based perspective. Stat Papers 61, 1281-1307. tools:::Rd_expr_doi("10.1007/s00362-018-0988-y")
Delyon, B., Lavielle, M. & Moulines, E. (1999). Convergence of a stochastic approximation version of the EM algorithm. Annals of Statistics, pages 94-128.
Soybean
, HIV
, lqr
, group.plots