Page 1 of 1

Empty Range

Posted: Wed Sep 05, 2018 12:23 am
by humyra
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!

Re: Empty Range

Posted: Wed Sep 05, 2018 6:47 am
by humyra
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!

Re: Empty Range

Posted: Wed Sep 05, 2018 11:39 pm
by TomDoan
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

Posted: Thu Sep 06, 2018 12:47 am
by humyra
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!

Re: Empty Range

Posted: Thu Sep 06, 2018 9:38 am
by TomDoan
No. That's exactly what procedure are designed to avoid. See

https://estima.com/ratshelp/index.html? ... edure.html