# \donttest{
# Generate random returns for 20 assets over 100 periods
set.seed(123)
returns <- matrix(rnorm(20*100), nrow = 100, ncol = 20)
# Initialize object
tv <- TVMVP$new()
tv$set_data(returns)
# Run Expanding TV-MVP optimization
results <- expanding_tvmvp(
obj = tv,
initial_window = 50,
rebal_period = 20,
max_factors = 3,
return_type = "daily",
kernel_func = epanechnikov_kernel,
rf = NULL
)
# R6 method interface
results <- tv$expanding_tvmvp(
initial_window = 50,
rebal_period = 20,
max_factors = 3,
return_type = "daily",
rf = NULL)
# Print summary
print(results)
# Plot cumulative log excess returns
plot(results)
# }
Run the code above in your browser using DataLab