Learn R Programming

bayesics (version 2.0.2)

find_invgamma_parms: Find parameters for Inverse gamma prior based on prior mean and one quantile

Description

Find parameters for Inverse gamma prior based on prior mean and one quantile

Usage

find_invgamma_parms(
  lower_quantile,
  upper_quantile,
  response_variance,
  lower_R2,
  upper_R2,
  probability,
  plot_results = TRUE
)

Value

twice the shape and rate of the inverse gamma distribution.

Arguments

lower_quantile

lower quantile desired

upper_quantile

upper quantile desired

response_variance

variance of the response variable of the regression model

lower_R2, upper_R2

We are a priori probability sure that the coefficient of determination (\(R^2\)) falls within these lower and upper bounds.

probability

prior probability to be contained within the lower and upper quantiles

plot_results

logical. Should the resulting inverse gamma distribution be plotted?

Details

Either provide the lower and upper quantiles that contain probability of the inverse gamma distribution, or if this is for linear regression, you can specify that you are a priori probability sure that the coefficient of determination (\(R^2\)) falls within the two bounds provided, assuming that the residual variance is \(1-R^2\) times the total variance.

Examples

Run this code
# When aimed at linear regression via coefficient of determination...
hypothetical_s2_y = 2.0
lower_R2 = 0.05
upper_R2 = 0.85
find_invgamma_parms(response_variance = hypothetical_s2_y,
                    lower_R2 = lower_R2,
                    upper_R2 = upper_R2,
                    probability = 0.8)

# More arbitrary task...
find_invgamma_parms(0.3, # hypothetical_s2_y * (1.0 - upper_R2)
                    1.9, #hypothetical_s2_y * (1.0 - lower_R2)
                    probability = 0.8)




Run the code above in your browser using DataLab