| cbq {cbq} | R Documentation |
Fitting conditional binary quantile models
Description
The main function for running the conditional binary quantile model. The function returns a cbq cbq object that can be further investigated using standard functions such as plot, print, coef, and predict.
Usage
cbq(
formula,
data,
q = NULL,
vi = FALSE,
nsim = 1000,
grad_samples = 1,
elbo_samples = 100,
tol_rel_obj = 0.01,
output_samples = 2000,
burnin = NULL,
thin = 1,
CIsize = 0.95,
nchain = 1,
seeds = 12345,
inverse_distr = FALSE,
offset = 1e-20,
mc_core = TRUE
)
Arguments
formula |
An object of class "Formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted. |
data |
A data frame containing the variables in the model. |
q |
The quantile value. |
vi |
Indicating whether variantional inference should be used instead of MCMC sampling procedure. |
nsim |
The number of iterations. |
grad_samples |
Passed to |
elbo_samples |
Passed to |
tol_rel_obj |
Passed to |
output_samples |
Passed to |
burnin |
The number of burnin iterations. |
thin |
Thinning parameter. |
CIsize |
The size of confidence interval. |
nchain |
The number of parallel chains. |
seeds |
Random seeds to replicate the results. |
inverse_distr |
If FALSE, the ALD will not be reversed. The default is FALSE. |
offset |
Offset values to enhance sampling stability. The default value is 1e-20. |
mc_core |
Indicating whether the estimation will be run in multiple parallel chains. The default is TRUE. |
Details
The model can be passed either as a combination of a formula and a data frame data, as in lm().
Convergence diagnotics can be performed using either print(object, "mcmc") or plot(object, "mcmc").
Value
A cbq object, which can be further analyzed with its associated plot.cbq, coef.cbq and print.cbq functions.
An object of class cbq contains the following elements
CallThe matched call.
formulaSymbolic representation of the model.
qThe quantile value.
nsimThe number of MCMC iterations.
burninThe number of burnin periods.
thinThinning.
seedsRandom seeds.
CIsizeThe size of confidence interval.
dataData used.
xCovaraites used.
yThe dependent variable.
xnamesNames of the covariates.
stanfitOutputs from stan.
sampledfA matrix of posterior samples.
summaryoutA summary based on posterior samples.
nparsNumber of covariates.
ulbsLower and upper confidence bounds.
meansEstimates at the mean.
viIndicating whether variational inference has been performed.
output_samplesSample outputs.
fixed_varVariables estimated using fixed effects.
random_varVariables estimated using random effects.
xqVariables indicating the choice sets.
Author(s)
Xiao Lu
References
Lu, Xiao. (2020). Discrete Choice Data with Unobserved Heterogeneity: A Conditional Binary Quantile Model. Political Analysis, 28(2), 147-167. https://doi.org/10.1017/pan.2019.29
Examples
# Simulate the data
x <- rnorm(50)
y <- ifelse(x > 0, 1, 0)
dat <- as.data.frame(cbind(y, x))
# Estimate the CBQ model
model <- cbq(y ~ x, dat, 0.5, nchain = 1, mc_core = FALSE)
# Show the results
print(model)
coef(model)
plot(model)