# Box-Cox quantile regression model (dataset trees from package 'datasets')
fit <- tsrq(Volume ~ Height, data = trees, tsf = "bc", tau = 0.9)
# Coefficients (transformed scale)
coef(fit)
# Design matrix
head(fit$x)
# Marginal effect of 'Height'
maref(fit, index = 2)
# Plot marginal effect over grid of values (for fixed girth)
nd <- data.frame(Height = seq(min(trees$Height), max(trees$Height), length = 100),
Girth = rep(mean(trees$Girth), 100))
x <- maref(fit, newdata = nd, index = 2)
plot(nd$Height, x, xlab = "height", ylab = "marginal effect on volume")
# Include interaction between 'Height' and 'Girth'
fit <- tsrq(Volume ~ Height * Girth, data = trees, tsf = "bc", tau = 0.5)
head(fit$x)
# Marginal effect of 'Height'
maref(fit, index = 2, index.extra = 4)
# Quantile regression for counts (log transformation)
data(esterase)
fit <- rq.counts(Count ~ Esterase, tau = 0.25, data = esterase, M = 50)
maref(fit, index = 2)Run the code above in your browser using DataLab