Skip to contents

fitted() returns fitted response values from a drmTMB model. For univariate Gaussian, Student-t, Gamma, Tweedie, beta, beta-binomial, ordinary Poisson, ordinary negative-binomial, and cumulative-logit ordinal fits this is the fitted response summary. For Tweedie fits, that summary is the unconditional response mean mu. For beta-binomial fits, that summary is the fitted success probability mu. For ordinal fits, that summary is the expected ordered category score, sum_k k * Pr(y_i = k). For zero-truncated negative-binomial 2 fits this is the positive-count mean mu / (1 - Pr_NB2(0)), where mu is the untruncated NB2 component mean. For hurdle negative-binomial 2 fits this is the unconditional response mean (1 - hu) * mu / (1 - Pr_NB2(0)). For zero-inflated Poisson and zero-inflated negative-binomial 2 fits this is the unconditional response mean (1 - zi) * mu, where mu is the conditional count mean. For bivariate Gaussian fits this is a two-column matrix with mu1 and mu2. For lognormal fits this is the arithmetic response mean, exp(mu + sigma^2 / 2).

Usage

# S3 method for class 'drmTMB'
fitted(object, ...)

Arguments

object

A drmTMB fit.

...

Reserved for future fitted-value options.

Value

A numeric vector for univariate fits, or a two-column matrix for bivariate Gaussian fits.

Details

Fitted values are returned for the original fitted rows. Use predict() for new data or for non-location distributional parameters such as sigma or rho12.

Examples

dat <- data.frame(y = c(0.2, 0.5, 1.1, 1.4), x = c(-1, 0, 1, 2))
fit <- drmTMB(bf(y ~ x, sigma ~ 1), data = dat)
fitted(fit)
#> [1] 0.17 0.59 1.01 1.43