Hi Oarabile, I'm not sure to full understand how you plan to use your function ... but it seems that do.call("rbind", ...) should address your concern. HTH, Best regards F
----- Original Message ----- From: "Oarabile Molaodi" <[EMAIL PROTECTED]> To: <r-help@r-project.org> Sent: Tuesday, October 16, 2007 11:47 AM Subject: [R] simulation >I am trying to write a function that will simulate observed counts X and > Y as below, I want the function to be able give many replicates, can > somebody advise? > thanks > Oarabile > > #alpha,n sdx and sdy are constant, and N is a vector of length n. > unstructured<-function(n,N,alpha,sdx,sdy){ > Vx<-rnorm(n,mean=0,sd=sdx) > Vy<-rnorm(n,mean=0,sd=sdy) > thetax<-exp(alpha+Vx) > thetay<-exp(alpha+Vy) > X<-rpois(n,N*thetax) > Y<-rpois(n,N*thetay) > data.frame(X,Y) > } > set.seed() > unstructured() > > -- > Mrs Oarabile Ruth Molaodi > Department of Statistics and Modelling Science > University of Strathclyde > Livingstone Tower > 26 Richmond Street > Glasgow > G1 1XH > United Kingdom > > Tel: +44 141 548 3598 (office) > +44 7875087093 (mobile) > Fax: +44 141 552 2079 > > ______________________________________________ > R-help@r-project.org 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. > > ______________________________________________ R-help@r-project.org 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.