gts.nrobust: Apply the generalized Bayesian two-stage robust-based causal...

Description Usage Arguments Details Value References Examples

View source: R/gts.nrobust.R

Description

The gts.nrobust function applies the generalized Bayesian two-stage robust-based causal model to the categorical treatment data. The model best suits the outcome data that contain outliers and are ignorably missing (i.e., MCAR or MAR).

Usage

1
2
3
4
5
6
gts.nrobust(formula, data, advanced = FALSE, adv.model, b0 = 1,
  B0 = 1e-06, g0 = 0, G0 = 1e-06, e0 = 0.001, E0 = 0.001,
  v0 = 0, V0 = 100, beta.start = NULL, gamma.start = NULL,
  e.start = NULL, df.start = 5, n.chains = 1,
  n.burnin = floor(n.iter/2), n.iter = 10000, n.thin = 1, DIC,
  debug = FALSE, codaPkg = FALSE)

Arguments

formula

An object of class formula: a symbolic description of the model to be fitted. The details of the model specification are given under "Details".

data

A dataframe with the variables to be used in the model.

advanced

Logical; if FALSE (default), the model is specified using the formula argument, if TRUE, self-defined models can be specified using the adv.model argument.

adv.model

Specify the self-defined model. Used when advanced=TRUE.

b0

The mean hyperparameter of the normal distribution (prior distribution) for the first-stage generalized causal model coefficients, i.e., coefficients for the instrumental variables. This can either be a numerical value or a vector with dimensions equal to the number of coefficients for the instrumental variables. If this takes a numerical value, then that values will serve as the mean hyperparameter for all of the coefficients for the instrumental variables. Default value of 0 is equivalent to a noninformative prior for the normal distributions. Used when advanced=FALSE.

B0

The precision hyperparameter of the normal distribution (prior distribution) for the first stage generalized causal model coefficients. This can either be a numerical value or a vector with dimensions equal to the number of coefficients for the instrumental variables. If this takes a numerical value, then that values will serve as the precision hyperparameter for all of the coefficients for the instrumental variables. Default value of 1.0E-6 is equivalent to a noninformative prior for the normal distributions. Used when advanced=FALSE.

g0

The mean hyperparameter of the normal distribution (prior distribution) for the second-stage generalized causal model coefficients, i.e., coefficients for the treatment variable and other regression covariates. This can either be a numerical value if there is only one treatment variable in the model, or a if there is a treatment variable and multiple regression covariates, with dimensions equal to the total number of coefficients for the treatment variable and covariates. Default value of 0 is equivalent to a noninformative prior for the normal distributions. Used when advanced=FALSE.

G0

The precision hyperparameter of the normal distribution (prior distribution) for the second-stage generalized causal model coefficients. This can either be a numerical value if there is only one treatment variable in the model, or a vector if there is a treatment variable and multiple regression covariates, with dimensions equal to the total number of coefficients for the treatment variable and covariates. Default value of 1.0E-6 is equivalent to a noninformative prior for the normal distributions. Used when advanced=FALSE.

e0

