ts.nnormal.s: Apply the Bayesian two-stage normal-selection causal model...

Description Usage Arguments Details Value Examples

View source: R/ts.nnormal.s.R

Description

The ts.nnormal.s function applies the Bayesian two-stage normal-selection causal model to the continuous treatment data. The model best suits the outcome data that are normally-distributed and nonignorably missing (i.e., MNAR) (e.g., dropout, attrition).

Usage

1
2
3
4
5
6
7
ts.nnormal.s(formula, data, m.ind, advanced = FALSE, adv.model, b0 = 0,
  B0 = 1e-06, g0 = 0, G0 = 1e-06, u0 = 0.001, U0 = 0.001,
  e0 = 0.001, E0 = 0.001, l0 = 0, L0 = 1e-06, beta.start = NULL,
  gamma.start = NULL, u.start = NULL, e.start = NULL,
  lambda0.start = 1, lambda1.start = 1, n.chains = 1,
  n.burnin = 5000, 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 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 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 10E+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 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 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 10E+6 is equivalent to a noninformative prior for the normal distributions. Used when advanced=FALSE.

u0

The location hyperparameter of the inverse Gamma distribution (prior for the variance of the normal distribution on the model residuals at the first stage). Default of 0.001 is equivalent to the noninformative prior for the inverse Gamma distribution.

U0

The shape hyperparameter of the inverse Gamma distribution (prior for the variance of the normal distribution on the model residuals at the first stage). Default of 0.001 is equivalent to the noninformative prior for the inverse Gamma distribution.

e0

The location hyperparameter of the inverse Gamma distribution (prior for the variance of the normal distribution on the model residuals at the second stage). 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 variance of the normal distribution on the model residuals at the second stage). Default of 0.001 is equivalent to the noninformative prior for the inverse Gamma distribution.

l0

The mean hyperparameter of the normal distribution (prior for the added-on selection 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 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.

L0

The precision hyperparameter of the normal distribution (prior for the added-on selection 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 10E+6 is equivalent to a noninformative prior for the normal distributions. Used when advanced=FALSE.

beta.start

The starting values for the first-stage 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 OLS 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 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 OLS 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.

u.start

The starting value for the precision hyperparameter of the inverse gamma distribution (prior for the variance of the normal distribution of the first-stage residual term). The default value of NA will use the inverse of the residual variance from the OLS estimate of the first-stage model.

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 second-stage residual term). The default value of NA will use the inverse of the residual variance from the OLS estimate of the second-stage model.

lambda0.start

The starting value for the intercept of the coefficient of the added-on selection model.

lambda1.start

The starting value for the slope of the coefficient of the added-on selection model.

n.chains

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

Number of total iterations per chain (including burnin). The default is 50000.

n.thin

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. ts.nnormal provides a detailed description of the formula rule.

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

  3. Prior distributions used in ALMOND.

    • Causal model coefficients at both stages: normal distributions.

    • Causal model residuals at both stages: normal distributions.

    • Added-on selection model coefficients: normal distributions.

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).

select.intercept

Estimate of the intercept from the added-on selection model.

select.slope

Estimate of the slope from the added-on selection model.

var.e.s1

Estimate of the residual variance at the first stage.

var.e.s2

Estimate of the residual variance at the second stage.

DIC

Deviance Information Criterion.

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

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
44
45
46
# Run the model
model1 <- ts.nnormal.s(readingIRT~relAge+gender+race+numsib+parentedu+ses|PredEnt,data=subECLSK,
m.ind=subECLSK$mis.ind.read, n.iter=100000)

# Run the model with the self-defined advanced feature
my.normal.s.model<- function(){
  for (i in 1:N){
    mu[i] <- beta0 + beta1*z[i]
    x[i] ~ dnorm(mu[i], pre.u1)
    muY[i] <- gamma0 + gamma1*mu[i]
    y[i] ~ dnorm(muY[i], pre.u2)

    m[i] ~ dbern(q[i])
    q[i] <- phi(lambda0 + lambda1*y[i])
  }

  beta0 ~ dnorm(0,1)
  beta1 ~ dnorm(1, 1)
  gamma0 ~ dnorm(0, 1)
  gamma1 ~ dnorm(.5, 1)
  lambda0 ~ dnorm(0, 1.0E-6)
  lambda1 ~ dnorm(0, 1.0E-6)

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

  s1.intercept <- beta0
  s1.slope1 <- beta1
  s2.intercept <- gamma0
  s2.slope1 <- gamma1
  select.intercept <- lambda0
  select.slope <- lambda1
  var.e.s1 <- 1/pre.u1
  var.e.s2 <- 1/pre.u2
}

model2 <- ts.nnormal.s(readingIRT~relAge+gender+race+numsib+parentedu+ses|PredEnt,
m.ind=subECLSK$mis.ind.read,data=subECLSK,advanced=TRUE, adv.model=my.normal.selection.model,
n.iter=100000)

# Extract the model DIC
model1$DIC

# Extract the MCMC output
ts.nnormal.s(readingIRT~relAge+gender+race+numsib+parentedu+ses|PredEnt,
m.ind=subECLSK$mis.ind.read,data=subECLSK,codaPkg=TRUE)

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