Why is my risk ratio reported to be 1 with NA-NA confidence interval?

69 views Asked by At

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:

enter image description here

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?

1

There are 1 answers

0
Katie On

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")**)