Function to compute fitted values for bamlss models. The function calls predict.bamlss to compute fitted values from samples.

# S3 method for bamlss
fitted(object, model = NULL, term = NULL,
  type = c("link", "parameter"), samples = TRUE,
  FUN = c95, nsamps = NULL, ...)



An object of class "bamlss"


Character or integer, specifies the model for which fitted values should be computed.


Character or integer, specifies the model terms for which fitted values are required. Note that if samples = TRUE, e.g., term = c("s(x1)", "x2") will compute the combined fitted values s(x1) + x2.


If type = "link" the predictor of the corresponding model is returned. If type = "parameter" fitted values on the distributional parameter scale are returned.


Should fitted values be computed using samples of parameters or estimated parameters as returned from optimizer functions (e.g., function bfit returns "fitted.values"). The former results in a call to predict.bamlss, the latter simply extracts the "fitted.values" of the bamlss object and is not model term specific.


A function that should be applied on the samples of predictors or parameters, depending on argument type.


If the fitted bamlss object contains samples of parameters, computing fitted values may take quite some time. Therefore, to get a first feeling it can be useful to compute fitted values only based on nsamps samples, i.e., nsamps specifies the number of samples which are extracted on equidistant intervals.


Arguments passed to function predict.bamlss.


Depending on arguments model, FUN and the structure of the bamlss

model, a list of fitted values or simple vectors or matrices of fitted values.

See also


if (FALSE) ## Generate some data.
d <- GAMart()

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

## Estimate model.
b <- bamlss(f, data = d)
#> Error in bamlss.model.frame(formula, data, family, weights, subset, offset,     na.action, specials, contrasts): object 'd' not found

## Fitted values returned from optimizer.
f1 <- fitted(b, model = "mu", samples = FALSE)
#> Error in fitted(b, model = "mu", samples = FALSE): object 'b' not found

## Fitted values returned from sampler.
f2 <- fitted(b, model = "mu", samples = TRUE, FUN = mean)
#> Error in fitted(b, model = "mu", samples = TRUE, FUN = mean): object 'b' not found

plot(f1, f2)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'f1' not found