0
$\begingroup$

I am experimenting a course's teorical contents on this dataset. After data cleaning, I am trying to use chi-square test. I wrote the following code:

chisq.test(chocolate$CompanyMaker, chocolate$Rating, simulate.p.value = TRUE)
chisq.test(chocolate$SpecificBeanOriginOrBarName, chocolate$Rating, simulate.p.value = TRUE)
chisq.test(chocolate$CompanyLocation, chocolate$Rating, simulate.p.value = TRUE)
chisq.test(chocolate$BeanType, chocolate$Rating, simulate.p.value = TRUE)
chisq.test(chocolate$BroadBeanOrigin, chocolate$Rating, simulate.p.value = TRUE)

chisq.test(chocolate$CompanyMaker, chocolate$CocoaPerc, simulate.p.value = TRUE)
chisq.test(chocolate$SpecificBeanOriginOrBarName, chocolate$CocoaPerc, simulate.p.value = TRUE)
chisq.test(chocolate$CompanyLocation, chocolate$CocoaPerc, simulate.p.value = TRUE)
chisq.test(chocolate$BeanType, chocolate$CocoaPerc, simulate.p.value = TRUE)
chisq.test(chocolate$BroadBeanOrigin, chocolate$CocoaPerc, simulate.p.value = TRUE)

And these are my results:

RATING

  • CompanyMarker = 0.29

  • Specific... = 0.6267

  • CompanyLocation = 0.1819

  • BeanType = 0.5372

  • BroadBeanOrigin = 0.1534

COCOA PERC

  • CompanyMarker = 0.0004998
  • Specific... = 0.902
  • CompanyLocation = 0.04748
  • BeanType = 0.8136
  • BroadBeanOrigin = 0.8356

Online, I read about significance level, but i didn't quite understand it. In particular, is it at 0.5 or 0.05? Which values are "ok"?

From what I understood, I should say that CompanyMarker, CompanyLocation and BroadBeanOrigin are related to Rating, while CompanyMarker and CompanyLocation are related to cocoaPercent.

Is this right? If not, can you write or link me an example or a guide to do it right? Thanks.

$\endgroup$
  • $\begingroup$ what do you understand by simulated p values? $\endgroup$ – Subhash C. Davar Jul 27 at 17:35
1
$\begingroup$

Chi-Square is used to determine which of the attributes are most informative. Its used in feature Selection.

So, if you have an attribute A ,B and C and output Y, we are trying to know Y depends on A or B or C ? A or B or C might be independent also i.e. has no affect on output Y.

So Chi-Sqaure is a statistical test to find out which attribute is independent and can be removed.

A contingency tables is created for each attribute value and its frequencies/occurrence is recorded and p_values above/below threshold determines if its relevant or not.

More about it here- https://machinelearningmastery.com/chi-squared-test-for-machine-learning/

Online, I read about significance level, but i didn't quite understand it. In particular, is it at 0.5 or 0.05? Which values are "ok"?

Please read about p-value

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks for answering! So, if we think about my data, Y is Rating and A, B, ... are the other ones , right? And it's the same thing with cocoaPerc (?) $\endgroup$ – user96624 May 23 at 11:35
  • $\begingroup$ So, the only informative attributes are Companymaker and companyLocation for CocoaPercent because they are < 0.05, right? $\endgroup$ – user96624 May 23 at 11:55
  • 1
    $\begingroup$ Rating is your target which you are trying to predict , if yes then it is Y. All other attributes like company, company location, bean type, percentage are attributes then yes A, B and so on. $\endgroup$ – BlackCurrant May 23 at 12:19
  • 1
    $\begingroup$ you are trying to determine, if ComnayMaker affects the rating? or company location does? or Cocoa percent does? or any combination of it. its not .05 normally but 0.5 which is the thershold. as per your data, looks like, Beantype and broadBeansorigin affects the rating. $\endgroup$ – BlackCurrant May 23 at 12:22
  • 1
    $\begingroup$ No Problem, I suggest you to read it in detail please, i gave an extremely brief overview for you to get started.. $\endgroup$ – BlackCurrant May 23 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.