Description Usage Arguments Value References Examples
The main function for running the finite quantile mixture model. The function returns a qmix
object that can be further investigated using standard functions such as plot
, print
, and coef
. The model can be passed using a formula
as in lm()
. Convergence diagnotics can be performed using either print(object, "mcmc")
or plot(object, "mcmc")
.
1 2 3 |
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. |
nmix |
The number of mixture components. |
design |
Quantile specification. Options include "fixed" and "random". The default choice is "fixed" which requires quantile inputs from the user. |
q |
The quantile value. |
nsim |
The number of iterations. |
burnin |
The number of burnin iterations. |
thin |
Thinning parameter. |
CIsize |
The size of posterior confidence interval. |
nchain |
The number of parallel chains. |
seeds |
Random seeds to replicate the results. |
offset |
Offset values to enhance sampling stability. The default value is 1e-20. |
inverse_distr |
If FALSE, the ALD will not be reversed. The default is FALSE. |
A qmix
object. An object of class qmix
contains the following elements
Call
The matched call.
formula
Symbolic representation of the model.
nmix
Number of mixture components. If unspecified in the fixed-quantile specification, the value equals the number of quantiles specified. Otherwise, an error will be generated for the missing value.
design
Options include "fixed" and "random" for fixed- and random-quantile specification.
q
Quantiles in the fixed-quantile specification.
nsim
Number of iterations.
Burnin
Number of burnin iterations.
thin
Thinning.
seeds
Random seeds for reproducibility. The default is 12345.
CIsize
Size of the posterior confidence interval.
inverse_distr
Indicating whether ALD should be inversed.
offset
Offset to enhance stability in estimation. The default value is 1e-20.
data
Data used.
x
Independent variables.
y
Dependent variables.
xnames
Names of the independent variables.
stanfit
Output from stan.
sampledf
Posterior samples.
summaryout
Summary of the posterior samples.
npars
Number of covariates.
ulbs
Upper and lower bounds based on the specified confidence interval.
means
Mean estimates.
thetas
Estimated proportions of each mixture component.
binarylogic
Indicating whether the data contain a binary dependent variable.
Lu, Xiao (2019). Beyond the Average: Conditional Hypothesis Testing with Quantile Mixture. Working Paper.
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 | # simulate a mixture of 2 ALDs
k <- 2
N <- 50
# true effects: -10 and 10 respectively for two mixture components
beta1 <- -10
beta2 <- 10
set.seed(34324)
x1 <- rnorm(N,0,1)
x2 <- rnorm(N,0,1)
xb1 <- x1*beta1
xb2 <- x2*beta2
y1 <- y2 <- NA
# quantiles at 0.1 and 0.9
p1 <- 0.1
p2 <- 0.9
for (i in 1:N){
y1[i] <- rald(1,mu = xb1[i],p = p1,sigma = 1)
y2[i] <- rald(1,mu = xb2[i],p = p2,sigma = 1)
}
y <- c(y1,y2)
x <- c(x1,x2)
dat <- as.data.frame(cbind(y,x))
# Estimate the model using both the fixed- and random-quantile specification
model <- qmix(y ~ x, data = dat, nmix = 2, design = "fixed", q = c(0.1, 0.9))
# Summary the results
coef(model)
print(model)
# check traceplots
plot(model)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.