Extract BAMLSS Coefficients

Share:

Description

Methods to extract coefficients of fitted bamlss objects, either coefficients returned from optimizer functions, or samples from a sampler functions.

Method confint.bamlss() produces credible intervals or parameter samples using quantiles.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## S3 method for class 'bamlss'
coef(object, model = NULL, term = NULL,
  FUN = NULL, parameters = NULL,
  pterms = TRUE, sterms = TRUE,
  hyper.parameters = TRUE, list = FALSE,
  full.names = TRUE, ...)

## S3 method for class 'bamlss'
confint(object, parm, level = 0.95,
  model = NULL, pterms = TRUE, sterms = FALSE,
  full.names = FALSE, hyper.parameters = FALSE, ...)

Arguments

object

An object of class "bamlss"

model

Character or integer. For which model should coefficients be extracted?

term

Character or integer. For which term should coefficients be extracted?

FUN

A function that is applied on the parameter samples.

parameters

If is set to TRUE, additionally adds estimated parameters returned from an optimizer function (if available).

pterms

Should coefficients of parametric terms be included?

sterms

Should coefficients of smooths terms be included?

hyper.parameters

For smooth terms, should hyper parameters such as smoothing variances be included?

list

Should the returned object have a list structure for each distribution parameter?

full.names

Should full names be assigned, indicating whether a term is parametric "p" or smooth "s".

parm

Character or integer. For which term should coefficients intervals be extracted?

level

The credible level which defines the lower and upper quantiles that should be computed from the samples.

...

Arguments to be passed to FUN and function samples.

Value

Depending on argument list and the number of distributional parameters, either a list or vector/matrix of model coefficients.

See Also

bamlss.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
## Not run: ## Simulate data.
d <- GAMart()

## Model formula.
f <- list(
  num ~ s(x1) + s(x2) + s(x3),
  sigma ~ s(x1) + s(x2) + s(x3)
)

## Estimate model.
b <- bamlss(f, data = d)

## Extract coefficients based on MCMC samples.
coef(b)

## Now only the mean.
coef(b, FUN = mean)

## As list without the full names.
coef(b, FUN = mean, list = TRUE, full.names = FALSE)

## Coefficients only for "mu".
coef(b, model = "mu")

## And "s(x2)".
coef(b, model = "mu", term = "s(x2)")

## With optimizer parameters.
coef(b, model = "mu", term = "s(x2)", parameters = TRUE)

## Only parameteric part.
coef(b, sterms = FALSE, hyper.parameters = FALSE)

## For sigma.
coef(b, model = "sigma", sterms = FALSE,
  hyper.parameters = FALSE)

## 95 perc. credible interval based on samples.
confint(b)

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.