The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
The ‘REN’ package provides a set of tools for performing portfolio optimization using various regularization and ensemble learning methods. The package is designed to produce stable out-of-sample return predictions, particularly in the presence of strong correlations between assets. The core functions enable users to prepare data, set up parallel processing, and perform in-depth portfolio analysis.
To install the ‘REN’ package, you can use the following command:
# Install the development version from GitHub
::install_github("bonsook/REN") devtools
setup_parallel()
This function sets up parallel processing to speed up the computation of portfolio optimization tasks.
num_cores
: The number of cores to use for parallel
processing. Default is 7.# Set up parallel processing with the default number of cores
<- setup_parallel()
cl
# Set up parallel processing with 4 cores
<- setup_parallel(num_cores = 4)
cl
# Stop the cluster after completing the analysis
stopCluster(cl)
prepare_data()
This function prepares the input data for portfolio optimization by structuring it into the required format and calculating necessary metrics.
data
: A data frame containing the asset returns and
other relevant metrics.# Prepare the data for analysis
<- read.csv("data/FF25.csv")
ff25
# Define the date column index, start date, and end date
<- 1 # Update this based on your data
date_column_index <- "19990101" # Adjust as needed
start_date <- "20231231" # Adjust as needed
end_date
# Prepare the data for analysis
<- prepare_data(ff25, date_column_index, start_date, end_date)
data_prep <- data_prep$x
x <- data_prep$mon
mon <- data_prep$count
count <- data_prep$Date Date
perform_analysis()
This function performs portfolio analysis using various methods such as Mean-Variance (MV), James-Stein (JM), LASSO, Ridge Regression, and Equal Weighting (EW). It calculates portfolio weights, turnover, returns, Sharpe ratios, volatility, and maximum drawdown for each method.
x
: A numeric matrix where each column represents asset
returns and rows represent time periods.mon
: A numeric vector representing the number of months
since the start date for each time period.count
: A numeric vector indicating the number of
entries per month.Date
: A vector of Date objects representing the dates
of the time periods.num_cores
: The number of cores to use for parallel
processing. Default is 7.# Perform the portfolio analysis
<- perform_analysis(x, mon, count, Date, num_cores)
result
# Accessing the results
<- result$cumulative_return_plot
cumulative_return_plot <- result$turnover_mean
turnover_mean <- result$sharpe_ratio
sharpe_ratio <- result$volatility
volatility <- result$max_drawdown
max_drawdown
# Display the cumulative return plot
print(cumulative_return_plot)
Here’s an example workflow using the ‘REN’ package:
# Step 1: Set up parallel processing
<- setup_parallel(num_cores = 4)
cl
# Step 2: Prepare the data
<- prepare_data(ff25, date_column_index, start_date, end_date)
data_prep <- data_prep$x
x <- data_prep$mon
mon <- data_prep$count
count <- data_prep$Date
Date
# Step 3: Perform portfolio analysis
<- perform_analysis(x, mon, count, Date, num_cores)
result
# Step 4: Plot and interpret the results
print(results$cumulative_return_plot)
print(results$turnover_mean)
print(results$sharpe_ratio)
# Remember to stop the cluster after completing the analysis
stopCluster(cl)
Contributions to the ‘REN’ package are welcome. Please feel free to submit a pull request or report any issues you encounter.
This package is licensed under the MIT License.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.