Skip to contents

Prior predictive draws (prior_predict()), posterior predictive replicates (posterior_predict()) and predictive draws at new data (predict(fit, summary = FALSE)) each hold one draws-by-observation matrix per component. as.matrix() returns the one named by component.

Usage

# S3 method for class 'ratiod_priorpred'
as.matrix(x, component = NULL, ...)

# S3 method for class 'ratiod_ppred'
as.matrix(x, component = NULL, ...)

# S3 method for class 'ratiod_prediction_draws'
as.matrix(x, component = NULL, ...)

# S3 method for class 'ratiod_ppred'
print(x, ...)

# S3 method for class 'ratiod_prediction_draws'
print(x, ...)

Arguments

x

A ratiod_priorpred, ratiod_ppred or ratiod_prediction_draws object.

component

Which quantity: "ratio", "numerator" or "denominator". Posterior predictive replicates carry the numerator and the denominator only; predictive draws at new data carry the components predict() was asked for. The default is the first available.

...

Ignored.

Value

A numeric matrix, one row per draw and one column per observation.

Examples

set.seed(1)
df <- data.frame(count = 0L, total = 0L, x = rnorm(20))
pp <- prior_predict(count | total ~ x, family = ratiod_negbin_negbin(),
                    data = df, n = 30)
dim(as.matrix(pp))
#> [1] 30 20
range(as.matrix(pp, component = "denominator"))
#> [1] 0.000000e+00 2.164139e+22