GithubHelp home page GithubHelp logo

Complete cases in chaid_table about cgpfunctions HOT 2 OPEN

ibecav avatar ibecav commented on August 16, 2024
Complete cases in chaid_table

from cgpfunctions.

Comments (2)

ibecav avatar ibecav commented on August 16, 2024

I'm not sure I fully understand. The underlying CHAID::chaid function only operates on the complete case dataset. If you could share a reproducible example see for example https://stackoverflow.com/questions/48874304/creating-reproducible-example-using-reprex-package-in-r-where-a-local-file-is-be I'd be happy to look.

from cgpfunctions.

FedericoTrifoglio avatar FedericoTrifoglio commented on August 16, 2024

I see. I thought I could set na.action to na.pass in CHAID::chaid to make it work without having complete cases. Would that cause the CHAID algorithm to give bad results? Should I convert NA_real_'s to NA_character_'s, so "NA" is a factor level?
Anyway example below

library(CHAID)
library(CGPfunctions)
set.seed(290875)
USvoteS <- USvote[sample(1:nrow(USvote), 1000),]
random_NA <- function(x) {
  x[sample(2:6, 1)] <- NA_real_
  x
}
USvoteSNA <- as.data.frame(t(apply(USvoteS, 1, random_NA)))
USvoteSNA <- as.data.frame(lapply(USvoteSNA, factor))
ctrl <- chaid_control(minsplit = 200, minprob = 0.1)
chaidUS <- chaid(vote3 ~ ., na.action = na.pass, data = USvoteSNA, control = ctrl)
chaid_table(chaidUS)
# Error in chisq.test(., correct = FALSE) : 
  at least one entry of 'x' must be positive

from cgpfunctions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.