[R] simulation

Thür Brigitte Brigitte.Thuer at swica.ch
Tue May 1 11:59:54 CEST 2007


Thats exactly what I am looking for! Thanks for your help!


-----Ursprüngliche Nachricht-----
Von: Peter Dalgaard [mailto:p.dalgaard at biostat.ku.dk] 
Gesendet: Dienstag, 1. Mai 2007 11:46
An: Dimitris Rizopoulos
Cc: Thür Brigitte; r-help at stat.math.ethz.ch
Betreff: Re: [R] simulation

Dimitris Rizopoulos wrote:
> maybe you're looking for something like this:
>
> x <- rpois(999, 2000)
> y <- numeric(length(x))
> for (i in seq_along(x))
>      y[i] <- sum(exp(rgamma(x[i], scale = 2, shape = 0.5)))
>
>   
Or use sapply,
sapply(x, function(x) sum(exp(rgamma(x[i], scale = 2, shape = 0.5)) )

or even

replicate(999, sum(exp(rgamma(rpois(1,2000), scale = 2, shape = 0.5)) )

*** eSafe at SWICA scanned this email for malicious content and found it to be 
clean ***



More information about the R-help mailing list