factor-models

Estimate Fama-French factor models with OLS regression and GRS tests.

33|6|Updated Mar 17, 2026
One-click install
npx skills add https://github.com/xjtulyc/awesome-rosetta-skills --skill factor-models-xjtulyc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: factor-models
Source: https://github.com/xjtulyc/awesome-rosetta-skills/tree/main/skills/08-finance-academic/factor-models
Command: npx skills add https://github.com/xjtulyc/awesome-rosetta-skills --skill factor-models-xjtulyc

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires numpy, pandas, pandas-datareader, statsmodels, scipy, matplotlib, yfinance.

What problem does it solve?

It helps you measure and explain asset returns by estimating factor loadings and risk-adjusted performance (Jensen’s alpha) using academic factor models.

Core Features & Use Cases

  • Download and prepare factor data: Pulls Fama-French factors (e.g., 3/5-factor, momentum, q-factor) from the Ken French Data Library and formats them into usable time series.
  • Run OLS factor regressions: Estimates alpha and factor betas with support for intercept-based alpha and robust inference.
  • Validate pricing performance: Computes rolling factor loadings and applies the Gibbons-Ross-Shanken (GRS) test to assess joint pricing errors across multiple assets.
  • Use cases: Compare ETFs or portfolios against Carhart/Fama-French models, study changing exposures via rolling betas, and test whether a set of assets’ alphas are jointly zero.

Quick Start

Run the factor regression of your portfolio’s excess returns against the Fama-French 5-factor data for the same date range to obtain annualised alpha, t-stats, p-values, and factor betas.

Frequently Asked Questions about factor-models

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I estimate Fama-French factor alphas and betas for my portfolio?

To estimate Fama-French factor alphas, run an OLS time-series regression of your portfolio excess returns against downloaded factor returns. The model outputs annualized Jensen's alpha, factor betas, t-stats, and p-values using robust covariance matrices.

Can I test whether multiple assets' pricing errors are jointly zero using the GRS test?

Yes, the Gibbons-Ross-Shanken (GRS) test evaluates joint pricing errors across multiple assets. It computes GRS statistics and p-values to determine if alphas from the factor regressions are collectively significantly different from zero.

How do I calculate rolling factor loadings to study changing exposures over time?

Rolling factor loadings are computed by applying OLS time-series regression across a moving window over your aligned excess returns and factor data. This tracks how asset exposures to factors like momentum or size change dynamically.

What data format is needed to run asset pricing factor regressions?

Factor regressions require structured inputs: an aligned T×N matrix of portfolio excess returns and a T×K matrix of factor returns. Data is pulled via pandas-datareader or yfinance and aligned by date before estimating alpha and beta.

Does this model support robust inference for OLS regression coefficients?

Yes, the OLS time-series regression computes alpha and factor betas with robust covariance estimation. This ensures reliable t-statistics and p-values for performance evaluation against academic factor models.

What is the best way to evaluate ETF performance against the Carhart or Fama-French 5-factor model?

The best way to evaluate ETF performance is downloading Fama-French factors, aligning them with ETF excess returns, and running an OLS regression. This yields risk-adjusted alpha and factor betas to compare performance against benchmarks.