[R] Probabilities in discrete event simulation model in R

Bert Gunter 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.

Bert Gunter

"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
> cancer.
>
>    1.
>
>    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).
>    2.
>
>    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
> in
>    the 3rd column and gives the age at which women die because of causes
> other
>    than cancer.
>
> The problem is:
>
>    1.
>
>    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
> same
>    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
> on
>    how to do this in R.
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list