rifreg {rifreg} | R Documentation |
RIF regression
Description
Estimate a recentered influence function (RIF) regression for a distributional statistic of interest.
Usage
rifreg(
formula,
data,
statistic = "quantiles",
weights = NULL,
probs = c(1:9)/10,
custom_rif_function = NULL,
na.action = na.omit,
bootstrap = FALSE,
bootstrap_iterations = 100,
cores = 1,
...
)
Arguments
formula |
an object of class "formula". See lm for further details. |
data |
a data frame containing the variables in the model. |
statistic |
string containing the distributional statistic for which to compute the RIF. Can be one of
"quantiles", "mean", "variance", "gini", "interquantile_range", "interquantile_ratio", or "custom".
Default is "quantiles". If "custom" is selected, a |
weights |
numeric vector of non-negative observation weights, hence of same length as |
probs |
a vector of length 1 or more with probabilities of quantiles. Each quantile is indicated with a value between 0 and 1.
Default is |
custom_rif_function |
the RIF function to compute the RIF of the custom distributional statistic.
Default is NULL. Only needs to be provided if |
na.action |
generic function that defines how NAs in the data should be handled.
Default is |
bootstrap |
boolean (default = FALSE) indicating if bootstrapped standard errors will be computed |
bootstrap_iterations |
positive integer indicating the number of bootstrap iterations to execute.
Only required if |
cores |
positive integer indicating the number of cores to use when computing bootstrapped standard errors.
Only required if |
... |
additional parameters passed to the |
Value
rifreg
returns an object of class
"rifreg"
.
A "rifreg"
object is a list containing the following components:
estimates |
a matrix of RIF regression coefficients for each
covariate and the intercept. In case of several quantiles,
coefficient estimates for each quantile are provided.
Equivalent to |
rif_lm |
one or several objects of class |
rif |
a data frame containing the RIF for each observation. |
bootstrap_se |
bootstrapped standard errors for each coefficient.
Only provided if |
bootstrap_vcov |
the bootstrapped variance-covariance matrix for each coefficient.
Only provided if |
statistic |
the distributional statistic for which the RIF was computed. |
custom_rif_function |
The custom RIF function in case it was provided. |
probs |
the probabilities of the quantiles that were computed, in case the distributional statistic requires quantiles. |
References
Firpo, Sergio P., Nicole M. Fortin, and Thomas Lemieux. 2009. “Unconditional Quantile Regressions.” Econometrica 77(3): 953–73.
Cowell, Frank A., and Emmanuel Flachaire. 2015. “Statistical Methods for Distributional Analysis.” In Anthony B. Atkinson and François Bourguignon (eds.), Handbook of Income Distribution. Amsterdam: Elsevier.
Examples
rifreg <- rifreg(
formula = log(wage) ~ union +
nonwhite +
married +
education +
experience,
data = men8385,
statistic = "quantiles",
weights = weights,
probs = seq(0.1, 0.9, 0.1),
bootstrap = FALSE
)
# custom function
custom_variance_function <- function(dep_var, weights, probs = NULL) {
weighted_mean <- weighted.mean(x = dep_var, w = weights)
rif <- (dep_var - weighted_mean)^2
rif <- data.frame(rif, weights)
names(rif) <- c("rif_variance", "weights")
return(rif)
}
rifreg <- rifreg(
formula = log(wage) ~ union + nonwhite + married + education + experience,
data = men8385,
statistic = "custom",
weights = weights,
probs = NULL,
custom_rif_function = custom_variance_function,
bootstrap = FALSE
)