[R] temporal simulation
Huntsinger, Reid
reid_huntsinger at merck.com
Thu Oct 10 18:44:52 CEST 2002
One way to do this (for the interval [0,T]) is to first generate the total
count n (from a mixture of Poissons), then generate an iid sample of n draws
from the normalized intensity (representing the event times). (Then you
probably want to sort them.)
How to do these steps depends on the mixing distribution and normalized
intensity. If the mixing distribution is discrete, say contained in vectors
"intensity" (intensity value) and "p" (probability), you could generate a
vector of N counts from the mixture as follows:
lambda <- sample(x=intensity, size=N, replace=TRUE, prob=p)
n <- rpois(n=N,lambda=lambda)
In general you need a way like "sample" to draw a sample from your mixing
distribution (and your normalized intensity). The "r" functions (rgamma,
etc) might help if you are using common distributions.
For example if you wanted a constant intensity, you could use runif as
follows to get a list of N draws from the process:
draws <- runif(sum(n),min=0,max=T) # all strung together
f <- rep(1:N,n) # vector indicates group
# membership (simulation trial #) of
event
sim <- split(draws,f) # chop draws up into trial i with n[i]
events
Reid Huntsinger
-----Original Message-----
From: Elaine Hand [mailto:hande at tcd.ie]
Sent: Tuesday, October 08, 2002 7:04 AM
To: r-help at stat.math.ethz.ch
Subject: [R] temporal simulation
Hello,
I am new to R and was wondering if anybody would be able to advice me
on the following query. Is there any package available to generate a
mixed Poisson process, temporal data, using R? If anybody has
accomplished this before or has any advice I would appreciate it.
Regards,
Elaine Hand
--
Elaine Hand
Department of Community Health & General Practice
Trinity College Dublin
Trinity Centre for Health Sciences
AMNCH
Dublin 24
Ireland
email: hande at tcd.ie
telephone: +353 1 608 3460
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._
------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by e-mail and then delete it.
==============================================================================
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list