glm_standard: GLM equipped with the 'standard' prior evaluated

Description Usage Arguments Value Examples

View source: R/glm_standard.R

Description

Program for fitting a GLM equipped with the 'standard' prior evaluated in Boonstra and Barbaro, which is the regularized horseshoe.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
glm_standard(
  stan_fit = stanmodels$RegHS_Stable,
  y,
  x_standardized,
  p,
  q,
  beta_orig_scale,
  beta_aug_scale,
  local_dof = 1,
  global_dof = 1,
  slab_precision = (1/15)^2,
  intercept_offset = NULL,
  only_prior = F,
  mc_warmup = 50,
  mc_iter_after_warmup = 50,
  mc_chains = 1,
  mc_thin = 1,
  mc_stepsize = 0.1,
  mc_adapt_delta = 0.9,
  mc_max_treedepth = 15,
  ntries = 1,
  return_as_stanfit = FALSE
)

Arguments

stan_fit

an R object of class stanfit, which allows the function to run without recompiling the stan code.

y

(vector) outcomes corresponding to the type of glm desired. This should match whatever datatype is expected by the stan program.

x_standardized

(matrix) matrix of numeric values with number of rows equal to the length of y and number of columns equal to p+q. It is assumed without verification that each column is standardized to whatever scale the prior expects - in Boonstra and Barbaro, all predictors are marginally generated to have mean zero and unit variance, so no standardization is conducted. In practice, all data should be standardized to have a common scale before model fitting. If regression coefficients on the natural scale are desired, they be easily obtained through unstandardizing.

q

(nonneg. integers) numbers, the sum of which add up to the number of columns in x_standardized. For the standard prior, this distinction is only needed if a different constant scale parameter (beta_orig_scale, beta_aug_scale), which is the constant 'c' in the notation of Boonstra and Barbaro, is used.

beta_aug_scale

(pos. real) constants indicating the prior scale of the horseshoe. Both values correspond to 'c' in the notation of Boonstra and Barbaro, because that paper never considers beta_orig_scale!=beta_aug_scale

local_dof

(pos. integer) numbers indicating the degrees of freedom for lambda_j and tau, respectively. Boonstra, et al. never considered local_dof != 1 or global_dof != 1.

global_dof

(pos. integer) numbers indicating the degrees of freedom for lambda_j and tau, respectively. Boonstra, et al. never considered local_dof != 1 or global_dof != 1.

slab_precision

(pos. real) the slab-part of the regularized horseshoe, this is equivalent to (1/d)^2 in the notation of Boonstra and Barbaro

intercept_offset

(vector) vector of 0's and 1's equal having the same length as y. Those observations with a value of 1 have an additional constant offset in their linear predictor, effectively a different intercept. This is useful to jointly regress two datasets in which it is believed that the regression coefficients are the same but not the intercepts and could be useful (but was not used) in the simulation study to compare to a benchmark, namely if both the historical and current datasets were available but there is a desire to adjust for potentially different baseline prevalences.

only_prior

(logical) should all data be ignored, sampling only from the prior?

mc_warmup

number of MCMC warm-up iterations

mc_iter_after_warmup

number of MCMC iterations after warm-up

mc_chains

number of MCMC chains

mc_thin

every nth draw to keep

mc_stepsize

positive stepsize

mc_adapt_delta

between 0 and 1

mc_max_treedepth

max tree depth

ntries

(pos. integer) the stan function will run up to this many times, stopping either when the number of divergent transitions* is zero or when ntries has been reached. The reported fit will be that with the fewest number of divergent iterations.

return_as_stanfit

(logical) should the function return the stanfit object asis or should a summary of stanfit be returned as a regular list

Value

list object containing the draws and other information.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
data(historical)

foo = glm_standard(y = historical$y_hist,
                   x_standardized = historical[,2:5],
                   p = 4,
                   q = 0,
                   beta_orig_scale = 0.0231,
                   beta_aug_scale = 0.0231,
                   local_dof = 1,
                   global_dof = 1,
                   slab_precision = 0.00444,
                   intercept_offset = NULL,
                   only_prior = 0,
                   mc_warmup = 1000,
                   mc_iter_after_warmup = 1000,
                   mc_chains = 2,
                   mc_thin = 1,
                   mc_stepsize = 0.1,
                   mc_adapt_delta = 0.99,
                   mc_max_treedepth = 15,
                   ntries = 2);

 data(current)

 foo = glm_standard(y = current$y_curr,
                    x_standardized = current[,2:11],
                    p = 4,
                    q = 6,
                    beta_orig_scale = 0.0223,
                    beta_aug_scale = 0.0223,
                    local_dof = 1,
                    global_dof = 1,
                    slab_precision = 0.00444,
                    intercept_offset = NULL,
                    only_prior = 0,
                    mc_warmup = 1000,
                    mc_iter_after_warmup = 1000,
                    mc_chains = 2,
                    mc_thin = 1,
                    mc_stepsize = 0.1,
                    mc_adapt_delta = 0.99,
                    mc_max_treedepth = 15,
                    ntries = 2);

umich-biostatistics/AdaptiveBayesianUpdates documentation built on July 29, 2021, 3:06 a.m.