# Re: [R] select a range od distributions for simulation experiment

From: maiya <maja.zaloznik_at_gmail.com>
Date: Mon, 26 May 2008 10:03:50 -0700 (PDT)

I admit, that was a very half-baked way to ask a question. Here instead is a version of code I have, to make it clearer:

oldpar<-par(mfrow=c(4,4), mar=c(2,2,1,1)) sds<- data.frame(sd.cells=numeric(0), sd.margins=numeric(0)) for (i in 1:2){

for (j in 1:2) {
dist<-rbeta(100000, j*0.5,i*0.5)
plot(density(dist), main="", xlab="", ylab="") s<-sample(dist, 25)
s<-100*s/sum(s)
hist(s, main="", xlab="", ylab="")
pop<-matrix(s, c(5,5))
mosaicplot(pop, main="", xlab="", ylab="") mars<-c(margin.table(pop,1), margin.table(pop,2)) hist(mars, main="", xlab="", ylab="", probability=TRUE) lines(density(mars))
rug(c(margin.table(pop,1), margin.table(pop,2)), col="red") sds<-rbind(sds,c(sd(s),sd(mars)))

}
}
par(oldpar)
sds

This loops through four different beta distributions (1st. graph), and in each case samples 25 values (2.nd graph), to become "cell sizes" in a 5x5 crosstabulation of 100 (cells arranged randomly) (3rd graph) after which I am interested in the marginal distributions (both margins together in this case, but this is irrelevant to my question) (4th graph). I am only visualising this at this point, but i am actually interested in the table of standard deviations of cell sizes and marginal totals (sds).

What I would like is to loop this through a series of distributions, which would give me a whole range of cell size distributions, from all of them being aproximatley equaly sized, to extremes, where e.g. most cells would have values close to zero and only one or two would contain the majority - the sort of extremes that arise e.g. if you change the distribution code into this:
dist<-rbeta(100000, j*0.01,i*0.1)

the idea is to get a whole range of posible combinations of sds of cell and margin distributions

Hope this makes a little more sense!

cheers,
maia

```--
View this message in context: http://www.nabble.com/select-a-range-od-distributions-for-simulation-experiment-tp17464269p17475527.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help