Draw matrices of predictive and simulated quantities
Source:R/draws_matrix.R
as.matrix.ratiod_priorpred.RdPrior 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_ppredorratiod_prediction_drawsobject.- component
Which quantity:
"ratio","numerator"or"denominator". Posterior predictive replicates carry the numerator and the denominator only; predictive draws at new data carry the componentspredict()was asked for. The default is the first available.- ...
Ignored.
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