(*LNN and StableM are available on the Software Page*)
Needs["LNN`","C:\\Mathematica 6\\LogNormalStable\\LNN.m"];
LogReturn[data_]:=Differences[Log[N[data]]];
EmpiricCDFList[data_] := Block[{prob,sel,del},
					
					prob= Table[(i-0.5)/Length[data],{i,Length[data]}];
					Transpose[Join[{Sort[data]},{prob}]]];
DisplayLogStableFit1[data_,parm_]:=Module[{clist,lt,rt,trt,lp1,lp2,lp3,lp4,lp5,nmn,nstd},
clist=EmpiricCDFList[data];
	lt = Select[clist,#[[1]]<0&];
	rt= Select[clist,#[[1]]>0&];
	trt=Transpose[rt];
lp1=ListLogLogPlot[Abs[lt],PlotStyle->Blue,PlotRange->All];
	lp2=ListLogLogPlot[Transpose[{trt[[1]],1- trt[[2]]}],PlotStyle->Red,PlotRange->All];

lp5= LogLogPlot[1-LNNCDF[x,parm[[1]],parm[[2]],parm[[3]]],{x,0.0001,-2Min[data]},PlotStyle->Green,PlotRange->All,PerformanceGoal->"Speed"];
Show[lp1,lp2,lp5,PlotLabel->"Log Log Left Tail Blue, Right Red, (Lognormal Normal Green)",AspectRatio->Automatic,PlotRange->All,Frame->True]];
Clear[paramgen];
paramgen[ticker_]:=Module[{data,lr,pp},
data=FinancialData[ticker,"Close",Take[DateList[],3]-{10,0,0}];
lr= LogReturn[data[[All,2]]];
pp=LNNFit[lr];
If[pp[[1]]>0&&pp[[2]]>0,Null,pp=LNNParameters[lr]];

Print[ticker,"  ",First[data],"  ",Last[data]];If[pp[[1]]>0&&pp[[2]]>0,Print[Quiet[DisplayLogStableFit1[lr,pp]]]];
pp];

Fit Gallery

The graphics below show the lognormal-normal mixture (LNN) fits to the logarithmic returns to the stocks in the Dow Jones Industrial Average for ten years of data.  The fits are shown for the empirical density data points and the LNN distribution function in green, with the same configuration we have been using for stable distributions.  The ticker symbol, start date, and end date for the data along with the starting and ending price for the time-series of the fit are shown for each plot.  In the log-log plot every tail point in the ten-year data set is represented.

ticklist=FinancialData["DJI","Members"];
lnnparms=Quiet[paramgen/@ticklist];

The LNN fit parameters are shown for each ticker.

TableForm[Transpose[Join[{ticklist},Transpose[lnnparms]]],TableHeadings->{None,{"Ticker","γ","σ","δ"}},TableSpacing->{1,5}]

The lognormal density plots of the {log(γ), σ} are shown for each stock.  This presents a two dimensional visualization of risk.

Plot[Evaluate[PDF[LogNormalDistribution[Log[#[[1]]],#[[2]]],x]&/@lnnparms],{x,0,0.04},Frame->True,PlotLabel-> "A Gallery of Risk\nThe Lognormal Plots\nFor the DJIA Stocks"]

txcolor=RGBColor[181/255,18/255,27/255];
t1 = Graphics[Text[Hyperlink[Framed[Style["Financial Home", {txcolor, Bold, Larger}]], "../map/Overview.html"], {-5, 0}]];
t2 = Graphics[Text[Hyperlink[Framed[Style["Next", {txcolor, Bold, Larger}]],  "../lnn3/LNNRV.html"], {0, -0.5}]];
t3 = Graphics[Text[Hyperlink[Framed[Style["Download Notebook", {txcolor, Bold, Larger}]], "../lnn2/FitGallery.nb"], {5, 0}]];
t4 = Graphics[Text[Hyperlink[Framed[Style["Previous", {txcolor, Bold, Larger}]], "../lnn1/LNNRisk.html"], {0, 0.5}]];

Show[ t1, t2, t3,t4, ImageSize -> 500]
CellPrint[TextCell["\n\n© Copyright " <>ToString[DateList[][[1]]]<>" mathestate    "<>DateString[DateList[],"DateShort"], "Text"]]

© Copyright 2008 mathestate    Wed 18 Jun 2008