density graph

Econometrics questions and discussions

density graph

Postby ivory4 » Sat Jul 17, 2010 3:13 am

I have a serie generated and from histogram it looks quite bell-shaped.
To draw the density, I use

Code: Select all
density(type=gauss) bn 1 2000 x bnd


x are 100 grids automatically generated using 1%-ile to 99%-ile, why there is a 0.0, because there is no zero in my series?

Code: Select all
compute fract=%fractiles(bn,||.025,.975||)
compute bar = fract(1)
scatter(style=lines,$
header="Figure 3 ",hshade=||0.0,bar||) 1
# x bnd / 1


I want to shade the area left to 2.5%-ile point, but this would shade the whole area, I tried to add a vshade but only real is allowed as arguments. Is there any way to do that?

how do I put text near the shade or in the shade or with an arrow?
ivory4
 
Posts: 149
Joined: Mon Aug 24, 2009 12:16 pm

Re: density graph

Postby TomDoan » Sun Jul 18, 2010 10:07 pm

ivory4 wrote:I have a serie generated and from histogram it looks quite bell-shaped.
To draw the density, I use

Code: Select all
density(type=gauss) bn 1 2000 x bnd


x are 100 grids automatically generated using 1%-ile to 99%-ile, why there is a 0.0, because there is no zero in my series?


SCATTER will round the limits up and down to allow reasonable looking labels.

ivory4 wrote:
Code: Select all
compute fract=%fractiles(bn,||.025,.975||)
compute bar = fract(1)
scatter(style=lines,$
header="Figure 3 ",hshade=||0.0,bar||) 1
# x bnd / 1


I want to shade the area left to 2.5%-ile point, but this would shade the whole area, I tried to add a vshade but only real is allowed as arguments. Is there any way to do that?


That should do what you want. It's possible that the range is so thin that you can't really see much shading. Try something like 10% first.

ivory4 wrote:how do I put text near the shade or in the shade or with an arrow?


Use SPGRAPH..SCATTER..GRTEXT..SPGRAPH(DONE) like

Code: Select all
set bn 1 2000 = %rangamma(5.0)
density(type=gauss) bn 1 2000 x bnd
compute fract=%fractiles(bn,||.025,.975||)
compute bar = fract(1)
spgraph
scatter(style=lines,$
header="Figure 3 ",hshade=||0.0,bar||) 1
# x bnd / 1
grtext(position=upleft) "description"
spgraph(done)
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: density graph

Postby ivory4 » Tue Jul 20, 2010 12:04 pm

How to shade the intersection of two density functions? If HSHADE(VSHADE) is used, it does not allow series as element, but only REAL.
ivory4
 
Posts: 149
Joined: Mon Aug 24, 2009 12:16 pm

Re: density graph

Postby TomDoan » Tue Jul 20, 2010 1:26 pm

I'm not 100% sure of what you mean by the intersection, but see if this is what you want:

Code: Select all
set x  1 500 = .01*t
set f1 1 500 = %density((x-0.5)*4)
set f2 1 500 = %density((x-0.4)*9)
set minf = %min(f1,f2)
scatter(style=line,overlay=polygon,ovsame) 3
# x f1
# x f2
# x minf
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: density graph

Postby ivory4 » Tue Jul 20, 2010 4:21 pm

Yes I would like to shade the area left to 97.5quantile.I think i get it
ivory4
 
Posts: 149
Joined: Mon Aug 24, 2009 12:16 pm

Re: density graph

Postby ivory4 » Fri Jul 23, 2010 6:24 am

Looking at the histogram, it is quite concentrated to the left "tail", like a normal distribution with very high positve skewness.
To use option of GAUSS, it seems inappropriate.
What would be a good choice?
ivory4
 
Posts: 149
Joined: Mon Aug 24, 2009 12:16 pm

Re: density graph

Postby TomDoan » Fri Jul 23, 2010 8:24 am

ivory4 wrote:Looking at the histogram, it is quite concentrated to the left "tail", like a normal distribution with very high positve skewness.
To use option of GAUSS, it seems inappropriate.
What would be a good choice?


The shape of the kernel has very little to do with the shape of the density. Any of them should work reasonably well particularly with a target density that really has no particularly sharp features. The default of the Epanechnikov has certain optimality properties.
The only advantage of the Gaussian kernel over the others is that it's differentiable, which is important only if you need the derivative of the density, and you probably don't.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm


Return to General Econometrics

Who is online

Users browsing this forum: No registered users and 1 guest