Hi,
have a look at the packages distr and distrSim which are on CRAN.
hth
Matthias
- original Nachricht
Betreff: [R] Generic code for simulating from a distribution.
Gesendet: Mo, 10. Apr 2006
Von: [EMAIL PROTECTED]
Hello all,
I have the code below to simulate samples of certain size from a
particular distribution (here,beta distribution) and compute some
statistics for the samples.
betasim2-function(nsim,n,alpha,beta)
{
sim-matrix(rbeta(nsim*n,alpha,beta),ncol=n)
xmean-apply(sim,1,mean)
xvar-apply(sim,1,var)
xmedian-apply(sim,1,median)
simset-data.frame(sampleno=seq1:nsim),means=xmean,vars=xvar,medians=xmedian
)
return(simset)
}
I can write a similar coding for any distribution individually.
Now, I would like to have a generic code, say if I specify the
distribution with the parameters and simulation and sample size I would
like to have the simulations done for the mentioned distribution and the
statistics performed.
I would appreciate any help in doing so?
Thanks for your time.
Mathangi
Mathangi Gopalakrishnan
Graduate student
Dept of Mathematics and Statistics
University of Maryland, Baltimore County
Baltimore, MD
__
R-help@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
--- original Nachricht Ende
__
R-help@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