lqmm  R Documentation 
lqmm
is used to fit linear quantile mixed models based on the asymmetric Laplace distribution.
lqmm(fixed, random, group, covariance = "pdDiag", tau = 0.5, nK = 7, type = "normal", rule = 1, data = sys.frame(sys.parent()), subset, weights, na.action = na.fail, control = list(), contrasts = NULL, fit = TRUE)
fixed 
an object of class 
random 
a onesided formula of the form 
group 
grouping factor. 
covariance 
variance–covariance matrix of the random effects. Default is 
tau 
the quantile(s) to be estimated. 
nK 
number of quadrature knots. 
type 
type of quadrature "c("normal","robust")" (see details). 
rule 
quadrature rule (see details). 
data 
an optional data frame containing the variables named in

subset 
an optional vector specifying a subset of observations to be used in the fitting process. 
weights 
an optional vector of weights to be used in the fitting process of the same length as the number of rows of 
na.action 
a function that indicates what should happen when the
data contain 
control 
list of control parameters of the fitting process. See 
contrasts 
not yet implemented. 
fit 
logical flag. If FALSE the function returns a list of arguments to be passed to 
The function computes an estimate on the tauth quantile function of the response, conditional on the covariates, as specified by the formula
argument, and on random effects, as specified by the random
argument. The quantile predictor is assumed to be linear. The function maximizes the (log)likelihood of the Laplace regression proposed by Geraci and Bottai (2014). The likelihood is numerically integrated via Gaussian quadrature techniques. The optimization algorithm is based on the gradient of the Laplace log–likelihood (control = list(method = "gs")
). An alternative optimization algorithm is based on a NelderMead algorithm (control = list(method = "df")
) via optim
. The scale parameter is optimized in a refinement step via optimize
.
Quadrature approaches include GaussHermite (type = "normal"
) and GaussLaguerre (type = "robust"
) quadrature. The argument rule
takes one of the following: 1 (product rule quadrature), 2 (sparse grid quadrature), 3 (nested quadrature rule  only for type = "normal"
), 4 (quadrature rule with the smallest number of nodes between rules 1 or 2). Rules 2 and 3 have not yet been tested extensively.
Different standard types of positive–definite matrices for the random effects can be specified: pdIdent
multiple of an identity; pdCompSymm
compound symmetry structure (constant diagonal and constant off–diagonal elements); pdDiag
diagonal; pdSymm
general positive–definite matrix, with no additional structure.
Weights are given to clusters, therefore it is expected that these are constant within cluster. When the weights are specified in the main call, then the first value by group
in the vector weights
will be replicated for the same length of each group. Alternatively, different weights within the same cluster can be introduced with a direct call to lqmm.fit.gs or lqmm.fit.df
.
The lqmm
vignette can be accessed by typing help(package = "lqmm")
and then following the link 'User guides, package vignettes and other documentation'.
lqmm
returns an object of class
lqmm
.
The function summary
is used to obtain and print a summary of the results.
An object of class lqmm
is a list containing the following components:
theta 
a vector containing fixed regression coefficients and parameters of the variance–covariance matrix of the random effects. See 
theta_x,theta_z 
partition of 
scale 
the scale parameter. 
gradient 
the gradient ( 
logLik 
the log–likelihood. 
opt 
details on optimization (see 
call 
the matched call. 
nn 
column names of 
mm 
column names of 
nobs 
the number of observations. 
dim_theta 
the number of columns in 
dim_theta_z 
the length of 
edf 
length of 
rdf 
the number of residual degrees of freedom. 
df 
edf + 1 (scale parameter). 
tau 
the estimated quantile(s). 
mmf 
the model matrix – fixed effects. 
mmr 
the model matrix – random effects. 
y 
the model response. 
revOrder 
original order of observations (now ordered according to 
weights 
the likelihood weights used in the fitting process (a vector of 1's if 
group 
the grouping factor. 
ngroups 
the number of groups. 
QUAD 
quadrature nodes and weights. 
type 
the type of quadrature. 
rule 
quadrature rule. 
InitialPar 
starting values for theta. 
control 
list of control parameters used for optimization (see 
cov_name 
class of variancecovariance matrix for the random effects. 
mfArgs 
arguments for 
Updates/FAQ/news are published here https://marcogeraci.wordpress.com/. New versions are usually published here https://github.com/marcogeraci/lqmm/ before going on CRAN.
Marco Geraci
Genz A, and Keister BD (1996). Fully symmetric interpolatory rules for multiple integrals over infinite regions with Gaussian weight. Journal of Computational and Applied Mathematics, 71(2), 299–309. <doi:10.1016/03770427(95)002324>
Geraci M (2014). Linear quantile mixed models: The lqmm package for Laplace quantile regression. Journal of Statistical Software, 57(13), 1–29. <doi:10.18637/jss.v057.i13>
Geraci M and Bottai M (2007). Quantile regression for longitudinal data using the asymmetric Laplace distribution. Biostatistics 8(1), 140–154. <doi:10.1093/biostatistics/kxj039>
Geraci M and Bottai M (2014). Linear quantile mixed models. Statistics and Computing, 24(3), 461–479. <doi:10.1007/s1122201393819>.
Heiss F, and Winschel V (2008). Likelihood approximation by numerical integration on sparse grids. Journal of Econometrics, 144(1), 62–80. <doi:10.1016/j.jeconom.2007.12.004>
lqm, summary.lqmm, coef.lqmm, VarCorr.lqmm, predict.lqmm, residuals.lqmm
# Test example set.seed(123) M < 50 n < 10 test < data.frame(x = runif(n*M,0,1), group = rep(1:M,each=n)) test$y < 10*test$x + rep(rnorm(M, 0, 2), each = n) + rchisq(n*M, 3) fit.lqmm < lqmm(fixed = y ~ x, random = ~ 1, group = group, data = test, tau = 0.5, nK = 11, type = "normal") fit.lqmm #Call: lqmm(fixed = y ~ x, random = ~1, group = group, tau = 0.5, nK = 11, # type = "normal", data = test) #Quantile 0.5 #Fixed effects: #(Intercept) x # 3.443 9.258 #Covariance matrix of the random effects: #(Intercept) # 3.426 #Residual scale parameter: 0.8697 (standard deviation 2.46) #Loglikelihood: 1178 #Number of observations: 500 #Number of groups: 50 ## Orthodont data data(Orthodont) # Random intercept model fitOi.lqmm < lqmm(distance ~ age, random = ~ 1, group = Subject, tau = c(0.1,0.5,0.9), data = Orthodont) coef(fitOi.lqmm) # Random slope model fitOs.lqmm < lqmm(distance ~ age, random = ~ age, group = Subject, tau = c(0.1,0.5,0.9), cov = "pdDiag", data = Orthodont) # Extract estimates VarCorr(fitOs.lqmm) coef(fitOs.lqmm) ranef(fitOs.lqmm) # AIC AIC(fitOi.lqmm) AIC(fitOs.lqmm)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.