[R] Probabilities in discrete event simulation model in R
bgunter@4567 @end|ng |rom gm@||@com
Fri Jul 17 00:44:09 CEST 2020
Please read and follow the posting guide linked below when asking for help
here. This is not a "we do the work for you" forum.
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Thu, Jul 16, 2020 at 3:39 PM Shah Alam <dr.alamsolangi using gmail.com> wrote:
> I am designing a programme in R to simulate two events that are 1. a person
> gets cancer, or 2. die of other causes. I have data for the probability of
> getting cancer by age and probability of death due to causes other than
> My dataset has 3 columns 1) age 2) prob getting cancer 3) prob dying
> other causes. I generate random number using runif(1, min = 0, max = 1).
> This random number compares with all the values in the second column
> (prob getting cancer) and give the age which has the same value of
> probability as this random number. Then it compares with all the values
> the 3rd column and gives the age at which women die because of causes
> than cancer.
> The problem is:
> I want an R code in which the random number compares in both the columns
> simultaneously (prob of getting cancer, and prob of death) step by step.
> for example, if the random number is 0.2, first the code checks the
> observation 1 in the column of getting cancer if it fails to get the
> values. Then it checks the observation 1 in the column of death due to
> other causes. If it fails then move to 2nd observation of prob getting
> cancer............ The process should go on until it finds the age which
> has the same value of probability as this random number. Kindly help me
> how to do this in R.
> [[alternative HTML version deleted]]
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help