App on Sex and Love at First Sight

Do the Shiny app for the two-way table on sex and love_first.

How many times did you re-sample?

10000

What percentage of the time did the re sampled chi-square statistic exceed the chi-square statistic in the actual study?

13.44

Do you think there is overwhelming evidence that in the GC population the two sexes differ in whether they believe in love at first sight?

some evidence but not alot

chisqtestGC() on the sex and love at first sight Question

Here’s the code for a chi-square test to see if sex and belief in love at first sight are related in the GC population. Run the code:

chisqtestGC(~sex+love_first,data=m111survey,
            graph=TRUE)
## Pearson's Chi-squared test with Yates' continuity correction 
## 
## Observed Counts:
##         love_first
## sex      no yes
##   female 22  18
##   male   23   8
## 
## Counts Expected by Null:
##         love_first
## sex         no   yes
##   female 25.35 14.65
##   male   19.65 11.35
## 
## Contributions to the chi-square statistic:
##         love_first
## sex        no  yes
##   female 0.44 0.77
##   male   0.57 0.99
## 
## 
## Chi-Square Statistic = 2.0068 
## Degrees of Freedom of the table = 1 
## P-Value = 0.1566

Now look at the output and answer these question:

What’s the test statistic?

2.0068

About how big should it be if the Null is correct?

1

What’s the P-value?

0.1566

Race and Gun Owndership

Are race and gun owndership related in the U.S. population? In the code chunk below, insert the code needed to use chisqtestGC() to investigate this question. Tip: copy-paste and then modify the code from the previous problem.

chisqtestGC(~race+owngun,data=gss02,
            graph=TRUE)
## Pearson's Chi-squared test 
## 
## Observed Counts:
##           owngun
## race        No Yes
##   AfrAm    106  16
##   Hispanic  20   3
##   Other     25   7
##   White    454 284
## 
## Counts Expected by Null:
##           owngun
## race           No    Yes
##   AfrAm     80.67  41.33
##   Hispanic  15.21   7.79
##   Other     21.16  10.84
##   White    487.97 250.03
## 
## Contributions to the chi-square statistic:
##           owngun
## race          No   Yes
##   AfrAm     7.96 15.53
##   Hispanic  1.51  2.95
##   Other     0.70  1.36
##   White     2.36  4.61
## 
## 
## Chi-Square Statistic = 36.9779 
## Degrees of Freedom of the table = 3 
## P-Value = 0

What’s the test statistic?

10.5312

About how big should it be if the Null is correct?

3

What’s the P-value?

0

Do you think we have strong evidence for a relationship in the population, or could the pattern in the data be due just to chance?

very strong evidence that it is just chance

Is race a factor in beleif marajuana should be legalized?

chisqtestGC(~race+marijuan,data=gss02,
            graph=TRUE)
## Pearson's Chi-squared test 
## 
## Observed Counts:
##           marijuan
## race       Legal NotLegal
##   AfrAm       27       91
##   Hispanic     7       14
##   Other       10       18
##   White      262      421
## 
## Counts Expected by Null:
##           marijuan
## race        Legal NotLegal
##   AfrAm     42.48    75.52
##   Hispanic   7.56    13.44
##   Other     10.08    17.92
##   White    245.88   437.12
## 
## Contributions to the chi-square statistic:
##           marijuan
## race       Legal NotLegal
##   AfrAm     5.64     3.17
##   Hispanic  0.04     0.02
##   Other     0.00     0.00
##   White     1.06     0.59
## 
## 
## Chi-Square Statistic = 10.5312 
## Degrees of Freedom of the table = 3 
## P-Value = 0.0146

Looking at the output, answer the following questions.

What’s the test statistic?

10.5312

About how big should it be if the Null is correct?

3

What’s the P-value?

0.0146

Do you think we have strong evidence for a relationship in the population, or could the pattern in the data be due just to chance?

Yes the evidence is strong based on the p value calculated.

Simulated Sex and Seat

Try simulation on the sex and seating-preference study:

chisqtestGC(~sex+seat,data=m111survey,
            simulate.p.value="random",
            B=3000)

Now try it again, without simulation:

chisqtestGC(~sex+seat,data=m111survey)

Compare the P-values: are they about the same, or very different?

0.1606 in the first test and 0.1546 in the second They are about the same but becasue we simulated for the first one it is more accurate