graphing confidence bands
Moderators: EViews Gareth, EViews Moderator
graphing confidence bands
Using eviews 7.
Have estimated a simple regression line with 2 variables, have output as scatter diagram with regression line thru middle.
Is there a simple way to graph confidence interval (95% or other) bands?
Thanks.
HV
Have estimated a simple regression line with 2 variables, have output as scatter diagram with regression line thru middle.
Is there a simple way to graph confidence interval (95% or other) bands?
Thanks.
HV
-
EViews Esther
- EViews Developer
- Posts: 149
- Joined: Fri Sep 03, 2010 7:57 am
Re: graphing confidence bands
Please click the Forecast tab of the equation dialog.
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: graphing confidence bands
Which will do the graph in observation order but not scatterplot order. For the scatterplot, you'll have to add the lines yourself...
Re: graphing confidence bands
looks like I'll have to do it myself for scatter plot. I see the banks in observation order using forecast.
Perhaps EViews can add this as an option to future updates.
Is there an easy way to generate the confidence bands via formula/equation?
thanks.
Perhaps EViews can add this as an option to future updates.
Is there an easy way to generate the confidence bands via formula/equation?
thanks.
Re: graphing confidence bands
looks like I'll have to do it myself for scatter plot. I see the banks in observation order using forecast.
Perhaps EViews can add this as an option to future updates.
Is there an easy way to generate the confidence bands via formula/equation?
thanks.
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3798
- Joined: Wed Sep 17, 2008 2:25 pm
Re: graphing confidence bands
In the Forecast dialog there is a field to specify a new series to contain the standard error of the forecast. So is you name the forecast yf and the standard error yse, you can generate
Except you need to substitute an appropriate critical value in place of 1.96. Then do a scatterplot of x against upper, yf, lower.
Code: Select all
series upper= yf + 1.96*yse
series lower = yf - 1.96*yse-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: graphing confidence bands
The one issue is that unless the workfile is X-sorted, you won't be able to connect the observations with lines to show the band in the usual way. If it's not a time-series workfile, sorting by X is an option.
One issue with providing it as a built-in is that it's only really applicable to bivariate models which I would venture are a small subset of the models estimate. But I do think that it's a natural one for an add-in.
One issue with providing it as a built-in is that it's only really applicable to bivariate models which I would venture are a small subset of the models estimate. But I do think that it's a natural one for an add-in.
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3798
- Joined: Wed Sep 17, 2008 2:25 pm
Re: graphing confidence bands
No, scatter takes care of the ordering, although you may have to mess with the Graph elements/lines and symbols dialog.The one issue is that unless the workfile is X-sorted, you won't be able to connect the observations with lines to show the band in the usual way. If it's not a time-series workfile, sorting by X is an option.
But extraordinarily handy for teaching purposes.One issue with providing it as a built-in is that it's only really applicable to bivariate models which I would venture are a small subset of the models estimate. But I do think that it's a natural one for an add-in.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: graphing confidence bands
I think Glenn is right, you do need the sorting. It is not essential, but the graph will look much better if you have the sorting in place. Especially if you have a nonlinear estimation. Moving into matrix space rather than dealing with workfile sorting is probably easiest.
I'm not in the office, so knocked up this program on my iPhone. No guarantees it doesn't have mistakes in it, since I can't test it on my phone. Hopefully if there are some, they'll be easy to spot.
Open up your equation, then run the program, or register it as an add-in.
I'm not in the office, so knocked up this program on my iPhone. No guarantees it doesn't have mistakes in it, since I can't test it on my phone. Hopefully if there are some, they'll be easy to spot.
Open up your equation, then run the program, or register it as an add-in.
Code: Select all
%fn = @getnextname("yf")
%sen = @getnextname("se")
%mn = @getnextname("fitmat")
%gn = @getnextname("g")
%grn = @getnextname("gr")
%xn = @getnextname("x")
%rn = @getnextname("ranks")
_this.fit {%fn} {%sen}
%varlist = _this.@varlist
if @wcount(%varlist) <> 3 then
@uiprompt("Equation doesn't have 2 regressors")
stop
endif
%dep = @word(%varlist,1)
%reg = @word(%varlist,3)
if %reg = "C" then
%reg = @word(%varlist,2)
endif
group {%gn} {%reg} {%dep} {%fn} {%fn}+1.96*{%sen} {%fn}-1.96*{%sen}
stom({%gn}, {%mn})
stom({%reg}, {%xn})
vector {%rn} = @ranks({%xn})
{%mn} = @capplyranks({%mn}, {%rn})
freeze({%grn}) {%mn}.scat
%depstr = "Fitted " + %dep
%lowstr = "Lower bound"
%uppstr = "Upper bound"
{%grn}.setelem(1) symbol(circle) linecolor(blue) legend(%dep)
{%grn}.setelem(2) symbol(none) lpat(1) linecolor(red) legend(%depstr)
{%grn}.setelem(3) symbol(none) lpat(1) linecolor(green) legend(%uppstr)
{%grn}.setelem(4) symbol(none) lpat(1) linecolor(green) legend(%uppstr)
show {%grn}
d(noerr) {%fn} {%sen} {%mn} {%gn} {%xn} {%rn}
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3798
- Joined: Wed Sep 17, 2008 2:25 pm
Re: graphing confidence bands
Code: Select all
create u 200
series x=nrnd
series y=2+3*x+nrnd
equation eq
eq.ls y c x
eq.fit yf yse
scat x yf yf-1.96*yse yf+1.96*yse-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: graphing confidence bands
Notice how those lines are thick and inconsistent? That's because the same line is being drawn over itself many times. Since it is a straight line, it doesn't matter so much, but I think it is still ugly. Try running my program on it, and you should get a nicer looking graph.
Further, try changing yours so that there is a non-linearity in there, or try estimating log(y) c x. Bet it doesn't look as good then.
Further, try changing yours so that there is a non-linearity in there, or try estimating log(y) c x. Bet it doesn't look as good then.
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: graphing confidence bands
In Gareth's example, I had to change the @ranks function call to be
so that we didn't get fractional ranks on tied values. Also the labeling on the legend isn't quite right
There are a few more minor things as well that I'll leave as a further exercise. This is a nice proof of concept that needs a bit more cleanup.
Code: Select all
vector {%rn} = @ranks({%xn}, "a", "i")Code: Select all
{%grn}.setelem(3) symbol(none) lpat(1) linecolor(green) legend(%lowstr)Who is online
Users browsing this forum: No registered users and 2 guests
