ProjectMOSAIC / mosaic

Project MOSAIC R package
http://mosaic-web.org/
93 stars 26 forks source link

problems with xpf() #724

Closed nicholasjhorton closed 5 years ago

nicholasjhorton commented 5 years ago

1 - pf(1.5938, 2, 445) [1] 0.2043096 1 - xpf(1.5938, 2, 445) Error in pf(q = 1.5938) : argument "df1" is missing, with no default 1 - xpf(1.5938, df1 = 2, df2 = 445) [1] 0.2043096

rpruim commented 5 years ago

This stems from writing generic code that uses ... rather than customizing for each distribution:

> xpf
function (...) 
pdist("f", ...)

So, as currently implemented, distribution parameters must be named arguments. But we could change this to

> xpf
function (q, df1, df2, ...) 
pdist("f", q = q, df1 = df1, df2 = df2, ...)

Of course, we should then do this to the full suite of xp, and xq functions:

 [1] "xpbeta"             "xpbinom"            "xpchisq"            "xpdrows.data.frame"
 [5] "xpf"                "xpgamma"            "xpgeom"             "xpnbinom"          
 [9] "xpnorm"             "xppois"             "xpt"                "xqbeta"            
[13] "xqbinom"            "xqchisq"            "xqf"                "xqgamma"           
[17] "xqgeom"             "xqnbinom"           "xqnorm"             "xqpois"            
[21] "xqqmath"            "xqt"  
rpruim commented 5 years ago

Seems to be working:

library(mosaic)
1 - xpf(1.5938, df1 = 2, df2 = 445)
## [1] 0.2043096
1 - xpf(1.5938, 2, 445)
## [1] 0.2043096

I'll update some more distributions and then push (on beta).