Question

Write an R function to produce a confidence interval for the log odds ratio for a 2 by 2 table. Write it so it adds 1 to each cell by default if the cell frequencies are too small using the criterion in the textbook from table 2.3. Post the code for the function followed with a few illustrative examples. Include comments in the function that explain the arguments and how to specify them.

2.2 COMPARING PROPORTIONS IN TWO-BY-TWO TABLES Table 2.3. Cross Classification of Aspirin Use and Myocardial Infarction Myocardial Infarction Group Yes No Total Placebo Aspirin 189 104 10,845 10,933 11,034 11,037 of Source: Preliminary Report: Findings from the Aspirin Component of the Ongoing Physicians Health Study. New Engl. J. Med., 318: 262-264, 1988 ians Health Sltudy, New Eng,

0 0
Add a comment Improve this question Transcribed image text
Answer #1

## Using R software

> ####
>
> Input =("
+ Injection.area Yes No
+ Placebo 189 10845
+ Aspirin 104 10933
+ ")
>
> Matriz = as.matrix(read.table(textConnection(Input),
+ header=TRUE,
+ row.names=1))
>
> Matriz
Yes No
Placebo 189 10845
Aspirin 104 10933
>
> ### Chi-square test
> chisq.test(Matriz)

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

data: Matriz
X-squared = 24.429, df = 1, p-value = 7.71e-07

>
> ### G-test
>
> library(DescTools)
>
> GTest(Matriz,
+ correct="none") # "none" "williams" "yates"

Log likelihood ratio (G-test) test of independence without correction

data: Matriz
G = 25.372, X-squared df = 1, p-value = 4.727e-07

Comment: The estimated p-values form the Chi-square test and G-test is less than 0.05 level of significance. Hence, we can conclude that there is a significant association between the incidence of heart attacks and aspirin intake at 0.05 level of significance.

Add a comment
Know the answer?
Add Answer to:
Write an R function to produce a confidence interval for the log odds ratio for a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT