Learn R Programming

valueprhr (version 0.1.0)

test_structural_breaks: Test for Structural Breaks

Description

Performs multiple structural break tests on the aggregated time series relationship between direct and production prices.

Usage

test_structural_breaks(panel_data, chow_years = NULL, min_segment = 10L)

Value

A list containing:

chow

Chow test results for candidate years

cusum

CUSUM test results

mosum

MOSUM test results

supf

supremum F test results

breakpoints

Estimated breakpoint dates

aggregated_data

The aggregated time series used

Arguments

panel_data

Data frame in panel format.

chow_years

Integer vector of candidate break years for Chow test. Default NULL uses 1986, 1997, 2001, 2008 if present.

min_segment

Integer minimum observations per segment. Default 10.

Details

This function aggregates panel data to a single time series by taking means across sectors, then applies various structural break tests from the strucchange package.

Examples

Run this code
# \donttest{
if (requireNamespace("strucchange", quietly = TRUE)) {
  set.seed(123)
  years <- 1980:2020
  panel <- data.frame(
    year = rep(years, 5),
    sector = rep(LETTERS[1:5], each = length(years)),
    log_direct = rnorm(length(years) * 5, 5, 0.5),
    log_production = rnorm(length(years) * 5, 5, 0.5)
  )

  break_tests <- test_structural_breaks(panel)
  print(break_tests$cusum)
}
# }

Run the code above in your browser using DataLab