Description Usage Arguments Details Value References Examples
View source: R/gts.nnormal.s.R
The gts.nnormal.s
function applies the generalized Bayesian two-stage
normal-selection causal model to the categorical treatment data.
The model best suits the normally-distributed outcome data that are normally-distributed
and nonignorably missing (i.e., MNAR) (e.g., dropout, attrition).
1 2 3 4 5 6 | gts.nnormal.s(formula, data, m.ind, advanced = FALSE, adv.model,
b0 = 0, B0 = 1e-06, g0 = 0, G0 = 1e-06, e0 = 0.001,
E0 = 0.001, l0 = 0, L0 = 1e-06, beta.start = NULL,
gamma.start = NULL, e.start = NULL, lambda0.start = 1,
lambda1.start = 1, n.chains = 1, n.burnin = floor(n.iter/2),
n.iter = 50000, 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 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 variance of the normal 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 variance of the normal distribution on the model residual). 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 1.0E-6 is equivalent to a noninformative prior for the normal distributions. Used when advanced=FALSE. |
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 variance of the normal distribution on 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. |
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 |
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 50000. |
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. |
The formula takes the form response ~ terms|instrumental_variables.
gts.nnormal
provides a detailed description of the formula rule.
DIC is computed as mean(deviance)+pD.
Prior distributions used in ALMOND.
Generalized causal model coefficients at both stages: normal distributions.
Added-on selection model coefficients: normal distributions.
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.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.
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.
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 | # Run the model
model1 <- gts.nnormal.s(outcome~treatment|instrument,data=simCatNormMNAR,
m.ind=simCatNormMNAR$indicator,n.iter=100000)
# Run the model with the self-defined advanced feature
my.normal.s.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] ~ 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.u2 ~ dgamma(.001, .001)
s1.intercept <- beta0
s1.slope1 <- beta1
s2.intercept <- gamma0
s2.slope1 <- gamma1
select.intercept <- lambda0
select.slope <- lambda1
var.e.s2 <- 1/pre.u2
}
model2 <- gts.nnormal.s(outcome~treatment|instrument,data=simCatNormMNAR,
m.ind=simCatNormMNAR$indicator, advanced=TRUE, adv.model=my.normal.s.model,n.iter=100000)
# Extract the model DIC
model1$DIC
# Extract the MCMC output
model3 <- gts.nnormal.s(outcome~treatment|instrument,data=simCatNormMNAR,
m.ind=simCatNormMNAR$indicator,n.iter=100000,codaPkg=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.