{ From user Lonnie, Model Market_volatility_hy at 15-Jul-2010 11:57:41 AM }
Softwareversion 4.2.3
{ System Variables with non-default values: }
Samplesize := 1000
Sampletype := 1
Usetable := 0
Numberformat Run: 2,I,4,2,0,0,4,1,$,0,"ABBREV",0
{!40000|Att_contlinestyle Run: 0}
Typechecking := 1
Checking := 1
Saveoptions := 2
Savevalues := 0
{!40000|Att_contlinestyle Graph_primary_valdim: 1}
{!40000|Att_contlinestyle Graph_pdf_valdim: 6}
{!40000|Att_contlinestyle Graph_cdf_valdim: 1}
Model Market_volatility_hy
Title: Market Volatility Hypothesis
Description: Model for User Group Webinar on Hypothesis Testing.~
~
This contains actual S&P 500 data for a set of dates randomly selected from the previous decade, which are then used to test the hypothesis that market volatility varies with day-of-week.~
~
Exercise: Compute the p-value for the hypothesis that the daily volatility in the S&P index varies with the day of the week. (For example, maybe Wednesdays are more volatile than Tuesdays, etc.) A p-value of 0.05 or less would indicate that this sampled data provides statistically significant support for the hypothesis.
Author: Lonnie
Date: Wed, Jul 14, 2010 11:59 AM
Saveauthor: Lonnie
Savedate: Thu, Jul 15, 2010 11:57 AM
Defaultsize: 48,24
Diagstate: 2,5,4,711,466,17
Windstate: 2,309,136,546,424
Fontstyle: Arial, 15
Fileinfo: 0,Model Market_volatility_hy,2,2,0,0,W:\Training\User Group Webinars\Hypothesis Test S&P Volatility solutions.ana
Index Day_num
Title: Day Num
Definition: 1..100
Nodelocation: 96,56,1
Nodesize: 48,24
{!40000|Att_previndexvalue: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100]}
Index Day_of_week
Title: Day of Week
Definition: { To make these labels language independent, I'm generating the list with an expression }~
DatePart( 12-Jul-2010 + (0..4), "WWW")
Nodelocation: 96,112,1
Nodesize: 48,24
Constant Trading_date
Title: Trading Date
Definition: Table(Day_Num)(35105,35125,35126,35138,35153,35271,35356,35361,35385,35402,35425,35437,35467,35495,35537,35552,35565,35775,35809,35810,35846,35872,35885,35990,36042,36055,36186,36230,36243,36327,36410,36455,36491,36526,36529,36607,36610,36630,36673,36677,36729,36806,36832,36887,36897,36978,37027,37121,37229,37260,37323,37372,37391,37477,37489,37498,37517,37548,37581,37593,37600,37637,37666,37698,37701,37824,37901,37929,37947,37964,38128,38164,38185,38192,38217,38218,38279,38308,38331,38447,38463,38468,38492,38518,38577,38587,38603,38605,38638,38647,38659,38661,38674,38707,38709,38721,38728,38860,38883,38889)
Nodelocation: 216,56,1
Nodesize: 48,24
Valuestate: 2,617,4,467,689,0,MIDM
Numberformat: 2,DD,1,2,0,0,4,0,$,0,"LONG",0
Variable Trading_day
Title: Trading Day
Definition: DatePart(Trading_date,"WWW")
Nodelocation: 336,56,1
Nodesize: 48,24
Variable Count_by_day
Title: Count by day
Definition: Aggregate(1,Trading_day,Day_num,Day_of_week)
Nodelocation: 216,112,1
Nodesize: 48,24
Valuestate: 2,432,240,416,303,0,MIDM
Reformval: [Trading_date,Day_of_week]
Variable Volatility_by_day
Title: Volatility by day
Definition: Aggregate(Price_change,Trading_day,Day_num,Day_of_week,type:"SDeviation") * sqrt(Trading_days_per_yea)
Nodelocation: 336,176,1
Nodesize: 48,24
Valuestate: 2,662,26,298,215,0,MIDM
Numberformat: 2,%,4,2,0,0,4,1,$,0,"ABBREV",0
Constant Price_change
Title: Price change
Units: %
Description: This is the percentage change in the S&P index in price for the indicated day, measured as the ~
(closing_price - opening_price) / opening_price
Definition: Table(Day_num)(~
-0.0209693470635151,1.8634125827478m,0.0198370194534507,0.0242725232682191,-0.0136557685678678,-0.014954526033083,0.03474328120226791,1.683646419923m,-3.3519878745481m,7.4438479903891m,0.0104395562618329,-1.9178187699773m,-8.408146362385899m,6.452384750359m,0.038890427165404,-0.0148726162391612,0.0284527468305801,272.7048805376u,6.8340931650284m,-0.0162451251537704,-0.0155103007340753,4.0667496031916m,-740.8117553754u,-3.7551959539392m,-0.0159503022162525,-4.6478615257807m,-0.0161597399582075,4.3210570354552m,0.012161114518126,910.224192176u,0.010035343992011,3.3095228852053m,-236.1944352591u,-3.0937477516369m,0.0123953521939954,-1.3237173635202m,-1.0187614385273m,593.8821276934u,-535.1027397259u,464.0039975729u,-9.700594434921999m,-7.5266439658603m,0.0111981884763034,7.1540019254389m,-1.4311089410636m,-7.596144020165601m,6.957252785903501m,566.0284490821u,-2.3634868941095m,15.705243981u,-4.8808341220365m,3.3016446940041m,-1.8694476631905m,4.8114906930442m,1.0019113385535m,-329.6913935212u,-2.6718741721353m,1.2143912680877m,2.4239140508593m,8.914059870978701m,2.2910888701314m,-803.2016315470001u,1.140775865031m,0.0108944085943977,-348.4223436281u,4.8955060427884m,-2.5248793775819m,-2.2847882253703m,0.0162808086793359,7.2087754383401m,2.5308628660584m,-4.0666874415704m,1.9551429797651m,3.39047953347m,-7.801668429091801m,5.6811905250367m,0.0443980455957011,7.954572119107401m,-0.0275616407858852,-5.0848466805597m,-4.3788211410901m,-6.154238427482m,-0.0134270673685612,-0.0147255834053587,-8.041650613003m,-993.5806894670999u,7.8118904579855m,-1.1399340945667m,0.012366967033782,-0.0146218579434475,-611.1885707738u,4.0846988121507m,-0.0104298470771121,3.1493660891333m,4.816783815606501m,3.4079070506594m,-6.6357174705588m,-0.010260144914176,529.6134719304u,-0.0166891103330641)
Nodelocation: 216,176,1
Nodesize: 48,24
Valuestate: 2,626,-4,402,639,0,MIDM
Numberformat: 2,%,4,2,0,0,4,1,$,0,"ABBREV",0
Constant Trading_days_per_yea
Title: Trading days per year
Definition: 250
Nodelocation: 96,176,1
Nodesize: 52,24
Variable Total_volatility
Title: Total volatility
Definition: SDeviation(Price_change,Day_num) * sqrt(Trading_days_per_yea)
Nodelocation: 456,176,1
Nodesize: 48,24
Valuestate: 2,604,37,416,303,0,MIDM
Numberformat: 2,%,4,2,0,0,4,1,$,0,"ABBREV",0
Decision Statistic
Title: Statistic
Definition: Choice(Self,0)
Nodelocation: 96,240,1
Nodesize: 48,24
Domain: ['Range','SD','F']
{!40000|Att_previndexvalue: ['Range','SD','F']}
Function Stat(Vol : Array[I] ; I : Index ; Total_vol : scalar)
Title: Stat
Definition: Determtable(Statistic)(~
Max(Vol,I) - Min(Vol,I),SDeviation(Vol,I),Variance(Vol,I) / Total_vol^2)
Nodelocation: 208,240,1
Nodesize: 48,24
Windstate: 2,5,7,476,224
Defnstate: 2,104,189,416,146,0,MIDM
Paramnames: Vol,I,Total_vol
Variable Actual_stat
Title: actual stat
Definition: Stat(Volatility_by_day,Day_of_week,Total_volatility)
Nodelocation: 584,176,1
Nodesize: 48,24
Valuestate: 2,641,177,232,195,0,MIDM
Aliases: Alias Actual_stat1, Alias Actual_stat2
Module Log_normal_analysis
Title: Log Normal Analysis
Defaultsize: 48,24
Nodelocation: 408,280,1
Nodesize: 48,32
Diagstate: 2,-3,0,699,218,17
Chance Price_change_sim1
Title: Price change sim1
Definition: var m := mean(Price_change+1,day_num);~
var sd := SDeviation(Price_change,day_num);~
Sample( LogNormal( mean:m, stddev:sd, over:day_num ) - 1 )
Nodelocation: 96,112,1
Nodesize: 48,31
Valuestate: 2,45,16,527,410,1,PDFP
Reformval: [Undefined,Day_num,Undefined,Undefined,Undefined,1]
Numberformat: 2,%,4,2,0,0,4,0,$,0,"ABBREV",0
Variable Volatility_by_day_si
Title: Volatility by day sim1
Definition: Aggregate(Price_change_sim1,Trading_day,Day_num,Day_of_week,type:"SDeviation") * sqrt(Trading_days_per_yea)
Nodelocation: 216,112,1
Nodesize: 48,24
Valuestate: 2,617,26,298,215,0,MIDM
Reformval: [Run,Day_of_week]
Numberformat: 2,%,4,2,0,0,4,1,$,0,"ABBREV",0
Variable Total_volatility_sim
Title: Total volatility sim1
Definition: SDeviation(Price_change_sim1,Day_num) * sqrt(Trading_days_per_yea)
Nodelocation: 344,113,1
Nodesize: 48,24
Valuestate: 2,604,37,416,303,0,MIDM
Reformval: [Run,Day_of_week]
Numberformat: 2,%,4,2,0,0,4,1,$,0,"ABBREV",0
Variable Stat_sim1
Title: stat sim1
Definition: stat(Volatility_by_day_si,Day_of_week,Total_volatility_sim)
Nodelocation: 464,112,1
Nodesize: 48,24
Valuestate: 2,295,185,746,336,0,SAMP
Reformval: [Run,Statistic]
Objective Pvalue1
Title: pValue1
Definition: Probability( Stat_sim1 >= Actual_stat )
Nodelocation: 584,112,1
Nodesize: 48,24
Valuestate: 2,713,6,267,161,0,MIDM
Aliases: Alias Pvalue3
Alias Actual_stat1
Title: actual stat
Definition: 1
Nodelocation: 344,48,1
Nodesize: 48,24
Original: Actual_stat
Close Log_normal_analysis
Module Shuffle_analysis
Title: Shuffle Analysis
Defaultsize: 48,24
Nodelocation: 520,280,1
Nodesize: 48,32
Diagstate: 2,-3,0,711,201,17
Chance Price_change_sim2
Title: Price Change sim2
Definition: Shuffle( Price_change, Day_num, over:Run )
Nodelocation: 96,120,1
Nodesize: 48,31
Valuestate: 2,192,21,416,303,0,MIDM
Reformval: [Run,Day_num]
Numberformat: 2,%,4,2,0,0,4,0,$,0,"ABBREV",0
Variable Volatility_by_day_s1
Title: Volatility by day sim2
Definition: Aggregate(Price_change_sim2,Trading_day,Day_num,Day_of_week,type:"SDeviation") * sqrt(Trading_days_per_yea)
Nodelocation: 216,120,1
Nodesize: 48,24
Valuestate: 2,702,26,349,229,0,MIDM
Reformval: [Run,Day_of_week]
Numberformat: 2,%,4,2,0,0,4,1,$,0,"ABBREV",0
Variable Total_volatility_si2
Title: Total volatility sim2
Definition: SDeviation(Price_change_sim2,Day_num) * sqrt(Trading_days_per_yea)
Nodelocation: 344,120,1
Nodesize: 48,24
Valuestate: 2,604,37,416,303,0,MIDM
Numberformat: 2,%,4,2,0,0,4,1,$,0,"ABBREV",0
Variable Stat_sim2
Title: stat sim2
Definition: Stat(Volatility_by_day_s1,Day_of_week,Total_volatility_si2)
Nodelocation: 464,120,1
Nodesize: 48,24
Valuestate: 2,730,9,268,502,0,SAMP
Objective Pvalue2
Title: pValue2
Definition: Probability( Stat_sim2 >= Actual_stat )
Nodelocation: 584,120,1
Nodesize: 48,24
Valuestate: 2,709,205,416,164,0,MIDM
Aliases: Alias Pvalue4
Alias Actual_stat2
Title: actual stat
Definition: 1
Nodelocation: 464,48,1
Nodesize: 48,24
Original: Actual_stat
Close Shuffle_analysis
Alias Pvalue3
Title: pValue1
Definition: 1
Nodelocation: 408,360,1
Nodesize: 48,24
Original: Pvalue1
Alias Pvalue4
Title: pValue2
Definition: 1
Nodelocation: 520,360,1
Nodesize: 48,24
Original: Pvalue2
Module Parkinson_s_exercise
Title: Parkinson's Exercise
Description: This exercise was not covered in the webinar, but is included in the power point slides for those who want to try another example on their own. Here I provide a "solution" for an implementation of this analysis.~
~
The data here is purely fictional, and the study is purely hypothetical. The data set in Subject_Counts shows the number of people in the hypothetical study that fall into each of the four possible groupings: Those with/without Parkinsons, and those with/without exposure to Tricholoethylene (TCE).~
~
The hypothesis to be test is: Exposure to TCE increases one's rick of getting Parkinson's disease.~
~
Does the data set confirm this hypothesis at a statistically significant level?
Defaultsize: 48,24
Nodelocation: 120,368,1
Nodesize: 52,24
Diagstate: 2,55,35,550,300,17
Index Exposed
Title: Exposed
Definition: [0,1]
Nodelocation: 96,56,1
Nodesize: 48,24
{!40000|Att_previndexvalue: [0,1]}
Index Parkinsons
Title: Parkinsons
Definition: [1,0]
Nodelocation: 200,56,1
Nodesize: 48,24
{!40000|Att_previndexvalue: [1,0]}
Constant Subject_counts
Title: Subject counts
Definition: Table(Exposed,Parkinsons)(~
10,140,~
4,25~
)
Nodelocation: 96,120,1
Nodesize: 48,24
Reformdef: [Parkinsons,Exposed]
Reformval: [Parkinsons,Exposed]
Variable Parkinson_rates
Title: Parkinson rates
Definition: Subject_counts[Parkinsons=1] / sum(Subject_counts,Parkinsons)
Nodelocation: 208,120,1
Nodesize: 48,24
Valuestate: 2,174,182,416,303,0,MIDM
Numberformat: 2,%,4,2,0,0,4,0,$,0,"ABBREV",0
Variable Overall_rate
Title: Overall rate
Definition: var x := sum(Subject_counts,Exposed);~
x[Parkinsons=1] / sum(x,Parkinsons)
Nodelocation: 208,176,1
Nodesize: 48,24
Numberformat: 2,%,4,2,0,0,4,0,$,0,"ABBREV",0
Chance Null_hypoth_counts_w
Title: Null hypoth counts with Parkinsons
Description: The null hypothesis: ~
The true underlying rate of Parkinsons is the same for exposed and non-exposed, and equal to the overall_rate observed.
Definition: var grpSz := sum(Subject_counts,Parkinsons);~
Binomial(grpSz,overall_rate)
Nodelocation: 96,240,1
Nodesize: 48,31
Windstate: 2,379,294,476,224
Valuestate: 2,43,364,631,165,0,SAMP
Reformval: [Undefined,Exposed,Undefined,Undefined,Undefined,1]
Variable Actual_statistic
Title: Actual Statistic
Definition: Parkinson_rates[Exposed=1] - Parkinson_rates[Exposed=0]
Nodelocation: 336,120,1
Nodesize: 48,24
Variable Null_rates
Title: Null rates
Definition: Null_hypoth_counts_w / sum(Subject_counts,Parkinsons)
Nodelocation: 208,240,1
Nodesize: 48,24
Valuestate: 2,212,219,416,303,0,SAMP
Reformval: [Undefined,Exposed,Undefined,Undefined,Undefined,1]
Numberformat: 2,%,4,2,0,0,4,0,$,0,"ABBREV",0
Variable Null_statistic
Title: Null statistic
Definition: Null_rates[Exposed=1] - Null_rates[Exposed=0]
Nodelocation: 336,240,1
Nodesize: 48,24
Valuestate: 2,228,235,416,303,0,SAMP
Reformval: [Undefined,Exposed,Undefined,Undefined,Undefined,1]
Objective Pvalue_tce
Title: pValue TCE
Description: The p-value for the hypothesis that TCE is associated with an increased risk of getting Parkinson's disease.~
~
A value < 0.05 indicates that there is statistically significant evidence in this data for a connection. A value >0.05 simply means that whatever evidence is here is inconclusive given the sample size.
Definition: Probability( Null_statistic >= Actual_statistic )
Nodelocation: 456,176,1
Nodesize: 48,24
Windstate: 2,121,153,476,224
Close Parkinson_s_exercise
Close Market_volatility_hy