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

Problem with noncentral confidence interval estimation #23

Closed
mtorchiano opened this issue Mar 20, 2017 · 1 comment
Closed

Problem with noncentral confidence interval estimation #23

mtorchiano opened this issue Mar 20, 2017 · 1 comment
Assignees
Labels

Comments

@mtorchiano
Copy link
Owner

From email on March 19, 2017

I have a question regarding cohen.d function.
I am trying to use this function to calculate confidence intervals for effect size using non-central t distribution for 500 samples. However, the function does not run inside a for loop if non-central=TRUE, even for small loops such as a loop of 2.
Here is the code that I have used:

# I generate two independent normal random samples size 10 with 500 repetition

x1 <-matrix(0,10,500)
x2 <-matrix(0,10,500)

for (i in 1:500) {	
 x1[,i] <- rnorm(10,9,2)
 x2[,i] <- rnorm(10,8,2)

      }

####Then I calculate confidence intervals for effect size using non-central t distribution

lb<-c(0)
ub<-c(0)
for (i in 1:500) {
 
 cohen.dres<-cohen.d(x1[,i],x2[,i],hedges.correction = FALSE, noncentral =TRUE)
 lb[i]<-cohen.dres$conf.int[1]  ##saving the lower limit in a vector
 ub[i]<-cohen.dres$conf.int[2]  ##saving the upper limit in a vector
 }

However, as I mentioned function cohen.d in the above for loop does not work.

@mtorchiano mtorchiano added the bug label Mar 20, 2017
@mtorchiano mtorchiano self-assigned this Mar 20, 2017
@mtorchiano
Copy link
Owner Author

After looking into details, I found a bug in the code that identifies the range for the ncp estimation.

The bug makes a loop non-converging, in practice a never ending loop is entered.

MWE

a = c(9.81605624621576, 8.93891560898168, 9.05436620537713, 6.01771305071382, 
8.98575772172126, 7.2595761413452, 13.7537304479165, 9.89861975363729, 
7.37246838418731, 8.33888742066376)
b = c(8.62798051757027, 5.25390514295654, 12.0869496333763, 7.20553319908951, 
6.99017188584104, 8.22363490828756, 8.05485287987422, 6.50534569228974, 
8.68871033652186, 4.62897740315003)
cohen.d(a,b,hedges.correction = FALSE, noncentral =TRUE)

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

1 participant