# NOT RUN {
# 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)
# }
Run the code above in your browser using DataLab