proc (1) = gamesim(para,msel,nobs);

local bet1, bet2,

del1, del2,

alp, alp1, alp2,

pim1, pim2, pid1, pid2,

pm1, pm2, pd1, pd2,

yy,

i;

bet1 = para[1];

del1 = para[2];

bet2 = para[3];

if msel[1] == 1;

del2 = para[4];

elseif msel[1] == 2;

del2 = del1;

endif;

alp1 = para[5];

alp2 = para[6];

alp = alp12_to_alp(para[1:6]');

pim1 = bet1 + rndn(nobs,1);

pim2 = bet2 + rndn(nobs,1);

pid1 = pim1 - del1;

pid2 = pim2 - del2;

yy = zeros(nobs,2);

i = 1;

do until i > nobs;

pm1 = pim1[i];

pm2 = pim2[i];

pd1 = pid1[i];

pd2 = pid2[i];

if (pm1<0) AND (pm2<0); yy[i,.] = (0~0);
elseif (pd1>0) AND (pd2>0); yy[i,.] = (1~1);

elseif (pm1 GE 0) AND (pm2 < 0); yy[i,.] = (1~0);
elseif (pm1 < 0) AND (pm2 GE 0); yy[i,.] = (0~1);
elseif (pd1 GE 0) AND (pm2 GE 0) AND (pd2 < 0); yy[i,.] = (1~0);
elseif (pm1 GE 0) AND (pd1 < 0) AND (pd2 GE 0); yy[i,.] = (0~1);
else;
if rndu(1,1) LE alp;
yy[i,.] = (1~0);
else;
yy[i,.] = (0~1);
endif;
endif;
i = i+1;
endo;
**yy = yy~pim1~pim2~pid1~pid2;**

retp(yy);

endp;

## 2 Answers

0

Can anyone explain little about the following three part?

"alp = alp12_to_alp(para[1:6]‘);" I don't understand the logic how do we define variable alp

"if rndu(1,1) LE alp;" why did we put LE alp after rndu(1,1)?

and the line:

**yy = yy~pim1~pim2~pid1~pid2;**

what does "~" means here.

0

- The line below means: if the 1x1 uniform random number created by
`rndu`is less than or equal to the value of the variable`alp`.if rndu(1,1) LE alp;

This line could have been written also this way:

tmp = rndu(1,1); if tmp < alp;

- The line below:
alp = alp12_to_alp(para[1:6]‘);

performs these steps 1) transpose the first 6 elements of

`para`2) Pass those 6 elements in to a user defined procedure called`apl12_to_alp`3) Assign the return from this function call to`alp`. GAUSS always uses square brackets`[]`for indexing. Parentheses`()`are used for function calls and for separating operations i.e. (5*6)+7 vs 5*(6+7) - The tilde operator
`~`performs horizontal concatenation in GAUSS. For example:a = 5; b = 2; c = a~b;

will assign

`c`to be equal to the row vector:5 2

The tilde operator works for scalars, vectors and matrices