R Under development (unstable) (2025-09-21 r88861 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 > library(ggplot2) > > # 🎲 Generate data > set.seed(123) > X <- rnorm(300) > u_vals <- seq(-10, 10, length.out = 200) > > # 🔍 Compute ECF using recursive method > ecf_result <- ecf_fn(X, u_vals, method = "recursive") > yr <- ecf_result$magnitude > > # 🔍 Compute ECF using kernel method > ecf_result1 <- ecf_fn(X, u_vals, method = "kernel") > yr1 <- ecf_result1$magnitude > > # 📊 Plot kernel-smoothed ECF > df_plot1 <- data.frame(u = u_vals, magnitude = yr1) > > p1 <- ggplot(df_plot1, aes(x = u, y = magnitude)) + + geom_line(color = "blue") + + labs( + title = "Empirical Characteristic Function (Kernel Smoothed)", + x = "u (frequency)", + y = "|ECF(u)|" + ) + + theme_minimal() > > # 📊 Plot recursive-smoothed ECF > df_plot <- data.frame(u = u_vals, magnitude = yr) > > p <- ggplot(df_plot, aes(x = u, y = magnitude)) + + geom_line(color = "red") + + labs( + title = "Empirical Characteristic Function (Recursive Smoothed)", + x = "u (frequency)", + y = "|ECF(u)|" + ) + + theme_minimal() > > # Show plots > print(p1) > print(p) > > # Save the plots > ggsave("ecf_kernel_plot.png", p1, width = 10, height = 5, dpi = 300) > ggsave("ecf_recursive_plot.png", p, width = 10, height = 5, dpi = 300) > > proc.time() user system elapsed 16.95 1.67 18.62