xtvfreg: Variance Function Panel Regression

View source: R/xtvfreg.R

xtvfregR Documentation

Variance Function Panel Regression

Description

Implements an iterative mean-variance panel regression estimator that allows both the mean and variance of the dependent variable to be functions of covariates. Based on Mooi-Reci and Liao (2025).

Usage

xtvfreg(
  formula,
  data,
  group,
  panel_id,
  mean_vars,
  var_vars,
  weights = NULL,
  subset = NULL,
  converge = 1e-06,
  max_iter = 100,
  verbose = TRUE
)

Arguments

formula

A formula specifying the dependent variable

data

A data frame containing the variables

group

A character string naming the grouping variable

panel_id

A character string naming the panel identifier

mean_vars

A character vector of variable names for the mean equation

var_vars

A character vector of variable names for the variance equation

weights

Optional character string naming the weight variable

subset

Optional logical vector for subsetting

converge

Convergence tolerance (default: 1e-6)

max_iter

Maximum iterations (default: 100)

verbose

Logical; print iteration history? (default: TRUE)

Value

An object of class "xtvfreg" containing:

results

List of results for each group

groups

Vector of group values

call

The matched call

convergence

Convergence information for each group

variance_decomp

Variance decomposition for each group

depvar

Name of dependent variable

panel_id

Name of panel identifier

group_var

Name of grouping variable

mean_vars

Variables in mean equation

var_vars

Variables in variance equation

References

Mooi-Reci, I., and Liao, T. F. (2025). Unemployment: a hidden source of wage inequality? European Sociological Review, 41(3), 382-401. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1093/esr/jcae052")}

Examples

# Example using nlswork subset data
data(nlswork_subset)

# Prepare the data
# Keep only observations with complete wage data and white/black race
analysis_data <- subset(nlswork_subset, 
                        !is.na(ln_wage) & 
                        !is.na(tenure) & 
                        race %in% 1:2)

# Create race grouping variable
analysis_data$race_group <- factor(analysis_data$race,
                                   levels = 1:2,
                                   labels = c("white", "black"))

# Create within and between components for tenure
analysis_data$m_tenure <- ave(analysis_data$tenure,
                              analysis_data$idcode,
                              FUN = function(x) mean(x, na.rm = TRUE))
analysis_data$d_tenure <- analysis_data$tenure - analysis_data$m_tenure

# Estimate varying effects model
result <- xtvfreg(
  formula = ln_wage ~ 1,
  data = analysis_data,
  group = "race_group",
  panel_id = "idcode",
  mean_vars = c("m_tenure", "d_tenure", "age"),
  var_vars = c("m_tenure"),
  verbose = FALSE
)

# View a summary of results
summary(result)

# Extract coefficients for white group if needed
coef(result, equation = "mean", group = "white")


xtvfreg documentation built on Nov. 27, 2025, 1:06 a.m.

Related to xtvfreg in xtvfreg...