Re: The D'Agostino Pearson k^2 test implemented in mathematica / variance of difference sign test
- To: mathgroup at smc.vnet.net
- Subject: [mg65000] Re: [mg64990] The D'Agostino Pearson k^2 test implemented in mathematica / variance of difference sign test
- From: leigh pascoe <leigh at cephb.fr>
- Date: Sat, 11 Mar 2006 05:15:36 -0500 (EST)
- References: <200603101015.FAA22041@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
john.hawkin at gmail.com wrote: > Hello, > > I have two questions. > > 1. Are there any resources of .nb files available on the internet > where I might find an implementation of the D'Agostino Pearson k^2 test > for normal variates? > > 2. In the mathematica time series package (an add-on), the > "difference-sign" test of residuals is mentioned (url: > http://documents.wolfram.com/applications/timeseries/UsersGuidetoTimeSeries/1.6.2.html). > It says that the variance of this test is (n+1) / 2. However, it > would seem to me that a simple calculation gives a variance of (n-1)/4. > It goes as follows: > > If the series is differenced once, then the number of positive and > negative values in the difference should be approximately equal. If Xi > denotes the sign of each value in the differenced series, then > Mean(Xi) = 0.5(1) + 0.5(0) = 0.5 > Var(Xi) = Expectation( (Xi - Mean(Xi))^2 ) > = Expectation( Xi^2 -Xi + 0.25 ) > = 0.5 - 0.5 + 0.25 > = 0.25 > > And assuming independence of each sign from the others, the total > variance should be the sum of the individual variances, up to n-1 for n > data points (since there are only n-1 changes in sign), thus > > Variance = (n-1) / 4 > > There is an equivalent problem in Lemon's "Stochastic Physics" about > coin flips, for which the answer is listed, without proof, as (n-1)/8. > Because of these three conficting results I am wondering if I have made > an error in my calculation, and if anyone can find one please let me > know. > > Thank you very much, > > -John Hawkin > > > > Dear John, I agree with your calculation. We assume an indicator variable that is 1 if the succeeding value is greater or zero if it is less than the preceding one. Under the null hypothesis this is just a binomial variable with p=.5 and n-1 trials. The mean and variance of the number of successes must be proportional to n-1 and are in fact the values you calculated. I don't have Lemon's book, so I can't comment on the equivalence of the problems. Perhaps the factor of 2 is due to the way the problem is stated w.r.t heads and tails. LP
- References:
- The D'Agostino Pearson k^2 test implemented in mathematica / variance of difference sign test
- From: "john.hawkin@gmail.com" <john.hawkin@gmail.com>
- The D'Agostino Pearson k^2 test implemented in mathematica / variance of difference sign test