| Q.reg | R Documentation |
Use this function to adequately confer the formula
in VGAM when fitting quantile regression models.
Q.reg(y, pvector = NULL, length.arg = NULL)
y |
Numeric, a vector or a matrix. It is the response or dependent
variable in the |
pvector |
A prototype vector. Entries are the conditional |
length.arg |
A length–1 positive integer. It is the number of |
Conditional quantile regression can be carried out using family
functions in VGAM and VGAMextra.
The formula must be set up using this function, Q.reg.
Here, the p–quantiles of interest may be entered via
pvector. Alternatively, use argument length.arg by
establishing the length of pvector.
Besides, the corresponding link must be entered.
For example, gamma1Qlink
is the proper link to fit models of conditional quantiles for
data distributed as Gamma via the family function
gamma1.
See examples for further details.
A matrix, each column adequately arranged for regression on conditional quantiles, conforming with VGAM.
Indeed, this is equivalent to cbind(y, y, ...), where the
total number of columns is, either the length of pvector, or
length.arg.
Link functions for quantile regression in VGAM require the
vector of p–quantiles of interest via the argument p.
See normal1sdQlink or
maxwellQlink for instance.
Therefore, the integer entered at length.arg in this function,
if utilized, must match the length of the vector p. Else,
it will be recycled.
V. Miranda and T. W. Yee.
normal1sdQlink,
maxwellQlink,
gamma1Qlink,
gamma1,
vglm,
vgam
### Quantile regression with data distributed as Maxwell(s) ###
set.seed(12073)
x2 <- seq(0, 100,length.out = 100) # independent variable
b0 <- 0.5 # true intercept
b1 <- 0.25 # true slope
b2 <- 0.02 # true second order coef.
alpha <- b0 + b1 * x2 + b2 * x2^2 # Quadratically modelling the parameters
nn <- 100 # Sample size
# The data as a data frame. #
mdata <- data.frame(y = rmaxwell(n = nn, rate = alpha), x2 = x2, x3 = x2^2)
# Quantile regression using our link function maxwellQlink(). #
# Quantiles 25%, 50%, 75% are of interest #
my.p <- c(0.25, 0.50, 0.75)
fit <- vglm(Q.reg(y, pvector = my.p) ~ x2 + x3,
# OPTIONALLY Q.reg(y, length = length(my.p)) ~ x2 + x3
maxwell(link = "maxwellQlink(p = my.p)"),
data = mdata, trace = TRUE, crit = "coef")
coef(fit, matrix = TRUE)
summary(fit)
head(predict(fit))
constraints(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.