[R] simulation

Dimitris Rizopoulos Dimitris.Rizopoulos at med.kuleuven.be
Tue May 1 09:34:47 CEST 2007


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)))


I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
      http://www.student.kuleuven.be/~m0390867/dimitris.htm


Quoting Thür Brigitte <Brigitte.Thuer at swica.ch>:

>
> Hello
>
> I would like to simulate datasets in the following way:
>
> x <- rpois(999, 2000)
> y <- sum(exp(rgamma(x, scale=2, shape=0.5)))
>
> The problem is, that by calling "y" I just get 1 value back and not   
> 999 values. Can anyone help me? Thanks!
>
> Brigitte
>
>
>
>
>
>
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>
>



Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



More information about the R-help mailing list