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 custom_rif_function needs to be provided.

weights

numeric vector of non-negative observation weights, hence of same length as dep_var. The default (NULL) is equivalent to weights = rep(1, length(dep_var)).

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 c(1:9)/10. If statistic = "quantiles", a single RIF regression for every quantile in probs is estimated. An interquantile ratio (range) is defined by the ratio (difference) between the max(probs)-quantile and the min(probs)-quantile.

custom_rif_function

the RIF function to compute the RIF of the custom distributional statistic. Default is NULL. Only needs to be provided if statistic = "custom". Every custom_rif_function needs the parameters dep_var, weights and probs. If they are not needed, they must be set to NULL in the function definition (e.g. probs = NULL). A custom function must return a data frame containing at least a "rif" and "weights" column. See examples for further details.

na.action

generic function that defines how NAs in the data should be handled. Default is na.omit, leading to exclusion of observations that contain one or more missings. See na.action for further details.

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 bootstrap = TRUE.

cores

positive integer indicating the number of cores to use when computing bootstrapped standard errors. Only required if bootstrap = TRUE.

...

additional parameters passed to the custom_rif_function. Apart from dep_var, weights and probs they must have a different name than the the ones in rifreg. For instance, if you want to pass a parameter statistic to the custom_rif_function, name it custom_statistic.

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 coef() call of an object of class "lm".

rif_lm

one or several objects of class "lm", containing the detailed RIF regression results.

rif

a data frame containing the RIF for each observation.

bootstrap_se

bootstrapped standard errors for each coefficient. Only provided if bootstrap = TRUE.

bootstrap_vcov

the bootstrapped variance-covariance matrix for each coefficient. Only provided if bootstrap = TRUE.

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
)


[Package rifreg version 0.1.0 Index]