Question: This problem deals with contingency table analysis. The warpbreaks dataset gives the number of warp breaks per loom, where a loom corresponds to a fixed

This problem deals with contingency table analysis. The "warpbreaks" dataset gives the number of warp breaks per loom, where a loom corresponds to a fixed length of yarn.There are 54 observations on 3 variables: breaks (numeric, the number of breaks), wool (factor, type of wool: A or B), and tension (factor, low L, medium M and high H).These data have been studied and used for example elsewhere.For the purposes of this problem, we will focus on the relationship between breaks and tension using contingency table analysis.

```{r test5a}

data(warpbreaks)

str(warpbreaks)

# breaks median

median_breaks

hist(warpbreaks$breaks, main = "Warpbreaks: histogram", xlab = "Number of breaks", col = "light blue")

abline(v = median_breaks, col = "dark blue", lwd = 2)

# factor numbers

number

# make augmented dataset + summary

augmented_wb

summary(augmented_wb)

# contingency table

contingency_table

contingency_table

please see attached and fill in the blanks accordingly

This problem deals with contingency table analysis. The "warpbreaks" dataset gives the

(5)(c) (3 points) 'Manually' calculate the chi-squared statistic and p-value of the table from (5)(a). The *addmargins()* function can be used to add row and column sums to the table; useful for calculating the expected values for each cell. You should be able to match the chi-squared and p-values from (5)(b). The underlying code for the *chisq. test()* function can be viewed by entering *chisq. test* - without parentheses - in the Console. You are given code below to create the table, add row and column sums and calculate the expected values for the for the first two (2) of three (3) rows. You will need to add code to calculate the expected values for the third row and the chi-squared. The *pchisq()* function can be used to return the p-value. {r test5c} (5)(d) (4 points) Build a user-defined function, using your code for (5)(c). We want to pass our (5)(a) table to our function and have it return the chi-squared statistic and p-value. You're provided with the 'shell' of a function and will need to add code to calculate the expected values, the chi-squared statistic, the p-value and return (i.e. output) the chi-squared and p-value. {r 5d}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!