Basic Concepts
While the chi-square distribution characterizes how the chi-square test statistic is distributed when the null hypothesis is assumed to be true, the noncentral chi-square distribution instead shows how the chi-square test statistic is distributed when the alternative hypothesis is assumed to be true (i.e. when the null hypothesis is assumed to be false). As such it is useful in calculating the power of various chi-square tests.
Definition
where Gr(x) is the cumulative distribution function for the central chi-square distribution χ2(r).
Similarly, the probability density function (pdf) is given by the formula
where gr(x) is the pdf for the central chi-square distribution χ2(r).
Algorithm
The cdf can also be expressed as
where pr(z) is the probability density function of the Poisson distribution with mean r (see Poisson Distribution).
The probability density function (pdf) of the noncentral chi-square distribution can also be expressed by the formula
Thus, the pdf and cdf of the noncentral chi-square distribution can be expressed to any desired degree of precision in Excel as a finite sum of terms using POISSON.DIST and CHISQ.DIST.
Properties
The mean of the noncentral chi-square distribution is k + λ. The variance is 2(k+2λ).
When λ = 0 the noncentral chi-square distribution is equal to the central chi-square distribution, i.e. χ2(k,0) = χ2(k).
Graph
Figure 1 displays a graph of the noncentral chi-square distribution with 5 degrees of freedom for noncentrality parameter δ = 0, 2, 4, 6.
Figure 1 – Noncentral chi-square distribution
Worksheet Functions
Real Statistics Functions: The Real Statistics Resource Pack supplies the following worksheet functions:
NCHISQ_DIST(x, df, λ, cum, iter, prec). If cum = TRUE then the cdf of the noncentral chi-square distribution χ2(df, λ) at x is returned, while if cum = FALSE then the pdf at x is returned.
NCHISQ_INV (p, df, λ, iter, iter0, prec) = the inverse of the cdf of the noncentral chi-square distribution χ2(df, λ) at p, i.e. the value of x such that NCHISQ(x, df, λ, TRUE, iter, prec) = p.
NCHISQ_NCP (p, df, x, iter, iter0, prec) = the value of the noncentrality parameter λ such the cdf of the noncentral distribution χ2(df, λ) at x is p, i.e. NCHISQ(x, df, λ, TRUE, iter, prec) = p.
Here iter = the maximum number of terms in the infinite sum that will be calculated (default 1000), prec = desired level of accuracy of the power calculation (default 0.000000001) and iter0 = the number of iterations used in calculating NCHISQ_INV and NCHISQ_NCP (default 40). df can take any positive value and does not have to be an integer.
Note that NCHISQ_DIST(6,5,4,FALSE) = .087883Â and NCHISQ_DIST(6,5,4,TRUE) = .317396, which is consistent with the values shown in the green curve of Figure 1.
Examples Workbook
Click here to download the Excel workbook with the examples described on this webpage.
References
Steier, J. F. and Fouladi, R. T. (1997)Â Noncentrality interval estimation and the evaluation of statistical models
http://www.statpower.net/Steiger%20Biblio/Steiger&Fouladi97.PDF
Krishnamoorthy, K. (2006) Handbook of statistical distributions with applications. Chapman and Hall
https://www.academia.edu/41846183/Handbook_of_Statistical_Distributions_with_Applications
Benton, D. and Krishnamoorthy, K. (2003)Â Computing discrete mixtures of continuous
distributions: noncentral chisquare, noncentral t and the distribution of the square of the sample multiple correlation coefficient. Computational Statistics & Data Analysis 43. 249 – 267
https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3142698
Hi Charles,
I am on a Mac using Excel 2011. I have tried several times to use the Add-In and have failed.
The first error message I get is “Can’t find project or library”. When I click Ok, it asks me for a Real-Stat password.
I have followed the instructions and don’t know what I am doing wrong. Do you have any ideas?
Thank!
Evita,
You should never need to provide a password. Make sure that you downloaded the version of Real Statistics for the Mac Excel 2011.
See the following webpage. Instead of pressing Alt-TI, use the AddIns choice from the Tools menu.
Password prompt
Charles
Charles,
I am still having the same problem. I removed the previous add-in and carefully repeated the download and installation steps again and I get the same error messages. The Solver add-in is already installed in my Excel and so all I should have to do when I go to the Add-Ins menu should be just click the box. I have Excel 2011 on a Mac and that is the version I have been selecting.
Do you have any idea what can be wrong?
Thanks.
Evita,
Here are some possible reasons, although it looks like you have ruled out #2.
1. Try using one of the Real Statistics functions. In particular, enter the formula =VER() and see whether you get an error, in which case, the software has not been installed correctly
2. Solver has not been installed. When you choose the Add-Ins option from the Tools menu, do you see RealStats and Solver in the list of addins with a check mark next to them?
3. See Hint 2 at https://real-statistics.com/appendix/faqs/disappearing-addin
4. The problem might be with the Trust Center settings. Click on Options from the File ribbon and then choose the Trust Center option on the left side. Next click on Trust Center Settings …. Next click on the Macro Settings option on the left side and make sure that it is Disable all Macros with Notification. Also click on the Trusted Locations option on the left side and click on the Add New Location… button to add the folder that contains RealStats-2007 folder as a trusted location.
Charles
Charles,
Thanks for your reply.
Unfortunately, I still cannot get it to worked.
To address your comments:
1) Solver is installed
2) I tried =VER() and it returns “5.0 Excel Mac” so something installed but not completely or correctly.
3) I am using Excel 2011 on a Mac and Trust Center settings does not exist.
4) I do see “Real Statistics” in the bar at the top. However, I tried calling a couple of the functions that that I saw in these help pages and I either get an error or the wrong answer. Specifically:
a)”=NCHISQ_DIST(6,5,4,FALSE)” generates a pop-up with the message “Compile error in hidden module: NonCentral” as opposed to 0.087883
b) “=NT_DIST(6,5,4,TRUE)” gives 0.7870196 and not 0.317396 as shown in one of the help pages.
Does this help at all to identify the problem?
Thank you for all your help
Evita,
I don’t see where the problem is. I am on vacation this weekend and don’t have my Mac with me. When I return on Tuesday, I will try to figure out what is happening. One further question: are you using an English-language version of Excel or some other language?
Charles
I did not see a “Reply” link under your list response so I am responding here. I am using the English (default) language. If you want me to try anything else, please let me know.
Thanks again.
Evita,
Thanks for your response. I will look into this problem when I return home on Tuesday.
Charles
Charles,
I am sorry but I just saw your response – for some reason the posts are not listed in chronological order.
I tried what you suggested but unfortunately, to no avail. Specifically, in a new workbook, I unselected Real-Stats and then closed the workbook. When I reopened, I selected it again and got the usual error message : “Can’t find project or library” followed by being prompted for a password again. I selected OK and Cancel, respectively.
Also, inside the spreadsheet, I try to get values for some of the functions:
1) NCHISQ_DIST(6,5,4,FALSE) gives the error “Compile error in hidden module: NonCentral”
2) NT_DIST(6,5,4,TRUE) gives 0.7870196 which is incorrect (the correct value is 0.317396)
I don’t know if this information helps at all but I don’t what else to do.
Thanks.
Evita,
1. Are you using Excel 2016 for the Mac. If so, try using the Real Statistics version for Excel 2016 (Mac).
If using Excel 2011, did you try using the Rel 3.5.3 version of the software?
2. The value for NT_DIST(6,5,4,TRUE) is correct (see http://keisan.casio.com/exec/system/1180573219). The value of =NCHISQ_DIST(6,5,4,TRUE) is .317396
Charles
Thank you, Charles.
I am on Excel 2011 for the Mac. I uninstalled the version that I had downloaded previously and tried your suggesting – i.e., using Version 3.53. Everything works fine now.
I also checked the output given by NT_DIST(6,5,4,TRUE) against the other website and it agrees. As a note, you may want to update the last sentence under Figure 1 where it gives a value of 0.317396 for this as opposed to the correct value of 0.7879186.
I appreciate all your help. It is really nice to have a package like this!!
Evita,
Glad to see that everything is working now.
Thanks also for catching the error on the webpage. I have now corrected the formula. I appreciate your help in improving the accuracy of the website.
Charles
The noncentral chi-square function is not available in my version of Excel 2016. How do I enable it?
Seth,
Are you using the Real Statistics addin?
Are you using a Mac?
Charles
Figure 1 shows df=5 but the preceding reference says “10 degrees of freedom” is this a mistake?
Anthony,
Yes, you are correct. Thank you very much for finding this error. I have now corrected the referenced webpage. I really appreciate your help in making the website better and more accurate.
Charles
Dear Mr./Ms.
I’m using the non-central chi square distribution function from real-statistics package. However, when the df is less then 1, it doesn’t work anymore. How can I deal with the situation with df less then 1?
Thank you so much
Xiaotong
Xiaotong,
The reason that it doesn’t work is that Excel’s CHIDIST and CHISQ.DIST functions don’t work for df < 1 and the Real Statistics non-central chi-square function calls these Excel functions. I will make a change in the next release of the Real Statistics software to calculate the non-central chi-square distribution is a slightly different way so that values of df < 1 will be supported. Charles
Charles,
Thank you very much for your timely reply.
So when will you post the next release of the Real Statistics? Can’t wait to use it 🙂
Thank you a gain for this wonderful package.
Xiaotong
Probably late next week, depending on how the testing goes.
Charles
Hi Charles,
Can you tell me once you post the latest version?
Thank you
Best
Xiaotong
Hi Xiaotong,
You can get this information by following the Real Statistics website on Twitter by using @Real1Statistics. You can do this by clicking on the Follow @Real1Statistics icon.
Charles