Description Usage Arguments Author(s) Examples
This function implements the idea of Bayesian tobit quantile regression employing a likelihood function that is based on the asymmetric Laplace distribution (Yu and Stander, 2007). The asymmetric Laplace error distribution is written as scale mixtures of normal distributions as in Reed and Yu (2009).
1 | Btqr(x,y, tau = 0.5, left = 0, runs = 11000, burn = 1000, thin=1)
|
x |
|
y |
|
tau |
|
left |
|
runs |
|
burn |
|
thin |
|
Rahim Alhamzawi
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # Example
set.seed(12345)
x <- abs(rnorm(100))
y <- -0.5 + x +(.25 + .25*x)*rnorm(100)
plot(x,y, type="n")
h <-(y > 0)
points(x[h],y[h],cex=.9,pch=16)
points(x[!h],y[!h],cex=.9,pch=1)
y <- pmax(0,y)
for(tau in (2:8)/9){
fit=Brq(y~x,tau=tau, method="Btqr", left=0, runs=1000, burn=500)$coef
# Note: runs =11000 and burn =1000
Xs=sort(x)
Xc=cbind(1,sort(x))
Xcf=Xc%*%c(fit)
Xcfp=pmax(0,Xcf)
lines(Xs,Xcfp,col="red")}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.