Hi, that was really helpful about the simulation. Im now trying to find (nâ1)S2/Ï2, and fit it to a chi squared dist with 5 degrees of freedom.
im having trouble with the coding for this. i think for the second part of that i need to use the fitdist function, but to get it to where i am able to do that, im not sure what to do. THis is what i have been trying to do so far, but it hasn't returned me anything good sum((x-mean(x))^2)/(length(x)-1) i am really confused, can someone please help? Cheers ps. if someone knows of a simpler way of creating the simulation in the first place, your input is highly appreciated using your method, im getting a bit confused. > Date: Fri, 15 May 2009 12:16:45 +0100 > From: s.elli...@lgc.co.uk > To: konk2...@hotmail.com > Subject: Re: [R] Simulation > > The tidiest way of doing something 'simple' with a set of B random > samples of size n is often to create a matrix with b rows and n columns, > and then use apply() with a suitable function to get the statistic of > interest. > > For example, in the particular case of exp(1): > > samples<-matrix( rexp(1000*15), ncol=15) #generates a 1000 x 15 > matrix; > #each row is an n=15 sample from > exp(1) > > meds<-apply(samples, 1, median) #applies the function 'median' to each > row and returns the result as a vector > > hist(meds) > > For more complex problems, write a function that can be applied to each > row. For example, look at the distribution of the test statisic for a > wilcoxon test of whether the medians above are centred on 1.0: > > medtest<-function(x) { > wilcox.test(x, mu=1)$statistic #'statistic' is the name of the > calculated test statistic here > #don;t need to 'return' anything because the function returns > #the value of the last expression evaluated. > } > > medsim<-apply(samples,1, medtest) > hist(medsim) > > This trick (form a matrix and use apply()) can also be used to get > multi-parameter stats, 'cos apply will return a matrix or list if the > function returns a vector or list. > > The only snag is the memory usage; for large simulations that can be a > problem. If it is, resorting to looping is still an option. > > Steve E > > >>> Kon Knafelman <konk2...@hotmail.com> 15/05/2009 10:17 >>> > > hey guys, i've been following this discussion about the simulation, and > being a beginner myself, im really unsure of the best method. > > > > I hve the same problem as the initial one, except i need 1000 samples > of size 15, and my distribution is Exp(1). I've adjusted some of the > loop formulas for my n=15, but im unsure how to proceed in the quickest > way. > > > > Can someone please help? > > _________________________________________________________________ > [[elided Hotmail spam]] > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. > > ******************************************************************* > This email and any attachments are confidential. Any use, copying or > disclosure other than by the intended recipient is unauthorised. If > you have received this message in error, please notify the sender > immediately via +44(0)20 8943 7000 or notify postmas...@lgc.co.uk > and delete this message and any copies from your computer and network. > LGC Limited. Registered in England 2991879. > Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK _________________________________________________________________ Looking to change your car this year? Find car news, reviews and more http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641&_t=762955845&_r=tig_OCT07&_m=EXT [[alternative HTML version deleted]]
______________________________________________ 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.