View source: R/implement_portfolio_sort.R
| implement_portfolio_sort | R Documentation |
A convenience wrapper that combines sample construction filtering and
portfolio return computation into a single call. Equivalent to calling
filter_sorting_data() followed by compute_portfolio_returns().
implement_portfolio_sort(
data,
sorting_variables,
sorting_method,
rebalancing_month = NULL,
portfolio_sort_options,
breakpoint_function_main = compute_breakpoints,
breakpoint_function_secondary = compute_breakpoints,
min_portfolio_size = 1L,
cap_weight = 0.8,
data_options = NULL,
quiet = FALSE
)
data |
A data frame containing the stock-level panel data. |
sorting_variables |
A character vector of one or two column names to sort portfolios on. |
sorting_method |
A string specifying the sorting method:
|
rebalancing_month |
An optional integer specifying the month in which
portfolios are rebalanced annually. |
portfolio_sort_options |
A list of class
|
breakpoint_function_main |
The function used to compute breakpoints for
the main sorting variable. Defaults to |
breakpoint_function_secondary |
The function used to compute breakpoints
for the secondary sorting variable. Defaults to |
min_portfolio_size |
An integer specifying the minimum number of
firms in the reported portfolio cross-section on a given date. Defaults
to |
cap_weight |
A numeric between 0 and 1 specifying the quantile at which
portfolio weights are capped for the capped value-weighted return.
Defaults to |
data_options |
A list of class |
quiet |
A logical indicating whether informational messages should be
suppressed. Defaults to |
A data frame of portfolio returns as returned by
compute_portfolio_returns().
Other portfolio functions:
assign_portfolio(),
breakpoint_options(),
compute_breakpoints(),
compute_long_short_returns(),
compute_portfolio_returns(),
data_options(),
filter_options(),
filter_sorting_data(),
portfolio_sort_options()
set.seed(123)
data <- data.frame(
permno = 1:500,
date = rep(
seq.Date(
from = as.Date("2020-01-01"),
by = "month",
length.out = 100
),
each = 10
),
mktcap_lag = runif(500, 100, 1000),
ret_excess = rnorm(500),
prc_adj = runif(500, 0.5, 50),
size = runif(500, 50, 150)
)
implement_portfolio_sort(
data = data,
sorting_variables = "size",
sorting_method = "univariate",
portfolio_sort_options = portfolio_sort_options(
filter_options = filter_options(
min_stock_price = 1
),
breakpoint_options_main = breakpoint_options(n_portfolios = 5)
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.