{ Analytica Model Anderson_Darling_tes, encoding="UTF-8" } SoftwareVersion 6.3.2 { System Variables with non-default values: } SampleSize := 5000 TypeChecking := 1 Checking := 1 SaveOptions := 2 SaveValues := 0 {!-50299|DiagramColor Model: 65535,65535,65535} {!-50299|DiagramColor Module: 65535,65535,65535} {!-50299|DiagramColor LinkModule: 65535,65535,65535} {!-50299|DiagramColor Library: 65535,65535,65535} {!-50299|DiagramColor LinkLibrary: 65535,65535,65535} {!-50299|DiagramColor Form: 65535,65535,65535} NodeInfo FormNode: 1,0,0,,0,0,,,,0,,,0 {!-50299|NodeColor Text: 62258,62258,62258} {!-60000|Attribute AcpStyles} Model Anderson_Darling_tes Title: Anderson Darling Test Example Description: The Anderson-Darling test is used to detect whether a set of univariate continuous samples comes from a known distribution. The Kolmogorov-Smirnov Tests are used for the same thing, but differ in the choice of metric used to measure the distance between distributions. The Anderson-Darling test is more powerful (i.e., more likely to detect a difference in distribution when one exists) in many cases.~ ~ Here, instead of assuming any particular distribution, I show how to compute the p-value for any distribution null hypothesis in Analytica. The trade-off is that this is indeed distribution-free, but requires a Monte Carlo simulation to compute every p-value.~ ~ See Anderson-Darling test for more details on this example model. Author: Dale Rice~ Lumina Decision Systems Date: Mon, Mar 27, 2023 2:58 PM DiagState: 2,0,0,1062,656,17,10 FontStyle: Arial,15 FileInfo: 0,Model Anderson_Darling_tes,2,2,0,0,W:\TestModels\Anderson-Darling test.ana Variable X Title: X Description: Our example data. Definition: Random(Logistic(10,2,over:I)) NodeLocation: 160,104,1 NodeSize: 64,24 Index I Title: I Description: This indexes our data points. Definition: 1..15 NodeLocation: 160,184,1 NodeSize: 64,24 Function F(x) Title: F Description: The analytic CDF function for the null hypothesis distribution. Definition: DetermTable(Hypothesis)(CumNormal(x, 10, 2 ), CumLogistic(x, 10, 2 ) ) NodeLocation: 160,264,1 NodeSize: 64,24 Variable A2 Title: A^2 Description: This is the Anderson-Darling statistic, which is usually written an A^2. It is a measure of distance between a sample of points and a known distribution. Definition: AD_dist(x,I,F) NodeLocation: 368,104,1 NodeSize: 64,24 Chance Xr Title: Xr Description: Simulated points from the hypothesized distribution, used for computing the p-Value in the Anderson-Darling hypothesis test. Definition: DetermTable(Hypothesis)(Normal(10,2,over:I),Logistic(10,2,over:I)) NodeLocation: 160,392,1 NodeSize: 64,24 ValueState: 2,180,186,416,303,,SAMP Function AD_dist( x : [I] ; I : Index ; F : Function(x) atom ) Title: AD dist Description: Returns the A^2 statistic that measures the distance of the distribution of points in «x» from a reference distribution whose CDF is given by F(x). Definition: Local xs := Sort(x,I);~ Local n := sum(x<>Null, I);~ Local S := Sum( (2*@I-1)/n * (ln(F(xs)) + ln(1-F(Reverse(xs,I)))), I );~ -n - S NodeLocation: 800,104,1 NodeSize: 64,24 WindState: 2,659,468,720,350 Variable Sim_AD_stat_under_nu Title: Sim AD stat under null hyp Description: The Anderson-Darling statistic for each of the Monte Carlo simulation runs. Definition: AD_dist(Xr, I, F) NodeLocation: 368,392,1 NodeSize: 64,24 ValueState: 2,1263,228,521,651,,SAMP Variable p_value Title: p value Description: The probability of seeing an Anderson-Darling distance larger than our measured AD-distance if our null-hypothesis is true, i.e., if the data really is generated from the hypothesized distribution. Definition: Probability( Sim_AD_stat_under_nu > A2 ) NodeLocation: 544,392,1 NodeSize: 64,24 ValueState: 2,1122,55,416,303,,MIDM Decision Hypothesis Title: Hypothesis Definition: Choice(Self,2) NodeLocation: 160,480,1 NodeSize: 64,24 Aliases: FormNode Fo1792811539 {!40300|DomainExpr: Discrete('Normal(10,2)','Logistic(10,2)',type:'text')} FormNode Fo1792811539 Title: Hypothesis Definition: 0 NodeLocation: 196,568,1 NodeSize: 124,16 NodeInfo: 1,,,,,,,140,,,,,,0 Original: Hypothesis Close Anderson_Darling_tes