# Calculating a P-value for a two-tailed One-Standard-Deviation chi-square Test

#### damienpf

##### New Member
How does one calculate a P-value for a two-tailed One-Standard-Deviation chi-square Test?

Before we begin, I would like to say thank you for reading my post. Also, I would like to apologize if anything I have written below is unclear.

Here is the situation:
Suppose we have a variable x over a population P. Let σ be the undetermined population standard deviation for x. Let S be a sample of a determined size n from P with a determined sample standard deviation s for x. Let HT be a hypothesis test for x with null hypothesis
H0: σ = σ0
and alternate hypothesis
Ha: σ ≠ σ0,
where σ0 is determined.

To calculate the P-value of HT, I currently use a conditional algorithm on my TI-89. This function takes use of the chi2cdf(lowerχ²,upperχ²,degreesOfFreedom) function on the calculator. For example, chi2cdf(5,15,11) will return the area (≈0.74867) between 5 and 15 under the χ²-curve with 11 degrees of freedom. My conditional algorithm also uses another function of my own making, c2tests(s,n,σ0), which returns the test statistic for HT.

Here is an informal representation of the algorithm using the parameters s,n and σ0 from the hypothesis test HT:

Code:
Let P and ts be local variables;
Let ts=c2tests(s,n,σ0);
If s<σ0, then let P=2*chi2cdf(0,ts,n-1);
Otherwise, if s>σ0, then let P=2*chi2cdf(ts,∞,n-1);
Otherwise, if s=σ0, then return 1;
If P>1, then return 1;
Return P;
Oddly enough, for every chi-square exercise in my statistics book, this algorithm produces a consistent P-value. Did I just get lucky, or is this an appropriate way to calculate the P-value for an arbitrary two-tailed one-standard-deviation chi-square hypothesis test HT?

Thank you again for all your help!