Open wviechtb opened 6 years ago
The computation in dd() isn't correct. Two issues:
dd()
1) In dd(), you use df + 2, but convert.d.to.t() also does df + 2, so in essence this is done twice.
df + 2
convert.d.to.t()
2) You cannot just convert d to t and then plug t into dt(). You need to use the change of variables technique:
dt()
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)).
sqrt(n1*n2/(n1+n2))
The computation in
dd()
isn't correct. Two issues:1) In
dd()
, you usedf + 2
, butconvert.d.to.t()
also doesdf + 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:
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:
So, you need to multiply by
sqrt(n1*n2/(n1+n2))
.