Movatterモバイル変換


[0]ホーム

URL:


Title:Gaussian Location-Scale Regression
Version:0.1.1
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.
License:MIT + file LICENSE
URL:https://hriebl.github.io/lmls/,https://github.com/hriebl/lmls
BugReports:https://github.com/hriebl/lmls/issues
Depends:R (≥ 3.5.0)
Imports:generics (≥ 0.1.0)
Suggests:bookdown, coda, covr, ggplot2, knitr, mgcv, mvtnorm,numDeriv, patchwork, rmarkdown, testthat (≥ 3.0.0)
Encoding:UTF-8
LazyData:true
RoxygenNote:7.3.2
VignetteBuilder:knitr
Config/testthat/edition:3
NeedsCompilation:no
Packaged:2024-11-20 18:46:55 UTC; hannes
Author:Hannes Riebl [aut, cre]
Maintainer:Hannes Riebl <hriebl@posteo.de>
Repository:CRAN
Date/Publication:2024-11-20 22:20:02 UTC

Abdominal circumference data

Description

Theabdom data frame has 610 rows and 2 columns. The data aremeasurements of abdominal circumference (response variable) taken fromfetuses during ultrasound scans at Kings College Hospital, London, atgestational ages (explanatory variable) ranging between 12 and 42 weeks.

Usage

data(abdom)

Format

This data frame contains the following columns:

y

Abdominal circumference: a numeric vector.

x

Gestational age: a numeric vector.

Details

The data were used to derive reference intervals by Chittyet al.(1994) and also for comparing different reference centile methods byWright and Royston (1997), who also commented that the distribution ofz-scores obtained from the different fitted models "has somewhat longertails than the normal distribution".

Source

Dr. Eileen M. Wright, Department of Medical Statistics and Evaluation,Royal Postgraduate Medical School, Du Cane Road, London, W12 0NN.

Theabdom dataset was copied into thelmls package from thegamlss.data package.gamlss.data is licensed under the GPL 2 and 3.

References

Chitty, L.S., Altman, D.G., Henderson, A. and Campbell, S. (1994). Chartsof fetal size: 3, abdominal measurement.Br. J. Obstet. Gynaec.,101: 125–131.

Wright, E.M. and Royston, P. (1997). A comparison of statisticalmethods for age-related reference intervals.J. R. Statist. Soc. A.,160: 47–69.

Examples

data(abdom)attach(abdom)plot(x, y)detach(abdom)

Parametric bootstrap for LMLS

Description

A simple parametric bootstrap algorithm for location-scale regression modelsfrom thelmls() function.

Usage

boot(m, num_samples = 1000, seed = NULL)

Arguments

m

A location-scale regression model from thelmls() function.

num_samples

The number of bootstrap samples to draw.

seed

EitherNULL or an integer that will be used in a call toset.seed() before simulating the response vectors.

Value

Anlmls S3 object, seelmls(). The entryboot with the matrices ofbootstrap samples is added to the object as a list with the nameslocationandscale.

Examples

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])

Gaussian location-scale regression

Description

The location-scale regression model assumes a normally distributed responsevariable with one linear predictor for the mean (= the location) and one forthe standard deviation (= the scale). The standard deviation is mapped tothe linear predictor through a log link.

This function sets up the model object and estimates it with maximumlikelihood.

Usage

lmls(  location,  scale = ~1,  data = environment(location),  light = TRUE,  maxit = 100,  reltol = sqrt(.Machine$double.eps))

Arguments

location

A two-sided formula with the response variable on the LHSand the predictor for the mean on the RHS.

scale

A one-sided formula with the predictor for the standarddeviation on the RHS.

data

A data frame (or list or environment) in which to evaluatethelocation andscale formulas.

light

IfTRUE, the design matrices are removed from the estimatedmodel to save some memory.

maxit

The maximum number of iterations of the Fisher scoringalgorithm.

reltol

The relative convergence tolerance of the Fisher scoringalgorithm.

Value

A fitted linear model for location and scale as anlmls S3 object.The object has at least the following entries:

Examples

library(lmls)m <- lmls(y ~ poly(x, 2), ~ x, data = abdom)summary(m)plot(m)qqnorm(m)

Methods for LMLS

Description

A couple of methods for location-scale regression models from thelmls()function are provided.

Usage

## 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"), ...)

Arguments

object

A location-scale regression model from thelmls() function.

predictor

The predictor to work on. Either"location" or"scale"or both. If both, a list with the names"location" and"scale" is returned.

...

Currently ignored.

newdata

A data frame (or list or environment) with the covariatevalues at which the predictions are computed. IfNULL, thepredictions at the original data are returned.

type

Used bypredict() andresiduals():

  • Forpredict(),"link" or"response". If"link"(default),\mu and log(\sigma) are returned.If"response",\mu and\sigmaare returned.

  • Forresiduals(),"deviance","pearson" or"response". If"deviance" (default) or"pearson",(y - \mu) /\sigma is returned.If"response",y - \mu is returned.

Value

A numeric vector forresiduals(). For the other methods, a numeric vectorif the argumentpredictor is either"location" or"scale", or a listwith the nameslocation andscale if it is both.


MCMC inference for LMLS

Description

A Markov chain Monte Carlo (MCMC) sampler for location-scale regressionmodels from thelmls() function. The sampler uses Gibbs updates for thelocation coefficients and the Riemann manifold Metropolis-adjusted Langevinalgorithm (MMALA) from Girolami and Calderhead (2011) with the Fisher-Raometric tensor for the scale coefficients. The priors for the regressioncoefficients are assumed to be flat.

To find the optimal step size for the MMALA updates, the dual averagingalgorithm from Nesterov (2009) is used during a warm-up phase.

Usage

mcmc(m, num_samples = 1000, num_warmup = 1000, target_accept = 0.8)

Arguments

m

A location-scale regression model from thelmls() function.

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 averagingalgorithm used for the warm-up. Defaults to 0.8.

Value

Anlmls S3 object, seelmls(). The entrymcmc with the matricesof MCMC samples is added to the object as a list with the nameslocationandscale.

References

Girolami, M. and Calderhead, B. (2011), Riemann manifold Langevin andHamiltonian 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

Examples

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")

Objects exported from other packages

Description

These objects are imported from other packages. Follow the linksbelow to see their documentation.

generics

glance,tidy


Summary for LMLS

Description

Prints a summary for location-scale regression models from thelmls()function.

Usage

## S3 method for class 'lmls'summary(  object,  type = c("ml", "boot", "mcmc"),  digits = max(3, getOption("digits") - 3),  ...)

Arguments

object

A location-scale regression model from thelmls() function.

type

Either"ml" or"boot" or"mcmc":

  • If"ml", the maximum likelihood estimates and theasymptotic standard errors are shown.

  • If"boot", the bootstrap estimates and confidenceintervals are shown.

  • If"mcmc", the Markov chain Monte Carlo (MCMC)estimates and credible intervals are shown.

digits

The number of digits to print.

...

Passed on toprintCoefmat().

Value

The (unmodified and invisible)lmls S3 object, seelmls().


[8]ページ先頭

©2009-2025 Movatter.jp