NormInvGamPosteriorSample: Generate conjugate posterior sample of coefficients for a...

Description Usage Arguments Value Author(s)

View source: R/NormInvGamPosteriorSample.R

Description

This function can be used to generate a posterior sample of effects under the Normal-Inverse-Gamma conjugate model, for a particular combination of covariates (i.e. conditional on a fixed model). For use with JAM specify xTx and z instead of data and outcome.var. Note to self: adapted from Michael Jordan's lecture notes "Bayes Factors, g-priors, and Model Selection for Regression". Conugate expression is given under the 1/sigma prior. For the InverseGamma(a, b) prior as below, simply add a and b to the respective hyperparameters in equation (6) of Michael Jordan's notes.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
NormInvGamPosteriorSample(
  data = NULL,
  outcome.var = NULL,
  confounders = NULL,
  model = NULL,
  tau = NULL,
  n.samples = 1000,
  xTx = NULL,
  z = NULL,
  sigma2_invGamma_a = NULL,
  sigma2_invGamma_b = NULL
)

Arguments

data

Matrix or dataframe containing the data to analyse. Rows are indiviuals, and columns contain the variables and outcome. If modelling summary statistics specify X.ref, marginal.betas, and n instead (see below).

outcome.var

Name of outcome variable in data. For survival data see times.var below. If modelling summary statistics with JAM this can be left null but you must specify X.ref, marginal.beats and n instead (see below).

confounders

Optional vector of confounders to fix in the model at all times, i.e. exclude from model selection.

model

Vector of covariate names to include in the model. Do not include confounders here - they should be specified with the confounders argument.

tau

Value to use for the g-prior sparsity parameter (tau*sigma^2 parameterisation).

n.samples

Number of posterior samples to draw.

sigma2_invGamma_a

Inverse-Gamma parameter a for the residual variance. Not specifying means the value in default.arguments is used (type "data(DefaultArguments)").

sigma2_invGamma_b

Inverse-Gamma parameter b for the residual variance. Not specifying means the value in default.arguments is used (type "data(DefaultArguments)").

Value

The posterior sample as a matrix. Rows are different posterior samples, and columns are parameters.

Author(s)

Paul Newcombe


pjnewcombe/R2BGLiMS documentation built on Feb. 10, 2020, 8:52 p.m.