carlganz / svrepmisc

6 stars 2 forks source link

A possible error with the computation of Pr(>|t|) #6

Closed larmarange closed 6 years ago

larmarange commented 6 years ago

When re-reading your code, I am feeling that there is probably a mistake on that line:

https://github.com/carlganz/svrepmisc/blob/8bed9b212f2fe30aeff843f9e49b2cbd8dc26189/R/misc.R#L34

Shouldn't it be:

  pvals <- (1 - stats::pt(abs(tvals), df.residual)) * 2

?

carlganz commented 6 years ago

I don't know, I can't remember why I did it that way.

Based on survey source code should probably use 2 * pt(-abs(tvals), df.residual)

Sources: https://github.com/cran/survey/blob/4bc6f900be6c085805e3912c07521c67129487cd/R/surveyrep.R#L1879

https://github.com/cran/survey/blob/4bc6f900be6c085805e3912c07521c67129487cd/R/survey.R#L1408

larmarange commented 6 years ago

right

2 * pt(-abs(tvals), df.residual) is equivalent to (1 - stats::pt(abs(tvals), df.residual)) * 2

larmarange commented 6 years ago

fixed by https://github.com/carlganz/svrepmisc/pull/7/