| categorical_accessors | R Documentation |
stats::fitted(), stats::residuals(), stats::predict() and posterior_predict() for a
categorical response: a tulpa_multinomial() fit (family = "multinomial")
or a tulpa_ordinal() fit (family = "ordinal"). The response is one of K
classes, so the response-scale quantities are N x K matrices with one column
per class.
fitted() returns the class probabilities at the posterior mode.
residuals() returns, per class, the indicator of the observed class minus
its fitted probability ("response"), or that difference divided by the
indicator's standard deviation sqrt(p (1 - p)) ("pearson"). A
categorical response has no single scalar residual; each class column is
the Bernoulli residual of that class's indicator.
predict() returns the link scale – the K - 1 baseline-category logits of
the multinomial model (N x (K - 1)), or the ordinal location predictor
x' beta (length N) – or the class probabilities (type = "response").
posterior_predict() draws one class per observation for each posterior
draw and returns the class indices, with the response levels attached;
simulate.tulpa_fit() turns them into factor columns.
The pointwise log-likelihood behind cpo(), dic(), loo::waic() and
loo::loo() is the log probability of each observed class at each stored
posterior draw; dic() evaluates it at the posterior-mean parameters.
## S3 method for class 'tulpa_categorical'
fitted(object, ...)
## S3 method for class 'tulpa_categorical'
residuals(object, type = c("pearson", "response"), ...)
## S3 method for class 'tulpa_categorical'
predict(
object,
newdata = NULL,
type = c("link", "response"),
se.fit = FALSE,
level = 0.95,
...
)
## S3 method for class 'tulpa_categorical'
posterior_predict(object, newdata = NULL, ndraws = NULL, seed = NULL, ...)
## S3 method for class 'tulpa_categorical'
pp_check(object, ndraws = 50, ...)
object |
A |
... |
Ignored. |
type |
For |
newdata |
Optional data frame of covariates; |
se.fit |
For |
level |
Credible-interval level (default 0.95). |
ndraws |
Number of posterior draws for |
seed |
Optional integer seed (RNG state is restored on exit). |
fitted(): an N x K probability matrix. residuals(): an N x K
matrix. predict(): a matrix (or, for the ordinal link scale, a vector);
with se.fit = TRUE a list of fit, se.fit, lower, upper of that
shape. posterior_predict(): an ndraws x N integer matrix of class
indices with attributes levels and ordered.
tulpa_multinomial(), tulpa_ordinal()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.