R Under development (unstable) (2025-10-07 r88904 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > # Clean environment and load libraries > rm(list = ls()) # Clear environment to avoid conflicts > > # Source files > library(MixStable) Attaching package: 'MixStable' The following object is masked from 'package:graphics': clip > > # 📊 Generate synthetic data using explicit package reference > X <- stabledist::rstable(1200, alpha = 1.2, beta = 0.5, gamma = 1, delta = 3, pm = 1) > u_vals <- seq(0.1, 1, length.out = 10) > > # Add some diagnostic information > cat("Data summary:\n") Data summary: > cat("Length:", length(X), "\n") Length: 1200 > cat("Range:", range(X), "\n") Range: -107.2666 84.8947 > cat("Mean:", mean(X), "SD:", sd(X), "\n") Mean: 2.307474 SD: 7.512991 > cat("u_vals:", u_vals, "\n\n") u_vals: 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 > > # 🧮 Estimate parameters with error handling > safe_estimate <- function(func, data, u, name) { + cat("Running", name, "...\n") + result <- tryCatch({ + func(data, u) + }, error = function(e) { + cat("Error in", name, ":", e$message, "\n") + return(NULL) + }, warning = function(w) { + cat("Warning in", name, ":", w$message, "\n") + suppressWarnings(func(data, u)) + }) + return(result) + } > > # Run estimations with error handling > result_CDF <- safe_estimate(CDF, X, u_vals, "CDF") Running CDF ... > result_ecf_regression <- safe_estimate(ecf_regression, X, u_vals, "ECF Regression") Running ECF Regression ... > result_robust_ecf_regression <- safe_estimate(robust_ecf_regression, X, u_vals, "Robust ECF Regression") Running Robust ECF Regression ... > result_fit_stable_ecf <- safe_estimate(fit_stable_ecf, X, u_vals, "Fit Stable ECF") Running Fit Stable ECF ... > result_ecf <- safe_estimate(estimate_stable_recursive_ecf, X, u_vals, "Recursive ECF") Running Recursive ECF ... > result_kernel <- safe_estimate(estimate_stable_kernel_ecf, X, u_vals, "Kernel ECF") Running Kernel ECF ... > result_weighted <- safe_estimate(estimate_stable_weighted_ols, X, u_vals, "Weighted OLS") Running Weighted OLS ... > result_cdf_ <- safe_estimate(estimate_stable_from_cdf, X, u_vals, "CDF-based") Running CDF-based ... > > # 📋 Display results > display_result <- function(result, name) { + cat("\n=== ", name, " Results ===\n") + if (is.null(result)) { + cat("Failed to compute\n") + } else { + print(result) + } + } > > display_result(result_CDF, "CDF") === CDF Results === $alpha [1] 1.203984 $beta [1] 0.5138119 $gamma (Intercept) 0.9761938 $delta [1] 1.414859 > display_result(result_ecf_regression, "ECF Regression") === ECF Regression Results === $alpha [1] 1.252024 $beta [1] 0.5152877 $gamma [1] 1.019098 $delta [1] 1.424009 > display_result(result_robust_ecf_regression, "Robust ECF Regression") === Robust ECF Regression Results === $alpha [1] 1.276817 $beta [1] 0.5253516 $gamma [1] 1.015998 $delta [1] 1.424405 > display_result(result_fit_stable_ecf, "Fit Stable ECF") === Fit Stable ECF Results === $alpha [1] 1.252024 $beta [1] 0.5152877 $gamma [1] 1.019098 $delta [1] 1.424009 > display_result(result_ecf, "Recursive ECF") === Recursive ECF Results === $alpha [1] 1.1337 $beta [1] 0.5118998 $gamma [1] 0.9652437 $delta [1] 1.406919 > display_result(result_kernel, "Kernel ECF") === Kernel ECF Results === $alpha [1] 1.156146 $beta [1] 0.4944459 $gamma [1] 0.9676924 $delta [1] 1.412266 > display_result(result_weighted, "Weighted OLS") === Weighted OLS Results === $alpha [1] 1.1337 $beta [1] 0.5296545 $gamma [1] 0.9652437 $delta [1] 1.405639 > display_result(result_cdf_, "CDF-based") === CDF-based Results === $alpha [1] 1.203984 $beta [1] -1 $gamma [1] 0.9761938 $delta [1] 1.417174 > > # Compare with true parameters > cat("\n=== True Parameters ===\n") === True Parameters === > cat("alpha: 1.2, beta: 0.5, gamma: 1, delta: 3\n") alpha: 1.2, beta: 0.5, gamma: 1, delta: 3 > > proc.time() user system elapsed 10.14 1.21 11.34