-
大小: 2.18MB文件类型: .zip金币: 1下载: 0 次发布日期: 2023-09-07
- 语言: Matlab
- 标签: MATLAN 三因子 fama-French
资源简介
该文件是基于fama-French三因子模型而编写的MATLAB程序代码。里面有详细说明和PDF文档
代码片段和文件信息
%FFestimateCAPM Estimate rolling parameters for CAPM 1-factor model.
clear all
% Step 1 - load in raw data and set up list of Fama & French factors
load FFUniverseCAPM
% Step 2 - convert total return prices to total returns
Returns = (CAPMUniverse - lagts(CAPMUniverse1)) ./ lagts(CAPMUniverse1);
% Step 3 - trim date range to match date range of factor returns
Returns = Returns(all(isfinite(fts2mat(extfield(Returns CAPMFactorList)))2));
% Step 4 - get information about data
SeriesList = fieldnames(Returns 1);
AssetList = setdiff(SeriesList CAPMFactorList);
NumSeries = numel(SeriesList);
NumAssets = numel(AssetList);
% Step 5 - primary controls
TMonth = 9; % terminal month for each historical estimation period
Window = 5; % historical estimation period in years
MaxNaNs = 4*260; % max number of daily NaNs in an estimation period
% Step 6 - set up date math
StartYear = year(Returns.dates(1));
StartMonth = month(Returns.dates(1));
EndYear = year(Returns.dates(end));
EndMonth = month(Returns.dates(end));
if StartMonth > TMonth
StartYear = StartYear + 1;
end
if EndMonth < TMonth
EndYear = EndYear - 1;
end
if (EndYear - StartYear) < Window
error(‘Insufficient data to perform analysis.‘);
end
NumPeriods = EndYear - StartYear - Window + 1;
% Step 7 - final setup
AnalysisPeriod = NaN(NumPeriods1);
CAPMAlpha = NaN(NumAssets NumPeriods);
CAPMBeta = NaN(NumAssets NumPeriods);
CAPMSigma = NaN(NumAssets NumPeriods);
CAPMStdAlpha = NaN(NumAssets NumPeriods);
CAPMStdBeta = NaN(NumAssets NumPeriods);
CAPMLLF = NaN(NumPeriods1);
CAPMDoF = NaN(NumPeriods1);
% Step 8 - main loop
TYear = StartYear + Window; % initial terminal year
for K = 1:NumPeriods
% Step 8a - get start and end dates for current analysis period
StartDate = datenum(TYear - WindowTMontheomday(TYearTMonth)) + 1;
EndDate = datenum(TYearTMontheomday(TYearTMonth));
%fprintf(1‘Period %2d: Target Range [%s - %s]\n‘Kdatestr(StartDate1)datestr(EndDate1));
% Step 8b - locate actual start and end dates in the data
StartIndex = find(Returns.dates >= StartDate1‘first‘);
EndIndex = find(Returns.dates <= EndDate1‘last‘);
AnalysisPeriod(K) = Returns.dates(EndIndex);
% Step 8c - determine active assets for current analysis period
Active = true(NumAssets1);
for i = 1:NumAssets
TestActive = sum(~isfinite(fts2mat(Returns.(AssetList{i})(StartIndex:EndIndex))));
if TestActive > MaxNaNs;
Active(i) = false;
end
end
NumActive = sum(Active);
fprintf(1‘ Points %5d:%5d: Dates = [%s : %s] Active Assets = %d\n‘ ...
StartIndexEndIndexdatestr(Returns.dates(StartIndex)1) ...
datestr(Returns.dates(EndIndex)1)NumActive);
% Step 8d - set up regression with active assets over current date range
Dates = Returns.dates(StartIndex:EndIndex);
AssetData = fts2mat(Returns.(AssetList));
AssetData = AssetData(StartIndex
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 751758 2016-09-01 11:05 webinar\FFUniverse.mat
文件 4491 2016-09-01 11:05 webinar\FFestimateCAPM.m
文件 5253 2016-09-01 11:05 webinar\FFestimateFF.m
文件 1602548 2016-09-01 11:05 webinar\Using ML to Develop Asset Pricing-111606.pdf
文件 2424 2016-09-01 11:05 webinar\readme.txt
文件 15699 2016-09-01 11:05 webinar\FFwebinar.m
文件 327 2016-09-01 11:05 webinar\erratum.txt
文件 1526 2016-09-01 11:05 license.txt
- 上一篇:基于Meanshift的单目标跟踪
- 下一篇:火车时刻表数据库2008年
评论
共有 条评论