Skip to content

Commit db5c705

Browse files
committed
text summarizing the content or functions
1 parent 94975df commit db5c705

File tree

8 files changed

+118
-22
lines changed

8 files changed

+118
-22
lines changed

R/VAR.R

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
# This is a copy of the code from the package vars by Bernhard Pfaff
2-
# with changes that were not merged to the package
3-
# with the pull request from 2021-08-22
1+
# Internal VAR Estimation Function (Modified from vars package)
2+
#
3+
# This is a modified copy of the VAR() function from the vars package by Bernhard Pfaff.
4+
# The modifications were submitted via pull request on 2021-08-22 but were not merged:
45
# https://github.com/bpfaff/vars/pull/10/files
5-
# I.e., subsequent vars v.1.5-6 (2021-09-17) does not include these changes.
6-
# The changes (most of them are marked with "#VL") allow for restricted VAR
7-
# estimation and Granger causality testing using such models.
6+
#
7+
# The vars package v.1.5-6 (2021-09-17) and later versions do not include these changes.
8+
# This modified version is maintained internally to support restricted VAR estimation
9+
# and Granger causality testing with lag restrictions.
10+
#
11+
# Key Modifications (marked with "#VL" comments):
12+
# - Added lag.restrict parameter to exclude near-contemporaneous lags
13+
# - Enhanced integration with causality_pred() and causality_predVAR() functions
14+
# - Support for restricted coefficient matrices in VAR models
15+
#
16+
# @keywords internal
17+
# @noRd
818

