Learn R Programming

DLFM (version 0.2.2)

Dfactor.tests: Distributed Factor Model Testing with Wald, GRS, PY tests and FDR control

Description

Performs comprehensive factor model testing in distributed environment across multiple nodes, including joint tests (Wald, GRS, PY), individual asset t-tests, and False Discovery Rate control.

Usage

Dfactor.tests(ret, fac, n1, K, q.fdr = 0.05)

Value

A list containing the following components:

alpha_list

List of alpha vectors from each node

tstat_list

List of t-statistics from each node

pval_list

List of p-values from each node

Wald_list

List of Wald test statistics from each node

p_Wald_list

List of p-values for Wald tests from each node

GRS_list

List of GRS test statistics from each node

p_GRS_list

List of p-values for GRS tests from each node

PY_list

List of Pesaran and Yamagata test statistics from each node

p_PY_list

List of p-values for PY tests from each node

reject_fdr_list

List of logical vectors indicating significant assets after FDR correction from each node

power_proxy_list

List of number of significant assets after FDR correction from each node

combined_alpha

Combined alpha vector from all nodes

combined_pval

Combined p-value vector from all nodes

combined_reject_fdr

Combined FDR rejection vector from all nodes

total_power_proxy

Total number of significant assets across all nodes after FDR correction

Arguments

ret

A T × N matrix representing the excess returns of N assets at T time points.

fac

A T × K matrix representing the returns of K factors at T time points.

n1

The number of assets allocated to each node

K

The number of nodes

q.fdr

The significance level for FDR (False Discovery Rate) testing, defaulting to 5%.

Examples

Run this code
set.seed(42)
T <- 120
N <- 100  # Larger dataset for distributed testing
K_factors <- 3
fac <- matrix(rnorm(T * K_factors), T, K_factors)
beta <- matrix(rnorm(N * K_factors), N, K_factors)
alpha <- rep(0, N)
alpha[1:10] <- 0.4 / 100  # 10 non-zero alphas
eps <- matrix(rnorm(T * N, sd = 0.02), T, N)
ret <- alpha + fac %*% t(beta) + eps

# Distributed testing with 4 nodes, each handling 25 assets
results <- Dfactor.tests(ret, fac, n1 = 25, K = 4, q.fdr = 0.05)

# View combined results
cat("Total significant assets after FDR:", results$total_power_proxy, "\n")
cat("Combined results across all nodes:\n")
print(summary(results$combined_alpha))

Run the code above in your browser using DataLab