hello, I asked about this simulation a few days ago, but still i can't get what i need. I have 2 units: icu and regular. from icu I want to take 200 observations from binomial distribution, when probability for disease is: p=0.6. from regular I want to take 300 observation with the same probability: p=0.6 . the distribution to detect disease when disease occurred- *for someone from icu* - is: p(T+ | D+)=0.95. the distribution to detect disease when disease occurred- *for someone from reg.unit* - is: p(T+ | D+)=0.8. I want to compute the joint distribution for each unit: p(T+,D+) for icu, and the same for reg. I tried:
pdeti <- 0 pdetr <- 0 picu <- pdeti*.6 preg <- pdetr*.6 dept <- c("icu","reg") icu <- rbinom(200, 1, .6) reg <- rbinom(300, 1, .6) for(i in 1:300) { if(dept=="icu") pdeti==0.95 if (dept=="reg") pdetr==0.80 } print(picu) print(preg) and got 50 warnings: the condition has length > 1 and only the first element will be used in: if (dept == "icu") pdeti == 0.95 the condition has length > 1 and only the first element will be used in: if (dept == "reg") pdetr == 0.8 I would appreciate any suggestions, thank you, Sigalit. [[alternative HTML version deleted]] ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.