Enter data into columns and provide headersscore epitools app
BIOSTATS 640 - Spring 2023 Unit 4. Categorical Data Analysis (2 of 2) R and Online Apps
Unit 4 – Categorical Data Analysis
Practice Problems (2 of 2)
This exercise gives you practice performing a2 x K test of trend for contingency table data.
The Western Collaborative Group Study (WCGS) was a prospective study of 3,154 men, all initially disease-free, who were followed for events of coronary heart disease (CHD). At the eight years follow-up mark, there were 257 events of CHD. Several potential predictors of CHD were of interest, including: age (at enrollment), cholesterol, systolic blood pressure, hematocrit, ECG status, smoking, and relative weight.
35-40 | 41-45 | Age at Enrollment (years) | 55-60 | Total = | ||
---|---|---|---|---|---|---|
46-50 | 51-55 | |||||
no | 512 | 1036 | 680 | 463 | 206 | 2987 |
yes | 31 | 55 | 70 | 65 | 36 | 257 |
Total = | 543 | 1091 | 750 | 528 | 242 | 3154 |
sol_categorical 2 of 2.docx Page 1 of 8
BIOSTATS 640 - Spring 2023 Unit 4. Categorical Data Analysis (2 of 2) R and Online Apps
chd | not chd | |
---|---|---|
1 | 31 | 512 |
2 | 55 | 1036 |
3 | 70 | 680 |
4 | 65 | 463 |
5 | 36 | 206 |
In EpiTools App, paste data into data box. Click SUBMIT
BIOSTATS 640 - Spring 2023 Unit 4. Categorical Data Analysis (2 of 2) R and Online Apps
Question #1B
HO: No association of interval of age with event of CHD
HA: Monotone increasing trend in event of CHD with increasing interval of age, one-sided
|
---|
|
---|
## CHD 35-40 41-45 46-50 51-55 55-60
## No 512 1036 680 463 206
## Yes 31 55 70 65 36Inspect Data
library(gmodels) # Attach package {gmodels}
BIOSTATS 640 - Spring 2023 Unit 4. Categorical Data Analysis (2 of 2) R and Online Apps
Q1a) Test of General Association
|
---|
|
---|
## X-squared = 46.653, df = 4, p-value = 0.000000001801
HO: No association of interval of age with event of CHD
unlikely result. Conclude these data provide statistically significant evidence of an association.
Q1b) Test of Trend
|
---|
|
---|
|
---|
|
---|
p-value <<< .0001
Reject the null hypothesis. Assumption of the null hypothesis and application to the data has led to an extremely
#2. Source: Triola MM and Triola MF. Biostatistics for the Biological and Health Sciences Boston: Pearson Addison Wesley, John Wiley, 2006. Chapter 10, Section 10-2. page 491.
This exercise gives you practice performing a chi square goodness of fit (GOF) test.
0 | 1 | 2 | 7 | 8 | 9 | |||||
---|---|---|---|---|---|---|---|---|---|---|
3 | 4 | 5 | 6 | |||||||
Frequency | 35 | 0 | 2 | 1 | 4 | 24 | 1 | 4 | 7 | 2 |
2b. How many degrees of freedom does your chi square statistic have? Degrees of freedom = (# intervals) - 1
= 92c. What is the value of your chi square statistic?
156.5
BIOSTATS 640 - Spring 2023 Unit 4. Categorical Data Analysis (2 of 2) R and Online Apps
Online Apps Solution
sol_categorical 2 of 2.docx Page 6 of 8
q2_df
## digit observed_n expected_percent
## 1 0 35 0.1
## 2 1 0 0.1
## 3 2 2 0.1
## 4 3 1 0.1
## 5 4 4 0.1
## 6 5 24 0.1
## 7 6 1 0.1
## 8 7 4 0.1
## 9 8 7 0.1
## 10 9 2 0.1Q2 – Chi Square GOF Test, minimal
|
---|
|
---|
digit <- c(0,1,2,3,4,5,6,7,8,9) # Last digit
obs <- c(35,0,2,1,4,24,1,4,7,2) # observed counts
q2_full <- data.frame(digit,obs) # combine to make data frame n_size <- sum(obs) # total sample size
|
---|
BIOSTATS 640 - Spring 2023 Unit 4. Categorical Data Analysis (2 of 2) R and Online Apps
|
---|
cat("\np-value =", pvalue)
## p-value = 0sol_categorical 2 of 2.docx Page 8 of 8