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

Inefficient Non-Parametric Test #22

Open
chrstphlbr opened this issue Feb 16, 2021 · 0 comments
Open

Inefficient Non-Parametric Test #22

chrstphlbr opened this issue Feb 16, 2021 · 0 comments

Comments

@chrstphlbr
Copy link
Contributor

Hi,

I just realized while running both parametric and non-parametric versions of the SK test that the non-parametric version is much slower. I have not measured or profiled the executions, although looking at the code, I suspect the diff function in PartitionNonParametric is the culprit. Once a magnitude is non-negligible, the variable negligible is not updated anymore but the nested loop continues to execute. Unfortunately, I am unable to send a PR myself at the moment, but I can provide a potential fix below.

Current version:

diff <- function(k, g, av, means){
        negligible <- TRUE
        for(i in k:(g-1)){
            for(j in (i+1):g){
                a <- av$model[av$model[,2] == names(means[k]),1]
                b <- av$model[av$model[,2] == names(means[g]),1]   
                magnitude <- as.character(effsize::cliff.delta(a,b)$magnitude, paired=TRUE)
                if(magnitude != "negligible"){
                    negligible <- FALSE
                }
            }
        }
        return(negligible)
    }

Fixed version:

diff <- function(k, g, av, means){
        for(i in k:(g-1)){
            for(j in (i+1):g){
                a <- av$model[av$model[,2] == names(means[k]),1]
                b <- av$model[av$model[,2] == names(means[g]),1]   
                magnitude <- as.character(effsize::cliff.delta(a,b)$magnitude, paired=TRUE)
                if(magnitude != "negligible"){
                    return(FALSE)
                }
            }
        }
        return(TRUE)
    }

Cheers
Christoph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant