Skip to content

Computation in dd() #9

@wviechtb

Description

@wviechtb

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)).

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions