Title: | Gaussian Location-Scale Regression |
---|---|
Description: | The Gaussian location-scale regression model is a multi-predictor model with explanatory variables for the mean (= location) and the standard deviation (= scale) of a response variable. This package implements maximum likelihood and Markov chain Monte Carlo (MCMC) inference (using algorithms from Girolami and Calderhead (2011) <doi:10.1111/j.1467-9868.2010.00765.x> and Nesterov (2009) <doi:10.1007/s10107-007-0149-x>), a parametric bootstrap algorithm, and diagnostic plots for the model class. |
Authors: | Hannes Riebl [aut, cre] |
Maintainer: | Hannes Riebl <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1 |
Built: | 2024-11-25 15:21:13 UTC |
Source: | CRAN |
The abdom
data frame has 610 rows and 2 columns. The data are
measurements of abdominal circumference (response variable) taken from
fetuses during ultrasound scans at Kings College Hospital, London, at
gestational ages (explanatory variable) ranging between 12 and 42 weeks.
data(abdom)
data(abdom)
This data frame contains the following columns:
Abdominal circumference: a numeric vector.
Gestational age: a numeric vector.
The data were used to derive reference intervals by Chitty et al. (1994) and also for comparing different reference centile methods by Wright and Royston (1997), who also commented that the distribution of z-scores obtained from the different fitted models "has somewhat longer tails than the normal distribution".
Dr. Eileen M. Wright, Department of Medical Statistics and Evaluation, Royal Postgraduate Medical School, Du Cane Road, London, W12 0NN.
The abdom
dataset was copied into the lmls
package from the
gamlss.data
package. gamlss.data
is licensed under the GPL 2 and 3.
Chitty, L.S., Altman, D.G., Henderson, A. and Campbell, S. (1994). Charts of fetal size: 3, abdominal measurement. Br. J. Obstet. Gynaec., 101: 125–131.
Wright, E.M. and Royston, P. (1997). A comparison of statistical methods for age-related reference intervals. J. R. Statist. Soc. A., 160: 47–69.
data(abdom) attach(abdom) plot(x, y) detach(abdom)
data(abdom) attach(abdom) plot(x, y) detach(abdom)
A simple parametric bootstrap algorithm for location-scale regression models
from the lmls()
function.
boot(m, num_samples = 1000, seed = NULL)
boot(m, num_samples = 1000, seed = NULL)
m |
A location-scale regression model from the |
num_samples |
The number of bootstrap samples to draw. |
seed |
Either |
An lmls
S3 object, see lmls()
. The entry boot
with the matrices of
bootstrap samples is added to the object as a list with the names location
and scale
.
library(lmls) m <- lmls(y ~ poly(x, 2), ~ x, data = abdom, light = FALSE) m <- boot(m) summary(m, type = "boot") hist(m$boot$scale[, 2])
library(lmls) m <- lmls(y ~ poly(x, 2), ~ x, data = abdom, light = FALSE) m <- boot(m) summary(m, type = "boot") hist(m$boot$scale[, 2])
The location-scale regression model assumes a normally distributed response variable with one linear predictor for the mean (= the location) and one for the standard deviation (= the scale). The standard deviation is mapped to the linear predictor through a log link.
This function sets up the model object and estimates it with maximum likelihood.
lmls( location, scale = ~1, data = environment(location), light = TRUE, maxit = 100, reltol = sqrt(.Machine$double.eps) )
lmls( location, scale = ~1, data = environment(location), light = TRUE, maxit = 100, reltol = sqrt(.Machine$double.eps) )
location |
A two-sided formula with the response variable on the LHS and the predictor for the mean on the RHS. |
scale |
A one-sided formula with the predictor for the standard deviation on the RHS. |
data |
A data frame (or list or environment) in which to evaluate
the |
light |
If |
maxit |
The maximum number of iterations of the Fisher scoring algorithm. |
reltol |
The relative convergence tolerance of the Fisher scoring algorithm. |
A fitted linear model for location and scale as an lmls
S3 object.
The object has at least the following entries:
y
: the response vector
nobs
: the number of observations
df
: the degrees of freedom
df.residual
: the residual degrees of freedom
coefficients
: the regression coefficients as a list with the names
location
and scale
fitted.values
: the fitted values as a list with the names location
and scale
residuals
: the response residuals
coefficients
: the variance-covariance matrices of the regression
coefficients as a list with the names location
and scale
iterations
: the number of iterations the Fisher scoring algorithm
took to converge
library(lmls) m <- lmls(y ~ poly(x, 2), ~ x, data = abdom) summary(m) plot(m) qqnorm(m)
library(lmls) m <- lmls(y ~ poly(x, 2), ~ x, data = abdom) summary(m) plot(m) qqnorm(m)
A couple of methods for location-scale regression models from the lmls()
function are provided.
## S3 method for class 'lmls' coef(object, predictor = c("location", "scale"), ...) ## S3 method for class 'lmls' fitted(object, predictor = c("location", "scale"), ...) ## S3 method for class 'lmls' predict( object, newdata = NULL, predictor = c("location", "scale"), type = c("link", "response"), ... ) ## S3 method for class 'lmls' residuals(object, type = c("deviance", "pearson", "response"), ...) ## S3 method for class 'lmls' vcov(object, predictor = c("location", "scale"), ...)
## S3 method for class 'lmls' coef(object, predictor = c("location", "scale"), ...) ## S3 method for class 'lmls' fitted(object, predictor = c("location", "scale"), ...) ## S3 method for class 'lmls' predict( object, newdata = NULL, predictor = c("location", "scale"), type = c("link", "response"), ... ) ## S3 method for class 'lmls' residuals(object, type = c("deviance", "pearson", "response"), ...) ## S3 method for class 'lmls' vcov(object, predictor = c("location", "scale"), ...)
object |
A location-scale regression model from the |
predictor |
The predictor to work on. Either |
... |
Currently ignored. |
newdata |
A data frame (or list or environment) with the covariate
values at which the predictions are computed. If |
type |
Used by
|
A numeric vector for residuals()
. For the other methods, a numeric vector
if the argument predictor
is either "location"
or "scale"
, or a list
with the names location
and scale
if it is both.
A Markov chain Monte Carlo (MCMC) sampler for location-scale regression
models from the lmls()
function. The sampler uses Gibbs updates for the
location coefficients and the Riemann manifold Metropolis-adjusted Langevin
algorithm (MMALA) from Girolami and Calderhead (2011) with the Fisher-Rao
metric tensor for the scale coefficients. The priors for the regression
coefficients are assumed to be flat.
To find the optimal step size for the MMALA updates, the dual averaging algorithm from Nesterov (2009) is used during a warm-up phase.
mcmc(m, num_samples = 1000, num_warmup = 1000, target_accept = 0.8)
mcmc(m, num_samples = 1000, num_warmup = 1000, target_accept = 0.8)
m |
A location-scale regression model from the |
num_samples |
The number of MCMC samples after the warm-up. Defaults to 1000. |
num_warmup |
The number of MCMC samples for the warm-up. Defaults to 1000. |
target_accept |
The target acceptance rate for the dual averaging algorithm used for the warm-up. Defaults to 0.8. |
An lmls
S3 object, see lmls()
. The entry mcmc
with the matrices
of MCMC samples is added to the object as a list with the names location
and scale
.
Girolami, M. and Calderhead, B. (2011), Riemann manifold Langevin and Hamiltonian Monte Carlo methods. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 73: 123-214. doi:10.1111/j.1467-9868.2010.00765.x
Nesterov, Y. (2009), Primal-dual subgradient methods for convex problems. Mathematical Programming, 120: 221–259. doi:10.1007/s10107-007-0149-x
library(lmls) m <- lmls(y ~ poly(x, 2), ~ x, data = abdom, light = FALSE) m <- mcmc(m) summary(m, type = "mcmc") plot(m$mcmc$scale[, 2], type = "l")
library(lmls) m <- lmls(y ~ poly(x, 2), ~ x, data = abdom, light = FALSE) m <- mcmc(m) summary(m, type = "mcmc") plot(m$mcmc$scale[, 2], type = "l")
Prints a summary for location-scale regression models from the lmls()
function.
## S3 method for class 'lmls' summary( object, type = c("ml", "boot", "mcmc"), digits = max(3, getOption("digits") - 3), ... )
## S3 method for class 'lmls' summary( object, type = c("ml", "boot", "mcmc"), digits = max(3, getOption("digits") - 3), ... )
object |
A location-scale regression model from the |
type |
Either
|
digits |
The number of digits to print. |
... |
Passed on to |
The (unmodified and invisible) lmls
S3 object, see lmls()
.