maref.rqt: Marginal Effects

Description Usage Arguments Details Value Author(s) See Also Examples

Description

This function computes marginal effects for rqt and rq.counts objects.

Usage

1
2
3
4
5
maref(object, newdata, index = 2, index.extra = NULL, ...)
## S3 method for class 'rqt'
maref(object, newdata, index = 2, index.extra = NULL, ...)
## S3 method for class 'rq.counts'
maref(object, newdata, index = 2, index.extra = NULL, ...)

Arguments

object

an rqt object.

newdata

an optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used.

index

a numeric value to specify the position of the effect among the model's coefficients.

index.extra

optional numeric value(s) to specify the position of additional effects to be included in the computation.

...

not used.

Details

Given the general model Q(h(response)|X) = Xb, where Q is the conditional quantile function, X a design matrix with p columns, and h is a one- or two-parameter transformation with inverse hinv, maref allows computing the marginal effect:

dQ(response|X)/dx[j]

where j specifies the covariate in the design matrix with respect to which the marginal effect is to be computed and is given in the argument index. Since the model may contain interactions with x[j], additional terms in the matrix X to be included in the computation are given in the argument index.extra. See the examples below.

Value

a vector for single quantiles or a matrix for multiple quantiles of marginal effects.

Author(s)

Marco Geraci

See Also

tsrq

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 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)

Qtools documentation built on May 2, 2019, 6:09 p.m.