# NOT RUN {
## Get newest version of BayesXsrc.
## Note: needs sh, svn and R build tools!
## get_BayesXsrc()
# }
# NOT RUN {
if(require("BayesXsrc")) {
## Simulate some data
set.seed(123)
d <- GAMart()
## Estimate model with BayesX. Note
## that BayesX computes starting values, so
## these are not required by some optimizer function
## in bamlss()
b1 <- bamlss(num ~ s(x1) + s(x2) + s(x3) + s(lon,lat),
data = d, optimizer = FALSE, sampler = BayesX)
plot(b1)
## Same model with anisotropic penalty.
b2 <- bamlss(num ~ s(x1) + s(x2) + s(x3) + tx(lon,lat),
data = d, optimizer = FALSE, sampler = BayesX)
plot(b2)
## Quantile regression.
b3_0.1 <- bamlss(num ~ s(x1) + s(x2) + s(x3) + tx(lon,lat),
data = d, optimizer = FALSE, sampler = BayesX,
family = gF("quant", prob = 0.1))
b3_0.9 <- bamlss(num ~ s(x1) + s(x2) + s(x3) + tx(lon,lat),
data = d, optimizer = FALSE, sampler = BayesX,
family = gF("quant", prob = 0.9))
## Predict quantiles.
p_0.1 <- predict(b3_0.1, term = "s(x2)")
p_0.9 <- predict(b3_0.9, term = "s(x2)")
## Plot.
plot2d(p_0.1 + p_0.9 ~ x2, data = d)
}
# }
Run the code above in your browser using DataCamp Workspace