Skip to content

R [loop statement ]

2 messages · tan sj, Jim Lemon

#
hi, i am new in this field.

I am now writing a code in robustness simulation study. I have written a brief code "for loop" for the factor (samples sizes d,std deviation ) , i wish to test them in gamma distribution with equal and unequal skewness, with the above for loop in a single code if possible. Can i ask is that any suitable loop statement for this situation.

This is my ideas ,all the two for loop runs then run for the first set of gamma distribution with equal skewness then store the result,
then,
all the two for loops run again and then run for the second set of gamma distribution with unequal skewness then store the result again.

if-else statement look like is not quite suitable in this situation as it will run one set only.
Please, i hope can get some help here. Thanks.
#
Hi tan sj,
It is by no means easy to figure out what you want without the code,
but If I read your message correctly, you can run the loops either
way. When you have nested loops producing output, it is often a good
idea to include the parameters for each run in the output as well as
the result so that you don't get the results mixed up:

cat(N,mean,...,p.value,"\n")

Jim
On Sat, Apr 16, 2016 at 12:06 PM, tan sj <sj_style_1125 at outlook.com> wrote: