'Why is my risk ratio reported to be 1 with NA-NA confidence interval?
I am trying to calculate the risk ratio for coinfection using the code:
*NET_post4['VCandShig']<-NA
NET_post4$VCandShig <- ifelse(NET_post4$VC=="Negative"& !is.na(NET_post4$VC) | NET_post4$Shigella=="Negative" & !is.na(NET_post4$Shigella), "No", "Coinf")
NET_post4$VCandShig <- ifelse(is.na(NET_post4$VC) & is.na(NET_post4$Shigella),NA,NET_post4$VCandShig)
table(NET_post4$VCandShig)
riskratio(NET_post4$VCandShig,NET_post3$SD_Cat)*
I receive the following result:
The 2x2 is correct but why is the RR estimate 1.0 with CI NA to NA? Manually I calculate based on the 2x2 that the RR is (1/9)/(74/440)=0.66
Is my code causing this problem in some way? How can I fix it?
Solution 1:[1]
A friend of mine pointed out that the problem can be fixed by reversing the row order of the 2x2 table with simply rev(c("rows")) so the final code is
NET_post4['VCandShig']<-NA
NET_post4$VCandShig <- ifelse(NET_post4$VC=="Negative"& !is.na(NET_post4$VC) | NET_post4$Shigella=="Negative" & !is.na(NET_post4$Shigella), "No", "Coinf")
NET_post4$VCandShig <- ifelse(is.na(NET_post4$VC) & is.na(NET_post4$Shigella),NA,NET_post4$VCandShig)
table(NET_post4$VCandShig)
riskratio(NET_post4$VCandShig,NET_post3$SD_Cat,**rev = c("rows")**)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | TylerH |