mcmc_agric_model: MCMC procedure for hierarchical model of agricultural...

Description Usage Arguments Details Value Examples

View source: R/mcmc_agric_model.R

Description

1
2
This function perform MCMC sampling for the hierarchical model of agricultural data.
There are two modules in this model: Gaussian response (HM), and Proportional Odds (PO) prior for missing ManureLevel.

Usage

 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
mcmc_agric_model(
  data_arc,
  data_mod,
  impute_spec = c("full", "cut", "smi")[1],
  power_w_PO = 1,
  power_w_HM = 1,
  prior_spec_PO = c("flat", "proper")[2],
  prior_spec_HM = c("flat", "proper")[2],
  PO_site_rnd_eff = TRUE,
  HM_site_rnd_eff = TRUE,
  n_iter = 10000,
  n_iter_sub = 100,
  n_warmup = 1000,
  n_thin = 2,
  theta_ini = NULL,
  theta_min_max = NULL,
  theta_prop_int = NULL,
  theta_prop_kernel = c("norm", "unif")[1],
  n_epoch_adapt = 0,
  n_iter_adapt = 2000,
  ManureLevel_arc_imp_ini = NULL,
  Rainfall_arc_imp_ini = NULL,
  imp_playpen = FALSE,
  gibbs_hm = TRUE,
  PO_expand = FALSE,
  POmixda = TRUE,
  lambda_prop_int = 0.2,
  lambda_mix_PO_prior = c(1, 1),
  keep_imp = FALSE,
  keep_ll = FALSE,
  elpd = FALSE,
  out_file_rda = NULL,
  log_file = NULL,
  devel = FALSE
)

Arguments

data_arc

Data frame. Archaeological data

data_mod

Data frame. Modern data

impute_spec

Character. Specification of imputed values of ManureLevel: "full", "cut", "smi"

power_w_PO

Numeric. Raise the likelihood in the PO module to a power when performing M-H steps.

power_w_HM

Numeric. Raise the likelihood in the HM module to a power when performing M-H steps.

prior_spec_PO

specification of prior distributions for the parameters in the PO model: "flat" or "proper"

prior_spec_HM

specification of prior distributions for the parameters in the HM model: "flat" or "proper"

PO_site_rnd_eff

Boolean. Shall the PO module use random effects by Site

HM_site_rnd_eff

Boolean. Shall the HM module use random effects by Site

n_iter

Integer. Number of iterations in the main MCMC chain.

n_iter_sub

Integer. Number of updates in the subchain for parameters in the PO module.

n_warmup

Integer. Number of updates discarded when "warming-up" the MCMC

n_thin

Integer. One of every n_thin updates will be kept (thinning the chain)

theta_ini

Numeric vector. Initial values for the parameters

theta_min_max

matrix with two columns, minimum and maximum values for each parameter

theta_prop_int

Used to control the width of the proposal distribution for parameters in PO and HM modules

theta_prop_kernel

Shape of the proposal distribution: "uniform" or "normal"

n_epoch_adapt

Integer. Number of epochs that adaptation runs of the MCMC, to addapt the proposal distribution, is performed before the real chain.

n_iter_adapt

Integer. Number of iterations in the adaptation runs of the MCMC.

ManureLevel_arc_imp_ini

Initial values for imputing the missing values of Rainfall

Rainfall_arc_imp_ini

Initial values for imputing the missing values of Rainfall

imp_playpen

(Experimental). If True, The missing manure levels are imputed in to avoid quasi-complete separation in the PO module.

gibbs_hm

Boolean. Shall we use Gibss to update parameters in the HM module. If FALSE, M_H is used.

PO_expand

Indicates if the Proportional Odds models should be expanded by considering an additional mixture component

POmixda

Indicates if the inference for the mixture model uses data augmentation

lambda_prop_int

Double. Width of the proposal distribution for the mixing weight, when PO_expand=TRUE

lambda_mix_PO_prior

Numeric vector. indicates the two parameters of the beta prior for the mixture weight

keep_imp

Indicates if the imputed values for missing data should be returned

keep_ll

Indicates if the individual log-likelihoods should be returned

elpd

Indicates if the ELPD should be computed and returned

out_file_rda

Indicates a file (.rda) where the output should be saved

log_file

Indicates a file (.txt) where the log of the process should be saved

devel

Development mode

Details

The hierarchical model consists of two parts: The Proportional Odds (PO1) component, and the Gaussian Linear model (HM1). HM1: normd15N ∼ 1 + Rainfall + ManureLevel + (1|Site) weights = nlme::varIdent (form=~1|Category) PO1: ManureLevel ∼ 1 + Size + (1|Site) link = "logistic"

MCMC details: Coefficients in the HM1 modulel can be updated using Gibbs sampling (gibbs_hm=TRUE) for the joint conditional posterior, M-H otherwise Parameters in the PO module are updated using M-H, updating one by one. ManureLevel missing values is updated using M-H one value at a time. Rainfall missing values are updated all together using M-H.

1
2
3
4
5
6
7
8
9
This function allows to perform adaptations for the proposal of the PO1 parameters. Change n_epoch_adapt and n_iter_adapt.

In this implementation, we allow to perform several types of inference.
1) Conventional Bayes (default): impute_spec="full", set power_w_HM=1, power_w_PO=1
2) Powered likelihood: impute_spec="full", gibbs_hm="FALSE", set "power_w_HM" and "power_w_PO" to control the influence of each module in the update of parameters and missing data.
3) Cut model: impute_spec="cut" (deprecate set power_w_HM and power_w_PO). Bayesian multiple imputation for ManureLevel.
4) smi imputation: impute_spec="smi", set "power_w_HM" and "power_w_PO" to control the influence of each module in the imputation of ManureLevel.

Parameters are initialized in the MLE using a single imputation of missing values.

Value

A list with three main elements, described below, and some details about the run.

theta_mcmc

Matrix with the chains of the parameters in the model.

ManureLevel_imp_mcmc

if keep_imp=TRUE, matrix with the chains of the imputed values of the missing ManureLevel.

Rainfall_imp_mcmc

if keep_imp=TRUE, matrix with the chains of the imputed values of the missing Rainfall.

Examples

1
2
3
4
5
6
## Not run: 

##### Cut model for NMeso data #####


## End(Not run)

christianu7/aistats2020smi documentation built on March 7, 2021, 2:40 p.m.