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
)
Run the code above in your browser using DataLab