Learn R Programming

lqmm (version 1.04)

lqmm: Fitting Linear Quantile Mixed Models

Description

lqmm is used to fit linear quantile mixed models based on the asymmetric Laplace distribution.

Usage

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)

Arguments

fixed
an object of class formula for fixed effects: a symbolic description of the model to be fitted.
random
a one-sided formula of the form ~x1 + x2 + ... + xn for random effects: a symbolic description of the model to be fitted.
group
grouping factor.
covariance
variance--covariance matrix of the random effects. Default is pdDiag (see details).
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 fixed, random and group. By default the variables are taken from the environment from which lqmm is called.
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 data. Weights are given to clusters, therefore units within the same cluster receive the same weight (see details).
na.action
a function that indicates what should happen when the data contain NAs. The default action (na.fail) causes lqmm to print an error message and terminate if there are any incomplete observations.
control
list of control parameters of the fitting process. See lqmmControl.
contrasts
not yet implemented.
fit
logical flag. If FALSE the function returns a list of arguments to be passed to lqmm.fit.

Value

  • 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:
  • thetaa vector containing fixed regression coefficients and parameters of the variance--covariance matrix of the random effects. See cov.lqmm to extract the variance--covariance of the random effects from an "lqmm" object.
  • theta_x,theta_zpartition of theta: fixed regression coefficients (theta_x) and unique variance--covariance parameters (theta_z).
  • scalethe scale parameter.
  • gradientthe gradient (control = list(method = "gs")).
  • logLikthe log--likelihood.
  • optdetails on optimization (see lqmm.fit.gs and lqmm.fit.df).
  • callthe matched call.
  • nncolumn names of mmf.
  • mmcolumn names of mmr.
  • nobsthe number of observations.
  • dim_thetathe number of columns in mmf and mmr.
  • dim_theta_zthe length of theta_z.
  • edflength of theta.
  • rdfthe number of residual degrees of freedom.
  • dfedf + 1 (scale parameter).
  • tauthe estimated quantile(s).
  • mmfthe model matrix -- fixed effects.
  • mmrthe model matrix -- random effects.
  • ythe model response.
  • revOrderoriginal order of observations (now ordered according to group).
  • weightsthe likelihood weights used in the fitting process (a vector of 1's if weights is missing or NULL).
  • groupthe grouping factor.
  • ngroupsthe number of groups.
  • QUADquadrature nodes and weights.
  • typethe type of quadrature.
  • rulequadrature rule.
  • InitialParstarting values for theta.
  • controllist of control parameters used for optimization (see lqmmControl).
  • cov_nameclass of variance-covariance matrix for the random effects.
  • mfArgsarguments for model.frame to return the full data frame.

Details

The function computes an estimate on the tau-th 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 (2013). 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 Nelder-Mead algorithm (control = list(method = "df")) via optim. The scale parameter is optimized in a refinement step via optimize. Quadrature approaches include Gauss-Hermite (type = "normal") and Gauss-Laguerre (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 manual can be accessed by typing browseVignettes(package = "lqmm") and then following the PDF link.

References

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. Geraci M and Bottai M (2007). Quantile regression for longitudinal data using the asymmetric Laplace distribution. Biostatistics 8(1), 140--154. Geraci M and Bottai M (2013). Linear quantile mixed models. Statistics and Computing, doi: 10.1007/s11222-013-9381-9. Heiss F, and Winschel V (2008). Likelihood approximation by numerical integration on sparse grids. Journal of Econometrics, 144(1), 62--80.

See Also

lqm, summary.lqmm, coef.lqmm, cov.lqmm, predict.lqmm, residuals.lqmm

Examples

Run this code
# 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)
#Log-likelihood: -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
cov.lqmm(fitOs.lqmm)
coef(fitOs.lqmm)
raneff.lqmm(fitOs.lqmm)

# AIC
AIC(fitOi.lqmm)
AIC(fitOs.lqmm)

Run the code above in your browser using DataLab