[R] Monte Carlo simulation for ratio and its CI

Marna Wagley m@rn@@w@g|ey @end|ng |rom gm@||@com
Tue Mar 26 00:30:57 CET 2019


Hi R User,
I was trying to calculate ratios with confidence interval using Monte Carlo
simulation but I could not figure it out.
Here is the example of my data (see below), I want to calculate ratios
(dat$v1/dat$v3 & dat$v2/dat$v3) and its confidence intervals using a 100
randomly selected data sets.
Could you please give me your suggestions how I can estimate ratios with
CI?
I will be very grateful to you.
Sincerely,

MW
---
dat<-structure(list(v1 = c(NA, TRUE, TRUE, TRUE, TRUE, TRUE, NA, TRUE,

NA, NA, TRUE, TRUE, TRUE, TRUE, NA, NA, TRUE, TRUE), v2 = c(TRUE,

NA, NA, NA, NA, TRUE, NA, NA, TRUE, TRUE, NA, TRUE, TRUE, NA,

NA, TRUE, TRUE, NA), v3 = c(TRUE, TRUE, NA, TRUE, TRUE, NA, NA,

TRUE, TRUE, NA, NA, TRUE, TRUE, TRUE, NA, NA, TRUE, NA)), .Names = c("v1",

"v2", "v3"), class = "data.frame", row.names = c(NA, -18L))


ratio1<-length(which(dat$v1 == "TRUE"))/length(which(dat$v3 == "TRUE"))

ratio2<-length(which(dat$v2 == "TRUE"))/length(which(dat$v3 == "TRUE"))


Thanks

	[[alternative HTML version deleted]]



More information about the R-help mailing list