point_est: Calculate point estimates and credible intervals for...

Description Usage Arguments Value Details Examples

View source: R/post_estimation.R

Description

point_est is used to calculate point estimates and credible intervals for the parameters of interest to the user.

Usage

1
point_est(posterior, pars = NULL, prob = 0.9)

Arguments

posterior

object of class rstan::stanfit as fit by the mediascores function

pars

character vector, a vector of model parameter names e.g. c("theta", "zeta[1]", "alpha"). See Details below.

prob

numeric, a number between 0 and 1 indicating the probability mass to include in the credible interval. Defaults to 0.9.

Value

Returns a three-columm matrix containing the median of the posterior of each parameter of interest and the lower and upper quantile to form a credible interval around the median.

Details

point_est is a helper function for users to quickly caluclate the median of the posterior for parameters of interest, and credible intervals for those parameters with quantiles defined by the user. These estimates can be calculated for the following parameters inputted (alone or in combination) by the user: "theta", "theta_mu", "theta_sigma", "zeta", "alpha", "alpha_mu", "alpha_sigma", "gamma", "gamma_sigma", "omega_domain", "omega_user". Indexed variants of these parameter names can also be retrieved (e.g. c("theta[4]", "zeta[1]").

Examples

1
2
3
4
5
6
7
8
## Not run: 
simulated_data <- simulate_data(5, 20)
posterior <- mediascores(Y = simulated_data$Y, group = simulated_data$group,
                         anchors = simulated_data$anchors,
                         variational = FALSE, chains = 1, iter = 500)
point_est(posterior, pars = c("theta", "theta_mu"), prob = 0.90)

## End(Not run)

SMAPPNYU/mediascores documentation built on May 18, 2019, 1:30 p.m.