Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Computation in dd() #9

Open
wviechtb opened this issue Jun 2, 2018 · 0 comments
Open

Computation in dd() #9

wviechtb opened this issue Jun 2, 2018 · 0 comments
Assignees
Labels

Comments

@wviechtb
Copy link

wviechtb commented Jun 2, 2018

The computation in dd() isn't correct. Two issues:

  1. In dd(), you use df + 2, but convert.d.to.t() also does df + 2, so in essence this is done twice.

  2. You cannot just convert d to t and then plug t into dt(). You need to use the change of variables technique:

https://en.wikipedia.org/wiki/Probability_density_function#Dependent_variables_and_change_of_variables

So, let's say n1=n2=10 and true d is 0.5. At the moment:

> integrate(function(x) dd(x, df=16, populationD=0.5), lower=-Inf, upper=Inf)
0.4264014 with absolute error < 2.3e-07

You can ignore the warnings. Note that I plug in df=16, so that 16+2+2=20 actually corresponds to n1=n2=10. But the density must integrate to 1. Correct would be:

> integrate(function(x) dd(x, df=16, populationD=0.5) * sqrt(10/2), lower=-Inf, upper=Inf)
1 with absolute error < 2.7e-07

So, you need to multiply by sqrt(n1*n2/(n1+n2)).

@Matherion Matherion self-assigned this Jul 24, 2018
@Matherion Matherion added the bug label Jul 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants