教程案例第2周_第1頁
教程案例第2周_第2頁
教程案例第2周_第3頁
教程案例第2周_第4頁
教程案例第2周_第5頁
已閱讀5頁,還剩51頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

Part pdfandPart MethodofPart OLSPart Part PartI.pdfandY= Y=Y= Y=Y= Y=‘bino’orn:numberofp:probabilityof‘poiss’orlambda:-‘unif’ora:lowerB:upper‘norm’ormu:%Bernoulli%N=100 pdf1=pdf(‘bino’,X1,N,p); %Bernoulli分布的pdfcdf1=cdf('bino',X1,N,p); %Bernoulli分布的cdf pdfandcdfforBernoulliNormal%Normal% %mu: %sigma:standarddeviationpdf4=pdf('norm',X4,mu,sigma);cdf4=cdf('norm',X4,mu,sigma);pdfandcdfforNormal%Poisson%lambda=3pdf2=pdf('poiss',X2,lambda);cdf2=cdf('poiss',X2,lambda);%Uniform%U(1,2)pdf3=cdf3=cdf('unif',X3,a,b);PartII.MethodofDataforPartCenterforResearchinSecurityPrices(CRSP)Marketreturn(Rm),value-weightreturnofallCRSPfirmsincorporatedintheUSandlistedontheNYSE,AMEX,orNASDAQthathaveaCRSPsharecodeof10or11atthebeginningofmontht,goodsharesandpricedataatthebeginningoft,andgoodreturndatafort.Matlabhasfunctionsforcomputingthemoments:data=xlsread(‘dataforweek1.xlsx’,‘Sheet2’); %sample %skewness(X,flag),setflag=0tocorrectthebias %kurtosis(X,flag),setflag=0tocorrectthebiasUsingtheOrwecancalculatethemomentsusingthe %Tocorrectthebias,divide(T-1)JarqueBeraJarqueBeratestfor%JB 正態(tài)分布假設(shè)下,JB~c2Matlabhasthefunction“jbtest”as(Notnormal)PartIII.OLSOrdinaryLeastSquares:minimizethesumofsquared Rp- FamaFrenchthreefactorE(Rp)=Rf+

(E(RM)-Rf)+bsSMB+bbRp-Rf=a+bm(E(RM)-Rf)+bsSMB+bbHML+DataforPartIII-DataFamaE.F.,K.R.French,Commonriskfactorsinthereturnsonstocksandbonds,1993,JournalofFinancialEconomics,Vol.33,3-56CenterforResearchinSecurityPrices(CRSP)datalibrary.html1926.07-2015.07,DataSampleRm:marketreturnasinPartRf:one-monthTreasurybillrate(fromIbbotsonSMB=1/3(SmallValue+SmallNeutral+SmallGrowth)-1/3(BigValue+BigNeutral+BigGrowth).HML=1/2(SmallValue+BigValue)-1/2(SmallGrowth+BigGrowth).Rp:Portfolioreturns.Theportfoliosaretheintersectionsof5portfoliosformedonsize(marketequity,ME)and5portfoliosformedontheratioofbookequitytomarketequityCodes:ols xpxi= results.yhat=x*results.beta;results.resid=y-results.yhat;results.sige=sigu/(nobs-nvar);tmp results.tstat=results.beta./(sqrt(tmp)); t統(tǒng)計(jì)量ym=y-mean(y);rsqr1=sigu;rsqr2=ym'*ym;results.rsqr=1.0- %R-Codes:data%OLS%load Codes:theta_capm %%Multivariate:Fama-FrenchThreeFactorModeltheta_ff=myols(y,Z);beta_capm=0.2827;tstats_capm=2.5164;58.7183(bothR2_capm=beta_ff=0.0473;0.9718;0.8268;tstats_ff=0.9094;94.3476;49.0097;(ThethreefactorsareallR2_ff=T

? tn(q)

Null

H0:q=r(b)=??'?? r(b?)' fic2Codes:t- xpxi= results.yhat=x*results.beta;results.resid=y-results.yhat;results.sige=sigu/(nobs-nvar);tmp Codes:Waldtest%WaldtestforCAPM(univariate)EstCov=sigma2*inv(X'*X);wald=(R*theta_capm.beta-Q)'*inv(R*EstCov*R')*(R*theta_capm.beta-Q);pvalue=1-chi2cdf(wald,1); h=1(rejectthenull);pValue=0;Wald=3454(squareoft-%Asymptoticdistribution:chi2 pdf5=title('Chisquarepdf');Codes:WaldtestNull b1=b2=b3=%Hypothesis(dataloadingisthesameasinPartIII,%WaldtestforFF(multivariate)theta_ff=myols(y,X);R=[0100;0010;000Q=Codes:Waldtestsigma2=EstCov=sigma2*(X'*X)^(-1); %EstCov= wald=(R*beta_ff-Q)'*inv(R*EstCov*R')*(R*beta_ff-Q);pvalue=1-chi2cdf(wald,3);wald= pvalue=2.8283e-04(Rejectthe pdf=pdf('chi2',X,nu);f(y;q)

Rp- =a+bm(E(RM)-Rf)+bsSMB+bbHML+Thefunctionsareallforminimization,andifwewanttomaximizeafunction,wecanminimizethenegativevalue.[x,fval,exitflag]=fminunc(@fun,x0,X0:initialfval:minimumvalueoftheexitflag:theflagofexit,>0meansoptions選項(xiàng)結(jié)構(gòu) [[x,fval,exitflag]=fminsearch(@fun,x0,fminsearchissimilarwithfminsearchtakesthesimplexmethod單純形法andthusismoreefficientthanfminunc.[x,fval,exitflag]=fminbnd(@fun,x1,xn,Findtheminimumupon[x1,OptimizationinMatlabMLE:PoissonAsampleofT=4observations,yt={6,2,3,1},isdrawnfromthePoissondistributionf(y;q)

DerivetheloglikelihoodfunctionlnLT(q)Drawthegraphsfortheloglikelihoodfunction,theGradientfunctionandtheHessianfunction.Codes:Main Defineafunction[theta_hat,g,h]=syms ln_L=mean(y*log(theta)-theta-log(factorial(y))); %loglikelihoodfunctionG=diff(ln_L); %gradientfunctiontheta_hat= %SetG=0togettheta_hat=Codes:Plotlog-likelihoodtheta_1=0.01:0.01:15;G1=zeros(length(theta_1),1);H1=zeros(length(theta_1),1);fori=lnL1(i)=mean(y*log(theta_1(i))-theta_1(i)-log(factorial(y)));G1(i)=mean(y)/theta_1(i)-1;H1(i)=-axis([-115-20Codes:PlotGradientandaxis([-115-20200])axis([-0.515-3Codes:AssumetheerrorMain%MLE%load 2.Codes:Definethefunction[theta,vcov]=t=x=[ones(t,1)x1x2%Estimatethetheta_0=[0.9094;94.3476;49.0097;37.3852; %Initialoptions=theta=fminunc(@(theta)%Computethecovariancee=y-theta(1)-x1*theta(2)-x2*theta(3)-x3*theta(4);sig2hat=e'*e/t; =2.Codes:Definethel

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論