longor at iastate.edu
2006-Jul-01 19:13 UTC
[Rd] noncentral F-distributed random numbers (PR#9055)
Full_Name: Long Qu Version: 2.3.1 OS: Windows XP Submission from: (NULL) (64.113.93.235) The QQ-plot of two versions of simulating noncentral F-distributed random numbers has quite different scales:> qqplot(rf(1000,2,15,3),qf(runif(1000),2,15,3))The rf() function reads:> rffunction (n, df1, df2, ncp = 0) { if (ncp == 0) .Internal(rf(n, df1, df2)) else rchisq(n, df1, ncp = ncp)/rchisq(n, df2) } <environment: namespace:stats> where I believe both the numerator and the denominator should be divided by their corresponding degrees of freedom. My suggested (slighly augmented) version is:> rffunction (n, df1, df2, ncp1 = 0, ncp2=0){ if (ncp1 == 0 && ncp2==0) .Internal(rf(n, df1, df2)) else if (ncp2==0) (rchisq(n, df1, ncp = ncp1)/df1)/(rchisq(n, df2)/df2) else (rchisq(n, df1, ncp = ncp1)/df1)/(rchisq(n, df2, ncp=ncp2)/df2) } which incorporated both singly and doubly noncentral F-distribution.> version_ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 3.1 year 2006 month 06 day 01 svn rev 38247 language R version.string Version 2.3.1 (2006-06-01) Regards, Long Qu
Thomas Lumley
2006-Jul-03 18:04 UTC
[Rd] noncentral F-distributed random numbers (PR#9055)
On Sat, 1 Jul 2006, longor at iastate.edu wrote:> > The rf() function reads: >> rf > function (n, df1, df2, ncp = 0) > { > if (ncp == 0) > .Internal(rf(n, df1, df2)) > else rchisq(n, df1, ncp = ncp)/rchisq(n, df2) > } > <environment: namespace:stats> > > where I believe both the numerator and the denominator should be divided by > their corresponding degrees of freedom. >Yes. Fixed for 2.4.0. I didn't add a denominator non-centrality parameter, since we don't have code for qf, pf, or df for the doubly non-central distribution. -thomas
Apparently Analagous Threads
- Random numbers from noncentral t-distribution
- Noncentral t & F distributions
- Sometimes having problems finding a minimum using optim(), optimize(), and nlm() (while searching for noncentral F parameters)
- Problems with pf() with certain noncentral values/degrees of freedom combinations
- Fitting Data to a Noncentral Chi-Squared Distribution using MLE