919
VAR <- function(y, p = 1, type = c("const", "trend", "both", "none"),
1020
season = NULL, exogen = NULL, lag.max = NULL,

R/VARselect.R

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
# This is a copy of the code from the package vars by Bernhard Pfaff
2-
# with changes that were not merged to the package
3-
# with the pull request from 2021-08-22
1+
# Internal VAR Order Selection Function (Modified from vars package)
2+
#
3+
# This is a modified copy of the VARselect() function from the vars package by Bernhard Pfaff.
4+
# The modifications were submitted via pull request on 2021-08-22 but were not merged:
45
# https://github.com/bpfaff/vars/pull/10/files
5-
# I.e., subsequent vars v.1.5-6 (2021-09-17) does not include these changes.
6-
# The changes (most of them are marked with "#VL") allow for restricted VAR
7-
# estimation and Granger causality testing using such models.
6+
#
7+
# The vars package v.1.5-6 (2021-09-17) and later versions do not include these changes.
8+
# This modified version is maintained internally to support restricted VAR estimation
9+
# with lag restrictions for Granger causality testing.
10+
#
11+
# Key Modifications (marked with "#VL" comments):
12+
# - Added lag.restrict parameter for excluding near-contemporaneous lags
13+
# - Validation checks for lag.restrict parameter
14+
# - Integration with modified VAR() function
15+
#
16+
# @keywords internal
17+
# @noRd
818

919
VARselect <- function(y,
1020
lag.max = 10,

R/fun_causality.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# Internal Helper Functions for Granger Causality Testing
2+
#
3+
# This file contains internal (non-exported) helper functions for Granger causality
4+
# testing with restricted VAR models. These functions are used by causality_pred()
5+
# and causality_predVAR().
6+
#
7+
# Functions:
8+
# - restrictions(): Creates/overlays restriction matrix for VAR models
9+
# - caustests(): Computes multiple causality test statistics
10+
#
11+
# @keywords internal
12+
# @noRd
13+
114
# Function to recreate matrix of restrictions and overlay new restrictions for causality testing
215
restrictions <- function(x, cause) {
316
co.names <- vars::Bcoef(x)

R/fun_cusum.R

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
#Auxiliary functions related to the modified CUSUM statistic
2-
#by Horvath et al. (2017) for testing changepoints.
1+
# Internal Helper Functions for Modified CUSUM Changepoint Tests
2+
#
3+
# This file contains internal (non-exported) helper functions for implementing
4+
# the modified CUSUM statistic by Horvath et al. (2017) for changepoint detection.
5+
# These functions are used by mcusum_test() and related changepoint detection methods.
6+
#
7+
# Functions:
8+
# - Mfun(): Computes M(k1,...,km) statistic from p. 553
9+
# - M1fun(): Optimized version for at most one changepoint
10+
# - MTfun(): Computes MT statistic from p. 554 or first equation on p. 568
11+
#
12+
# @keywords internal
13+
# @noRd
314

415

516
##### The function for M(k1,...,km) on p. 553:

R/fun_trust.R

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
#Auxiliary functions related to the TRUST algorithm;
2-
#were in the main body of the package until v.5.
1+
# Internal Helper Functions for TRUST Clustering Algorithm
2+
#
3+
# This file contains internal (non-exported) helper functions for the TRUST
4+
# (TRUSTworthy Spatio-Temporal cluster detection) algorithm. These functions
5+
# were previously exported in package versions prior to v.5.
6+
# They are used by BICC(), CSlideCluster(), CWindowCluster(), and related clustering methods.
7+
#
8+
# Functions:
9+
# - CNeighbor(): Identifies E^theta_delta neighbors of time series
10+
# - CHomogeneity(): Checks homogeneity of time series clusters
11+
# - CExpandSlideCluster(): Expands slide-level time series clusters
12+
# - CExpandWindowCluster(): Expands window-level time series clusters
13+
#
14+
# @keywords internal
15+
# @noRd
316

417

518
# ##### Neighborhood of Time Series #####

R/toMlm.R

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
# This is a copy of the code from the package vars by Bernhard Pfaff
2-
# with changes that were not merged to the package
3-
# with the pull request from 2021-08-22
1+
# Internal VAR to MLM Conversion Function (Modified from vars package)
2+
#
3+
# This is a modified copy of toMlm() methods from the vars package by Bernhard Pfaff.
4+
# The modifications were submitted via pull request on 2021-08-22 but were not merged:
45
# https://github.com/bpfaff/vars/pull/10/files
5-
# I.e., subsequent vars v.1.5-6 (2021-09-17) does not include these changes.
6-
# The changes (most of them are marked with "#VL") allow for restricted VAR
7-
# estimation and Granger causality testing using such models.
6+
#
7+
# The vars package v.1.5-6 (2021-09-17) and later versions do not include these changes.
8+
# This modified version is maintained internally to support conversion of restricted
9+
# VAR models to multivariate linear models (MLM) for coefficient estimation and testing.
10+
#
11+
# Key Modifications (marked with "#VL" comments):
12+
# - Support for x$restrictions matrix in varest objects
13+
# - Proper handling of restricted coefficients in conversion to MLM
14+
# - Individual equation fitting respecting coefficient restrictions
15+
#
16+
# @keywords internal
17+
# @noRd
818

919
toMlm <- function(x, ...){
1020
UseMethod("toMlm")

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ library(funtimes)
2323
## Current GitHub version
2424

2525
- Added new function `r_crit()` to compute critical values of correlations.
26+
- In the function `causality_pred()`, added option to turn off automatic lag selection.
2627

2728
## CRAN version 9.1
2829

misc/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Misc Directory
2+
3+
This directory contains experimental, deprecated, or archived code that is not part of the main package.
4+
5+
## Contents
6+
7+
### Archived/Removed Functions
8+
9+
- **TopoCBN.R** - Topological clustering function using Betti numbers. This function was removed from the package in version 8.2 due to removal of the `TDA` package dependency. The implementation is preserved here for reference.
10+
11+
### Experimental/Incomplete Code
12+
13+
- **CRAD.R** and **CRAD.py** - Experimental clustering using robust anomaly detection. This appears to be incomplete/under development and is not currently integrated into the package.
14+
- **CRAD.Rd** - Draft documentation for CRAD function.
15+
16+
### Old Versions
17+
18+
- **causality_predVAR_v0.R** - Previous version of the `causality_predVAR()` function, retained for reference during development.
19+
20+
## Recommendations
21+
22+
1. **CRAD files** - Consider either:
23+
- Completing the implementation and integrating into the package, or
24+
- Removing if the approach was abandoned
25+
26+
2. **TopoCBN.R** - Keep for archival purposes since it was a documented feature removed for dependency reasons. Users may still want to access it.
27+
28+
3. **causality_predVAR_v0.R** - Can be removed once the new version is stable and well-tested.

0 commit comments

Comments
 (0)