Empty Range

For questions and discussion related to graphs, reports, and other output, including issues related to presenting or publishing results.
humyra
Posts: 30
Joined: Fri Jun 02, 2017 4:26 am

Empty Range

Unread post 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!
humyra
Posts: 30
Joined: Fri Jun 02, 2017 4:26 am

Re: Empty Range

Unread post 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!
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Empty Range

Unread post 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.
humyra
Posts: 30
Joined: Fri Jun 02, 2017 4:26 am

Re: Empty Range

Unread post 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!
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Empty Range

Unread post by TomDoan »

No. That's exactly what procedure are designed to avoid. See

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