[R] simulation

Oarabile Molaodi oarabile at stams.strath.ac.uk
Tue Oct 16 11:47:32 CEST 2007


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



More information about the R-help mailing list