Empty Range
Empty Range
Hello,
I'm trying to draw the histogram of a series BOA, graphs it as a bar graph, overlay it with the normal density with the sample mean and variance, and display
the mean, standard deviation, skewness and kurtosis in the upper right corner.
I have used the following code:
density(maxgrid=50,type=histogram) BOA / fBOA dBOA
set nBOA = 1.0/sqrt(%variance)*%density((fBOA-%mean)/sqrt(%variance))
spgraph
scatter(style=bargraph,overlay=line,ovsamescale,header="Bank of America") 2
# fBOA dBOA
# fBOA nBOA
display(store=s) "Mean" %mean "\\Std Error" sqrt(%variance) $
"\\Skewness" %skewness "\\Excess Kurtosis" %kurtosis
grtext(position=upright) s
spgraph(done)
This works fine when I use it for all the observations (3200 approximately). However, when I used this for a lesser range by specifying a different time period in the Data command and then run the code, I get the error "nBOA is an empty range".
Why is this happening?
Thanks!
I'm trying to draw the histogram of a series BOA, graphs it as a bar graph, overlay it with the normal density with the sample mean and variance, and display
the mean, standard deviation, skewness and kurtosis in the upper right corner.
I have used the following code:
density(maxgrid=50,type=histogram) BOA / fBOA dBOA
set nBOA = 1.0/sqrt(%variance)*%density((fBOA-%mean)/sqrt(%variance))
spgraph
scatter(style=bargraph,overlay=line,ovsamescale,header="Bank of America") 2
# fBOA dBOA
# fBOA nBOA
display(store=s) "Mean" %mean "\\Std Error" sqrt(%variance) $
"\\Skewness" %skewness "\\Excess Kurtosis" %kurtosis
grtext(position=upright) s
spgraph(done)
This works fine when I use it for all the observations (3200 approximately). However, when I used this for a lesser range by specifying a different time period in the Data command and then run the code, I get the error "nBOA is an empty range".
Why is this happening?
Thanks!
Re: Empty Range
I ran the code again as I hadn't saved the code.
Now I am getting the same error message again whereas before it was giving me the graph!
Now I am getting the same error message again whereas before it was giving me the graph!
Re: Empty Range
Is there a reason that you're not just using the @HISTOGRAM procedure? It looks like you've cut the main elements out of that and tried to rename it rather than just use the procedure directly. Offhand, if you don't do a STATISTICS instruction first, %VARIANCE won't be defined and you'll get NA's for the computed density, but again, just use the procedure itself rather than trying to re-invent it.
Re: Empty Range
Thanks Tom!
After a while I realized I hadn't put the statistics instruction a d this solved my problem.
However, the problem with different time ranges remains.
A very stupid question: how do you use the procedure files such as @histogram? Do you simply copy and replace x with your own variable name? I did do that but I was getting an error after distrib==2.
Or is there another way?
Thanks!
After a while I realized I hadn't put the statistics instruction a d this solved my problem.
However, the problem with different time ranges remains.
A very stupid question: how do you use the procedure files such as @histogram? Do you simply copy and replace x with your own variable name? I did do that but I was getting an error after distrib==2.
Or is there another way?
Thanks!
Re: Empty Range
No. That's exactly what procedure are designed to avoid. See
https://estima.com/ratshelp/index.html? ... edure.html
https://estima.com/ratshelp/index.html? ... edure.html