Skip to content

R-dvel [robustness Simulation study of 2 sample test on several combination of factors ]

3 messages · tan sj, Jim Lemon, Michael Friendly

#
hi, i am new in this field.


do
favorite<http://stackoverflow.com/questions/36404707/simulation-study-of-2-sample-test-on-different-combination-of-factors#>


If I wish to conduct a simulation on the robustness of two sample test by using R language, is that any ways in writing the code?
There are several factors
(sample sizes-(10,10),(10,25),(25,25),(25,50),(25,100),50,25),(50,100), (100,25),(100,100))

(standard deviation ratio- (1.00, 1.50, 2.00, 2.50, 3.00 and 3.50))
distribution of gamma distribution with unequal skewness and equal skewness

I wish to test the pooled variance t test and welch t test and mann whitney by using the above combination of factors. But how can I combine them by using for loop or apply function??
I am intending to use apply function but i am stucking. If i use for loop function, can i use for loop with vectors ?
for (a in c(25,50,100)) #first group of sample sizes
{ for (b in c(25,50,100)) #second group of sample sizes
{ for (d in c(4,4.4,5,6,8)) #different SDs of first sample
the above code is an example that I would like to modified but I found I have different sets of sample sizes.

So if for loop with vectors, as shown in the code above, will the computer run from part (a) 25, to part(b) 25, then to the part (d) 4? then again the rotation 50->50->4.4?

?I hope can hear any news from this website ....please..thanks you.

Regards
sst
#
Hi sst,
You could set up your sample sizes as a matrix if you don't want all
of the combinations:

sample_sizes<-matrix(c(10,10,10,25,25,25,...),nrow=2)

and then use one loop for the sample sizes:

for(ss in 1:dim(sample_sizes)[2]) {
 ss1<-sample_sizes[1,ss]
 ss2<-sample_sizes[2,ss]

then step through your SDs:

for(ssd in  c(4,4.4,5,6,8)) {

Jim
On Tue, Apr 5, 2016 at 11:15 AM, tan sj <sj_style_1125 at outlook.com> wrote:
1 day later
#
On 4/4/2016 9:15 PM, tan sj wrote:
Don't try to code this yourself-- you'll run into a mess.  Instead, use 
the lovely SimDesign package, https://github.com/philchalmers/SimDesign
designed for just this purpose.

There are also some nice tutorial examples on a wiki,
https://github.com/philchalmers/SimDesign/wiki

best,
-Michael