r2_mc {R2D2ordinal} | R Documentation |
Posterior distribution of McFadden's R2
Description
This function finds the posterior distribution of McFadden's R2 given the posterior samples from a Stan model fit
Usage
r2_mc(Y, out)
Arguments
Y |
ordinal response |
out |
posterior samples from R2D2 model fit in Stan |
Value
Posterior samples from McFadden's R2
Examples
# Obtain output from ord_r2d2() model fit
set.seed(1234)
# X are covariates, Y are responses, K is number of response categories
# This example will yield low R2 values as the response are independent of the covariates.
n = 100
p = 5
X = matrix(rnorm(n*p), nrow = n, ncol=p)
K = 3
Y = sample(1:K, 100, replace=TRUE)
a = 1
b = 5
# Pre-computed hyperparameters
fit <- ord_r2d2(X, Y, K, hyper=c(0.002, 0.989, 1.013), no_cores=1)
out <- rstan::extract(fit)
# Plot histogram of posterior R2
hist(r2_mc(Y, out), xlab="R2")
[Package R2D2ordinal version 1.0.1 Index]