download_data_stambaugh_yuan: Download and Process Stambaugh-Yuan Mispricing Factors

View source: R/download_data_stambaugh_yuan.R

download_data_stambaugh_yuanR Documentation

Download and Process Stambaugh-Yuan Mispricing Factors

Description

Downloads and processes the mispricing factor data of Stambaugh and Yuan (2017) from Stambaugh's data library. The four-factor model (M4) combines the market and size factors with two mispricing factors, mgmt (management) and perf (performance). The function downloads the requested frequency, aligns the date, renames the columns to the package conventions, and optionally filters the data based on a provided date range.

Usage

download_data_stambaugh_yuan(
  dataset = "monthly",
  start_date = NULL,
  end_date = NULL,
  url = "https://finance.wharton.upenn.edu/~stambaug/"
)

Arguments

dataset

The data frequency to download, either "monthly" (the default) or "daily".

start_date

Optional. A character string or Date object in "YYYY-MM-DD" format specifying the start date for the data. If not provided, the full dataset is returned.

end_date

Optional. A character string or Date object in "YYYY-MM-DD" format specifying the end date for the data. If not provided, the full dataset is returned.

url

The base URL from which to download the dataset files. The file name (M4.csv or M4d.csv) is appended based on dataset.

Details

Returns are already expressed as plain numeric (decimal) values in the source data, so no rescaling is applied. The source files currently end in December 2016; a requested date range that lies entirely outside the available data emits a warning and returns an empty tibble.

Value

A tibble with the columns date (aligned to the beginning of the month for monthly data), mkt_excess (the market excess return), smb (size), mgmt (the management mispricing factor), perf (the performance mispricing factor), and risk_free (the risk-free rate). All returns are plain numeric (decimal) values, filtered by the specified date range if start_date and end_date are provided.

References

Stambaugh, R. F., & Yuan, Y. (2017). Mispricing factors. Review of Financial Studies, 30(4), 1270-1315. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1093/rfs/hhw107")}

See Also

Other download functions: download_data(), download_data_constituents(), download_data_factors_ff(), download_data_factors_q(), download_data_fred(), download_data_huggingface(), download_data_jkp(), download_data_macro_predictors(), download_data_osap(), download_data_pastor_stambaugh(), download_data_risk_free(), download_data_stock_prices(), download_factor_library_grid(), download_factor_library_ids()

Examples


  download_data_stambaugh_yuan(
    start_date = "2015-01-01", end_date = "2016-12-31"
  )
  download_data_stambaugh_yuan(
    dataset = "daily", start_date = "2016-01-01", end_date = "2016-12-31"
  )


tidyfinance documentation built on July 3, 2026, 1:09 a.m.