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

Typo in interestMeasure when measure is chiSquared #82

Open
bachnguyen-tomo opened this issue Jun 21, 2024 · 0 comments
Open

Typo in interestMeasure when measure is chiSquared #82

bachnguyen-tomo opened this issue Jun 21, 2024 · 0 comments

Comments

@bachnguyen-tomo
Copy link

The documentation mentioned that using chiSquared as an interest measure supports mining substitution effects, by setting the parametercomplement = TRUE, however it's actually "compliment" in interestMeasure.R leading to this error message
Error in .basicRuleMeasure(x, measure, transactions = transactions, ...) (quarterly.R#23): unused argument (complement = TRUE)

 chiSquared = {
        chi2 <- numeric(length(x))
        
        for (i in seq_len(length(x))) {
          fo <- matrix(c(n00[i], n01[i], n10[i], n11[i]), ncol = 2)
          #fe <- tcrossprod(c(nx0[i], nx1[i]), ic(n0x[i], n1x[i])) / n
          ## check if approximation is ok
          ## we don't do this now
          ##if(any(fe < 5)) chi2[i] <- nA
          ##else
          #chi2[i] <- sum((fo - fe) ^ 2 / fe)
          
          # warning about approximation
          suppressWarnings(chi2[i] <-
              stats::chisq.test(fo, correct = FALSE)$statistic)
        }
        
        ## the chi square test has 1 df for a 2x2 contingency table.
        ## The critical value at alpha=0.05 is:
        ## qchisq(0.05, df =1, lower.tail=FALSE)
        ## [1] 3.841459
        if (!significance)
          chi2
        else
          stats::pchisq(q = chi2,
            df = 1,
            lower.tail = !compliment)
      }
    ))

due to the variable declared by the bigger class as

.basicRuleMeasure <- function(x,
  measure,
  transactions = NULL,
  ### adds smoothCounts to the count in each cell to avoid counts of 0
  smoothCounts = 0,
  ### k is the number of classes used by laplace
  significance = FALSE,
  ### used by chi-squared
  compliment = TRUE,
...)

fishersExactTest and hyperConfidence supports mining substitution effect, but they have their own "complement" parameter

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