Description Usage Arguments Details Value Examples
The ts.nrobust
function applies the robust-based Bayesian two-stage causal model
to the continuous treatment data. The model best suits the outcome data that contain outliers and
are complete or ignorably missing (i.e., missing completely at random or missing at random).
1 2 3 4 5 6 | ts.nrobust(formula, data, advanced = FALSE, adv.model, b0 = 1,
B0 = 1e-06, g0 = 0, G0 = 1e-06, u0 = 0.001, U0 = 0.001,
e0 = 0.001, E0 = 0.001, v0 = 0, V0 = 100, beta.start = NULL,
gamma.start = NULL, u.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)
|
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 scale parameter of Student's t 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 scale parameter of Student's t distribution on the model residuals at the second stage). 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 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. |
df.start |
The starting value for the degrees of freedom of Student's t distribution. |
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 10000. |
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. |
The formula takes the form response ~ terms|instrumental_variables.
ts.nnormal
provides a detailed description of the formula rule.
DIC is computed as mean(deviance)+pD.
Prior distributions used in ALMOND.
Causal model coefficients at both stages: normal distributions.
The causal model residual at the first stage: normal distribution; the causal model residual at the second stage: Student's t distribution.
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.s1 |
Estimate of the residual variance at the first stage. |
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.
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 | # Run the model
model1 <- ts.nrobust(outcome~treatment|instrument,data=subECLSK)
# Run the robust model with the self-defined advanced feature
my.robust.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] ~ dt(muY[i], pre.u2, df)
}
beta0 ~ dnorm(0,1)
beta1 ~ dnorm(1, 1)
gamma0 ~ dnorm(0, 1)
gamma1 ~ dnorm(.5, 1)
pre.u1 ~ dgamma(.001, .001)
pre.u2 ~ dgamma(.001, .001)
df ~ dunif(0,50)
s1.intercept <- beta0
s1.slope1 <- beta1
s2.intercept <- gamma0
s2.slope1 <- gamma1
df.est <- df
var.e.s1 <- 1/pre.u1
var.e.s2 <- 1/pre.u2
}
model2 <- ts.nrobust(outcome~treatment|instrument,data=subECLSK,
advanced=TRUE,adv.model=my.robust.model)
# Extract the model DIC
model1$DIC
# Extract the MCMC output
ts.nrobust(outcome~treatment|instrument,data=subECLSK,codaPkg=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.