The location hyperparameter of the inverse Gamma distribution (prior for the scale parameter of Student's t distribution on the model residual). Default of 0.001 is equivalent to the noninformative prior for the inverse Gamma distribution.

E0

The shape hyperparameter of the inverse Gamma distribution (prior for the scale parameter of Student's t distribution on the model residual). Default of 0.001 is equivalent to the noninformative prior for the inverse Gamma distribution.

v0

The lower boundary hyperparameter of the uniform distribution (prior for the degrees of freedom parameter of Student's t distribution).

V0

The upper boundary hyperparameter of the uniform distribution (prior for the degrees of freedom parameter of Student's t distribution).

beta.start

The starting values for the first-stage generalized causal model coefficients, i.e., coefficients for the instrumental variables. This can either be a numerical value or a column vector with dimensions equal to the number of first-stage coefficients. The default value of NA will use the IWLS (iteratively reweighted least squares) estimate of first-stage coefficients as the starting value. If this is a numerical value, that value will serve as the starting value mean for all the first-stage beta coefficients.

gamma.start

The starting values for the second-stage generalized causal model coefficients, i.e., coefficients for the treatment variable and the model covariates. This can either be a numerical value or a column vector with dimensions equal to the number of second-stage coefficients. The default value of NA will use the IWLS (iteratively reweighted least squares) estimate of second-stage coefficients as the starting value. If this is a numerical value, that value will serve as the starting value mean for all the second-stage gamma coefficients.

e.start

The starting value for the precision hyperparameter of the inverse gamma distribution (prior for the scale parameter of Student's t distribution of the model residual). The default value of NA will use the inverse of the residual variance from the IWLS (iteratively reweighted least square) estimate of the second-stage model.

df.start

The starting value for the degrees of freedom of Student's t distribution.

n.chains

The number of Markov chains. The default is 1.

n.burnin

Length of burn in, i.e., number of iterations to discard at the beginning. Default is n.iter/2, that is, discarding the first half of the simulations.

n.iter

The number of total iterations per chain (including burnin). The default is 10000.

n.thin

The thinning rate. Must be a positive integer. The default is 1.

DIC

Logical; if TRUE (default), compute deviance, pD, and DIC. The rule pD=Dbar-Dhat is used.

codaPkg

Logical; if FALSE (default), an object is returned; if TRUE, file names of the output are returned.

Details

  1. The formula takes the form response ~ terms|instrumental_variables. gts.nnormal provides a detailed description of the formula rule.

  2. DIC is computed as mean(deviance)+pD.

  3. Prior distributions used in ALMOND.

    • Generalized causal model coefficients at both stages: normal distributions.

    • The generalized causal model residual: Student's t distribution.

Value

If codaPkg=FALSE(default), returns an object containing summary statistics of the saved parameters, including

s1.intercept

Estimate of the intercept from the first stage.

s1.slopeP

Estimate of the pth slope from the first stage.

s2.intercept

Estimate of the intercept from the second stage.

s2.slopeP

Estimate of the pth slope from the second stage (the first slope is always the LATE).

var.e.s2

Estimate of the residual variance at the second stage.

df.est

Estimate of the degrees of freedom for the Student's t distribution.

DIC

Deviance Information Criterion.

If codaPkg=TRUE, the returned value is the path for the output file containing the Markov chain Monte Carlo output.

References

Gelman, A., Carlin, J.B., Stern, H.S., Rubin, D.B. (2003). Bayesian data analysis, 2nd edition. Chapman and Hall/CRC Press.

Spiegelhalter, D. J., Thomas, A., Best, N. G., Gilks, W., & Lunn, D. (1996). BUGS: Bayesian inference using Gibbs sampling. http://www.mrc-bsu.cam.ac.uk/bugs, 19.

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
# Run the model
model1 <- gts.nrobust(neighborhoodRating~voucherProgram|extraBedroom,data=simVoucher)

# Run the model with the self-defined advanced feature
my.robust.model<- function(){
  for (i in 1:N){
    logit(p[i]) <- beta0 + beta1*z[i]
    x[i] ~ dbern(p[i])
    muY[i] <- gamma0 + gamma1*p[i]
    y[i] ~ dt(muY[i], pre.u2, df)
  }

  beta0 ~ dnorm(0,1)
  beta1 ~ dnorm(1, 1)
  gamma0 ~ dnorm(0, 1)
  gamma1 ~ dnorm(.5, 1)

  pre.u2 ~ dgamma(.001, .001)

  df ~ dunif(0,100)

  s1.intercept <- beta0
  s1.slope1 <- beta1
  s2.intercept <- gamma0
  s2.slope1 <- gamma1
  df.est <- df
  var.e.s2 <- 1/pre.u2
}

model2 <- gts.nrobust(neighborhoodRating~voucherProgram|extraBedroom,data=simVoucher,
advanced=TRUE, adv.model=my.robust.model)

# Extract the model DIC
model1$DIC

# Extract the MCMC output
model3 <- gts.nrobust(neighborhoodRating~voucherProgram|extraBedroom,data=simVoucher,
codaPkg=TRUE)

dingjshi/ALMOND documentation built on June 18, 2020, 4:32 p.m.