Skip to main content
added tags; edited
Source Link
gung - Reinstate Monica
  • 147.5k
  • 89
  • 406
  • 717

output Output of chisq.test in r

I have a question regarding the below output offrom a chi square-squares test, which I find to be confusing and contrary to my expected results - my chi square-squared value is infinity here :)

I expected it to show a strong relation between smoke and workoutideal  (I was expecting chi square to be 0), but a weak relation between smoke and workoutmixed  (I was expecting any integer value for chi square here). However, what I observe is the exact opposite. Please see my output below:

> mydata
  = data.frame(smoke workoutideal workoutmixed
1    no          yes           no
2   yes           no          = noc('no','yes','no','no','yes')
3    no          yes        workoutideal = yesc('yes','no','yes','yes','no')
4    no          yes       workoutmixed = c('no','no','yes','yes','yes') yes)
5   yes           no          yes
> table(smoke, workoutideal)
     workoutideal
smoke no yes
  no   0   3
  yes  2   0
> table(smoke, workoutmixed)
     workoutmixed
smoke no yes
  no   1   2
  yes  1   1
> chisq.test(smoke,workoutideal)

    Pearson's Chi-squared test with Yates' continuity correction

data:  smoke and workoutideal
X-squared = 1.7014, df = 1, p-value = 0.1921

Warning message:
In chisq.test(smoke, workoutideal) :
  Chi-squared approximation may be incorrect
>  
chisq.test(smoke, workoutmixed)

    Pearson's Chi-squared test with Yates' continuity correction

data:  smoke and workoutmixed
X-squared = 0, df = 1, p-value = 1

Warning message:
In chisq.test(smoke, workoutmixed) :
  Chi-squared approximation may be incorrect

Thanks.

PS : If you would like to recreate data to perform the test here it is,

smoke = c('no','yes','no','no','yes')
workoutideal = c('yes','no','yes','yes','no')
workoutmixed = c('no','no','yes','yes','yes')

output of chisq.test in r

I have a question regarding the below output of chi square test, which I find to be confusing and contrary to my expected results - my chi square value is infinity here :)

I expected it to show a strong relation between smoke and workoutideal(I was expecting chi square to be 0), but a weak relation between smoke and workoutmixed(I was expecting any integer value for chi square here). However, what I observe is the exact opposite. Please see my output below

> mydata
   smoke workoutideal workoutmixed
1    no          yes           no
2   yes           no           no
3    no          yes          yes
4    no          yes          yes
5   yes           no          yes
> table(smoke,workoutideal)
     workoutideal
smoke no yes
  no   0   3
  yes  2   0
> table(smoke,workoutmixed)
     workoutmixed
smoke no yes
  no   1   2
  yes  1   1
> chisq.test(smoke,workoutideal)

    Pearson's Chi-squared test with Yates' continuity correction

data:  smoke and workoutideal
X-squared = 1.7014, df = 1, p-value = 0.1921

Warning message:
In chisq.test(smoke, workoutideal) :
  Chi-squared approximation may be incorrect
> chisq.test(smoke,workoutmixed)

    Pearson's Chi-squared test with Yates' continuity correction

data:  smoke and workoutmixed
X-squared = 0, df = 1, p-value = 1

Warning message:
In chisq.test(smoke, workoutmixed) :
  Chi-squared approximation may be incorrect

Thanks.

PS : If you would like to recreate data to perform the test here it is,

smoke = c('no','yes','no','no','yes')
workoutideal = c('yes','no','yes','yes','no')
workoutmixed = c('no','no','yes','yes','yes')

Output of chisq.test in r

I have a question regarding the below output from a chi-squares test, which I find to be confusing and contrary to my expected results - my chi-squared value is infinity here :)

I expected it to show a strong relation between smoke and workoutideal  (I was expecting chi square to be 0), but a weak relation between smoke and workoutmixed  (I was expecting any integer value for chi square here). However, what I observe is the exact opposite. Please see my output below:

mydata = data.frame(smoke = c('no','yes','no','no','yes')
                    workoutideal = c('yes','no','yes','yes','no')
                    workoutmixed = c('no','no','yes','yes','yes') )

table(smoke, workoutideal)
     workoutideal
smoke no yes
  no   0   3
  yes  2   0
table(smoke, workoutmixed)
     workoutmixed
smoke no yes
  no   1   2
  yes  1   1
chisq.test(smoke,workoutideal)

    Pearson's Chi-squared test with Yates' continuity correction

data:  smoke and workoutideal
X-squared = 1.7014, df = 1, p-value = 0.1921

Warning message:
In chisq.test(smoke, workoutideal) :
  Chi-squared approximation may be incorrect
 
chisq.test(smoke, workoutmixed)

    Pearson's Chi-squared test with Yates' continuity correction

data:  smoke and workoutmixed
X-squared = 0, df = 1, p-value = 1

Warning message:
In chisq.test(smoke, workoutmixed) :
  Chi-squared approximation may be incorrect
Post Migrated Here from stackoverflow.com (revisions)
Source Link
IAMTubby
  • 287
  • 2
  • 11

output of chisq.test in r

I have a question regarding the below output of chi square test, which I find to be confusing and contrary to my expected results - my chi square value is infinity here :)

I have two questions here

  1. I made a data frame showing the relation between smoking and working out. In the column workoutideal, I have tried to convey that smokers don't work out and non smokers work out. In the column workoutmixed, it's any random data.

I expected it to show a strong relation between smoke and workoutideal(I was expecting chi square to be 0), but a weak relation between smoke and workoutmixed(I was expecting any integer value for chi square here). However, what I observe is the exact opposite. Please see my output below

> mydata
  smoke workoutideal workoutmixed
1    no          yes           no
2   yes           no           no
3    no          yes          yes
4    no          yes          yes
5   yes           no          yes
> table(smoke,workoutideal)
     workoutideal
smoke no yes
  no   0   3
  yes  2   0
> table(smoke,workoutmixed)
     workoutmixed
smoke no yes
  no   1   2
  yes  1   1
> chisq.test(smoke,workoutideal)

    Pearson's Chi-squared test with Yates' continuity correction

data:  smoke and workoutideal
X-squared = 1.7014, df = 1, p-value = 0.1921

Warning message:
In chisq.test(smoke, workoutideal) :
  Chi-squared approximation may be incorrect
> chisq.test(smoke,workoutmixed)

    Pearson's Chi-squared test with Yates' continuity correction

data:  smoke and workoutmixed
X-squared = 0, df = 1, p-value = 1

Warning message:
In chisq.test(smoke, workoutmixed) :
  Chi-squared approximation may be incorrect
  1. While deciding whether null hypothesis should be accepted or rejected in R, should I look at the X-squared value and accept null hypothesis if it is less than the critical value for it's degrees of freedom and reject otherwise. OR, should I look the p-value and accept null hypothesis if it is higher than 0.05, the significance level and reject otherwise.

Thanks.

PS : If you would like to recreate data to perform the test here it is,

smoke = c('no','yes','no','no','yes')
workoutideal = c('yes','no','yes','yes','no')
workoutmixed = c('no','no','yes','yes','yes')