simulation experimentI want to make a simulation experiment, generate 12 random variables, each variable contains 100 observations, so that the variables are subject to heterogeneity problem, and follow the normal distribution
The experiment is repeated 10,000 times.
# I don't know how to do this with JMPpro
Thanks
Advanced Statistical ModelingWindowsRe: simulation experiment"how to make the variables heterogeneous in variance" - does that mean each column needs a different sigma? Do you need 12 randomly chosen sigma values?
"Heteroscedasticity problem" - does that mean you have a function in mind for changing the sigma based on mu? And a function for choosing mu, probably randomly? (I don't have any expertise here, just guessing after a 30 second read.)
I think you'll want to do this using nested for loops. My original suggestion is too simple. You could also use column formulas, but a JSL script will be easier to manage. Nested loops would look something like this
m = J( 100 * 10000, 12, 0 );
for(row=1, row<=nrows(m), row+=1,
for(col=1, col<=ncols(m), col+=1,
m[row,col] = HSD(row,col);
);
);<BR /><BR />dt = astable(m)<BR /><BR />...
You have to write the "HSD" user written function with what you actually want.
You might also want to change the 10000 repeats to 2 or 3 repeats until you decide what the analysis should do. I used summary because it packs all 10K analyses into a data table. You might want to run a platform 10K times, grabbing some results, then closing the platform. You don't want 10K platforms open at once because JMP will run out of memory.
Re: simulation experimentDear Sir
First, thank you very much for helping.
In fact, your script above, comes close to what I want,
but I don't know how to make the variables heterogeneous in variance.
I don't know how to modify your script, such that:
Number of random variables = 12
The number of observations in each variable = 100
And that resulting variables are suffering from Heteroscedasticity problem
With possibility of repeating the experiment 10,000 times
Regards
Re: simulation experimentcheck out a search like this https://www.google.com/search?q=site%3Ajmp.com+Heteroscedasticity to find previous questions that might have good answers in the community. In the google search GUI you can do that with site:jmp.com to limit the results:
site:jmp.com Heteroscedasticitysite:jmp.com Heteroscedasticitysite:jmp.com Heteroscedasticity
I'm not a statistician. The data above is random. The source you point at suggests the data should have some sort of repeat across seasons...not completely random. If 1..12 represents months of the year, it might not make sense to have a January column, a February column, ... It might make a lot more sense to have a date column and a value column.
| date |
value |
| 2020/01 |
7 |
| 2020/02 |
6 |
| 2020/03 |
8 |
I looked up Heteroscedasticity and suspect you'll need a different approach to generating your random numbers so they actually exhibit that trait. Otherwise it is just random with nothing interesting but the mu and sigma passed to random normal, as seen in the graph above.
Just guessing, and way out on a limb...I think you'd have to generate a random mu (normal? uniform?), and a sigma based on that mu, and then use RandomNormal(mu,sigma). Or I might be completely wrong.
Re: simulation experiment
the source:
Random-Coefficient periodic autoregression (repec.org)
Re: simulation experimentDear Sir Craige_Hales
Thank you very much for helping me,
I wanted to do a simulation experiment:
Number of random variables = 12
The number of observations in each variable = 100
And that resulting variables are suffering from Heteroscedasticity problem
# With possibility of repeating the experiment 10,000 times
Re: simulation experimentSummary might be a good start
</CODE></P>
<PRE><CODE class=" language-jsl">dt = As Table( J( 100 * 10000, 12, Random Normal( 0, 1 ) ) );
dt << New Column( "group", formula( Floor( (Row() - 1) / 100 ) + 1 ) );
dt << runformulas;
dt:group << deleteformula;
dt << Go To( group );
dt << Move Selected Columns( To first );
dtsummary = dt << Summary(
Group( :group ),
Mean( :Col1 ),
Min( :Col1 ),
Max( :Col1 ),
Std Dev( :Col1 ),
Mean( :Col2 ),
Min( :Col2 ),
Max( :Col2 ),
Std Dev( :Col2 ),
Freq( "None" ),
Weight( "None" )
);
dtsummary << Graph Builder(
Size( 653, 452 ),
Show Control Panel( 0 ),
Variables(
X( :group ),
Y( :"Mean(Col1)"n ),
Y( :"Min(Col1)"n, Position( 1 ) ),
Y( :"Max(Col1)"n, Position( 1 ) ),
Y( :"Std Dev(Col1)"n, Position( 1 ) ),
Y( :"Mean(Col2)"n, Position( 1 ) ),
Y( :"Min(Col2)"n, Position( 1 ) ),
Y( :"Max(Col2)"n, Position( 1 ) ),
Y( :"Std Dev(Col2)"n, Position( 1 ) )
),
Elements(
Points(
X,
Y( 1 ),
Y( 2 ),
Y( 3 ),
Y( 4 ),
Y( 5 ),
Y( 6 ),
Y( 7 ),
Y( 8 ),
Legend( 7 )
)
)
);
</CODE></P>
<P><SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Color!" style="width: 812px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="Color!" style="width: 812px;"><span class="lia-inline-image-display-wrapper" image-alt="Color!" style="width: 812px;"><img src="https://us.v-cdn.net/6038925/uploads/images/41991iFA52067AFA73F318/Untitled%204%20By%20%28group%29%20-%20Graph%20Builder.png" role="button" title="Untitled 4 By (group) - Graph Builder.png" alt="Color!" /><span class="lia-inline-image-caption" onclick="event.preventDefault();">Color!</span></span><SPAN class="lia-inline-image-caption" onclick="event.preventDefault();">Color!</SPAN></SPAN><SPAN class="lia-inline-image-caption" onclick="event.preventDefault();">Color!</SPAN></SPAN></P></LINGO-BODY><LINGO-SUB id="lingo-sub-481697" slang="en-US" mode="NONE">Re: simulation experiment</LINGO-SUB><LINGO-BODY id="lingo-body-481697" slang="en-US" mode="NONE"><P>I don't know what the heterogeneity problem is, but the rest might look like this:</P>
<P> </P>
<PRE><CODE class=" language-jsl">dt = As Table( J( 100 * 10000, 12, Random Normal( 0, 1 ) ) );
dt << New Column( "group", formula( Floor( (Row() - 1) / 100 ) + 1 ) );
dt << runformulas;
dt:group << deleteformula;
dt << Go To( group );
dt << Move Selected Columns( To first );
Do your analysis with the group variable.
12 million random normal numbers12 million random normal numbers12 million random normal numbers