[Urgent] Marginal effects in probit
Moderators: EViews Gareth, EViews Moderator
[Urgent] Marginal effects in probit
Hello,
I have a quick question:
For a probit model I plan to report standard errors along with my marginal effects. Are the standard errors I should report in the default estimation output pane, or do I need to compute them for the marginal effects by some method? (I can't seem to even find the answer to this in Wooldridge, of all places!)
I thought I'd found a possible calculation method of these standard errors on p261 of the user guide which talks about Forecasting, but I'm not sure if this option will be possible given my dataset (3D unbalanced panel).
Thanks very much for any help
P.S. Big fan of the program :) Much easier than doing battle with Stata!
And just to add to the above, I assume that the probabilities in the estimation output are the same for the output coefficients and marginal effects?
I have a quick question:
For a probit model I plan to report standard errors along with my marginal effects. Are the standard errors I should report in the default estimation output pane, or do I need to compute them for the marginal effects by some method? (I can't seem to even find the answer to this in Wooldridge, of all places!)
I thought I'd found a possible calculation method of these standard errors on p261 of the user guide which talks about Forecasting, but I'm not sure if this option will be possible given my dataset (3D unbalanced panel).
Thanks very much for any help
P.S. Big fan of the program :) Much easier than doing battle with Stata!
And just to add to the above, I assume that the probabilities in the estimation output are the same for the output coefficients and marginal effects?
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: [Urgent] Marginal effects in probit
At what values are you going to evaluate the marginal effects? How many coefficients do you have?
Re: [Urgent] Marginal effects in probit
I've computed all of my marginal effects at the means. I'd also like to calculate the marginal effects given a 1 s.d. change in the variable, but it's not too essential.
I've got minimum 6 coefficients (plus 10 country dummies); maximum 11 coefficients (plus 10 country dummies).
I've got minimum 6 coefficients (plus 10 country dummies); maximum 11 coefficients (plus 10 country dummies).
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: [Urgent] Marginal effects in probit
For each of the marginal effects for which you want the standard error, you can feed the expression into the Wald test. That'll compute the local (delta method) linear approximation to the standard error for you and report it as part of the test results.
Re: [Urgent] Marginal effects in probit
I'm not totally sure how to do that, could you give a couple more hints? :)
For the variable for which I'm looking to calculate a marginal effect, I should run it through the Wald coefficient-restriction test (at any value) and use that s.e.?
(I couldn't see any Wald test within the meffects vector series i've computed).
Sorry to keep bothering you!
For the variable for which I'm looking to calculate a marginal effect, I should run it through the Wald coefficient-restriction test (at any value) and use that s.e.?
(I couldn't see any Wald test within the meffects vector series i've computed).
Sorry to keep bothering you!
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: [Urgent] Marginal effects in probit
The Wald is on the original equation.
How did you compute the effects?
How did you compute the effects?
Re: [Urgent] Marginal effects in probit
Ah Ok that is what I was trying.
Say my first variable was imp_pen. Its s.e. in the regression output is 0.183955.
I'd do View, Coefficient Diagnostics, Wald-Coefficient Restrictions and write c(1) = 0
Whichever value I set c(1) equal to I'll get the same s.e. , which is the same as the s.e. in the regression output. I've attached a screenshot of the output I get from the Wald test.
----
Computing marginal effects:
Let's say my equation's called probit3
I computed the effects by:
1) Forecasting eq01 using Forecast, Index - where... say into initf_probit3
2) scalar meffect_probit3 = @dnorm(-@mean(initf_probit3))
3) vector meffects_probit3 = meffect_probit3*probit3.@coefs
As instructed on one of the help posts.
Thanks again!
Say my first variable was imp_pen. Its s.e. in the regression output is 0.183955.
I'd do View, Coefficient Diagnostics, Wald-Coefficient Restrictions and write c(1) = 0
Whichever value I set c(1) equal to I'll get the same s.e. , which is the same as the s.e. in the regression output. I've attached a screenshot of the output I get from the Wald test.
----
Computing marginal effects:
Let's say my equation's called probit3
I computed the effects by:
1) Forecasting eq01 using Forecast, Index - where... say into initf_probit3
2) scalar meffect_probit3 = @dnorm(-@mean(initf_probit3))
3) vector meffects_probit3 = meffect_probit3*probit3.@coefs
As instructed on one of the help posts.
Thanks again!
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: [Urgent] Marginal effects in probit
This code isn't production quality, but it (or a suitably error corrected version) should do the trick. The code assumes that the equation of interest is named EQ01 and that it is specified by list. It creates svectors COEFS, VARS, and EXPR, and a vector MEANS which may be deleted upon completion. There are ways of doing this without these temps, but it was easier for debugging purposes. Note also that the means are computed for the workfile sample, which may not be the same as the estimation sample. This assumption may be modified as necessary.
Basically, I build up a string for the marginal effects as a function of the coefficient then feed it into the Wald test. It is possible that you'll run into length restrictions on the Wald test. If so, we can modify this so it does each of the effects individually.
As a check of the computations, the restrictions in the Wald output should match your current effects calculations. If not, we'll have to see what we're doing differently.
Copy and run this in a program after changing all of the "EQ01" to the name of your equation.
Basically, I build up a string for the marginal effects as a function of the coefficient then feed it into the Wald test. It is possible that you'll run into length restrictions on the Wald test. If so, we can modify this so it does each of the effects individually.
As a check of the computations, the restrictions in the Wald output should match your current effects calculations. If not, we'll have to see what we're doing differently.
Code: Select all
%coefs = @lower(eq01.@coeflist)
%vars = @wmid(@lower(eq01.@varlist), 2)
svector coefs = @wsplit(%coefs)
svector vars = @wsplit(%vars)
svector(@rows(coefs)) expr
' get the mean expression
vector(@rows(coefs)) means
%spec = ""
for !i = 1 to @rows(coefs)
%v = vars(!i)
means(!i) = @mean({%v})
if (@length(%spec) > 0) then
%spec = %spec + " + "
endif
%spec = %spec + coefs(!i)
if (vars(!i) <> "c") then
%spec = %spec + "*means(" + @str(!i) + ")"
endif
next
' get the final expression
%spec = "@dnorm(-(" + %spec + "))"
for !i = 1 to @rows(expr)
expr(!i) = coefs(!i) + "*" + %spec
next
' get the wald expression
%wald = ""
for !i = 1 to @rows(expr)
if (@length(%wald) > 0) then
%wald = %wald + " , "
endif
%wald = %wald + expr(!i) + "=0"
next
' compute the wald for the restrictions
eq01.wald {%wald}
Re: [Urgent] Marginal effects in probit
Thanks Glenn.
Impressive stuff!
So I've tried the code. It seems to work pretty well. The first screenshot - 'Wald S.E.s' - should show the calculation which seems to be good.
However, the program seems to run into problems when it tries to include either @trend [<@TREND is an illegal or reserved name in "MEANS(12)=@MEAN(@TREND)>] or my country dummies [<"Scalar sent to function which operates on a matrix in "MEANS(12)=@MEAN(COUNTRY="ECUADOR")">]. Is there a workaround for this?
I think this perhaps meant that I couldn't compare the statistics as you asked? I'll include a snapshot of the Wald test comparisons in a post below.
Just another couple of hopefully quick ones!
1) Will the p-values I get in the estimation output be the same as the ones I'll eventually end up with for the marginal effects?
2) What would be the quickest and easiest way to go about computing the estimation sample? (It's quite unlikely to be similar for my dataset)
Thanks again for all your help so far!
Impressive stuff!
So I've tried the code. It seems to work pretty well. The first screenshot - 'Wald S.E.s' - should show the calculation which seems to be good.
However, the program seems to run into problems when it tries to include either @trend [<@TREND is an illegal or reserved name in "MEANS(12)=@MEAN(@TREND)>] or my country dummies [<"Scalar sent to function which operates on a matrix in "MEANS(12)=@MEAN(COUNTRY="ECUADOR")">]. Is there a workaround for this?
I think this perhaps meant that I couldn't compare the statistics as you asked? I'll include a snapshot of the Wald test comparisons in a post below.
Just another couple of hopefully quick ones!
1) Will the p-values I get in the estimation output be the same as the ones I'll eventually end up with for the marginal effects?
2) What would be the quickest and easiest way to go about computing the estimation sample? (It's quite unlikely to be similar for my dataset)
Thanks again for all your help so far!
- Attachments
-
- Wald S.E.s.jpg (173.75 KiB) Viewed 15293 times
Re: [Urgent] Marginal effects in probit
Wald test
- Attachments
-
- Wald vs. Wald.JPG (166.4 KiB) Viewed 15292 times
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: [Urgent] Marginal effects in probit
As I said, the code I wrote isn't quite robust to everything: auto-series, for one
We can make it robust at the expense of some efficiency.
The modifications do two things: they use a temp series to compute the mean of the series, and they do so for the subsample of observations defined by those where the residual of the equation is defined. The latter will handle the sample.
To answer the questions:
1. The p-values for the marginal effects will differ since the latter are derived from nonlinear functions of all of the parameters, evaluated at the means. That's why we are using the Wald test routine since it computes the standard errors of nonlinear functions of parameters.
2. The code above should handle the sample.
We can make it robust at the expense of some efficiency.
Code: Select all
%coefs = @lower(eq01.@coeflist)
%vars = @wmid(@lower(eq01.@varlist), 2)
%coefs = @lower(eq01.@coeflist)
%vars = @wmid(@lower(eq01.@varlist), 2)
svector coefs = @wsplit(%coefs)
svector vars = @wsplit(%vars)
svector(@rows(coefs)) expr
eq01.makeresid eq01res
' get the mean expression
vector(@rows(coefs)) means
%spec = ""
for !i = 1 to @rows(coefs)
%v = vars(!i)
if (@length(%spec) > 0) then
series temp = @mean( {%v}, "if eq01res <>na")
means(!i) = @mean(temp)
%spec = %spec + " + "
endif
%spec = %spec + coefs(!i)
if (vars(!i) <> "c") then
%spec = %spec + "*means(" + @str(!i) + ")"
endif
next
' get the final expression
%spec = "@dnorm(-(" + %spec + "))"
for !i = 1 to @rows(expr)
expr(!i) = coefs(!i) + "*" + %spec
next
' get the wald expression
%wald = ""
for !i = 1 to @rows(expr)
if (@length(%wald) > 0) then
%wald = %wald + " , "
endif
%wald = %wald + expr(!i) + "=0"
next
' compute the wald for the restrictions
eq01.wald {%wald}
To answer the questions:
1. The p-values for the marginal effects will differ since the latter are derived from nonlinear functions of all of the parameters, evaluated at the means. That's why we are using the Wald test routine since it computes the standard errors of nonlinear functions of parameters.
2. The code above should handle the sample.
Re: [Urgent] Marginal effects in probit
Cracking!
And do I get t- statistics (or will they be F-statistics) from this by dividing the resulting values by their corresponding S.E.s?
Thanks!
And do I get t- statistics (or will they be F-statistics) from this by dividing the resulting values by their corresponding S.E.s?
Thanks!
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: [Urgent] Marginal effects in probit
They'll be t-stats for the individual marginal effects, evaluated at the means. The Wald test result at the top will give you the probability on the joint hypothesis that all are zero. Again, double check that you get what you got when you computed the marginal effects by hand...
Re: [Urgent] Marginal effects in probit
First of all, great idea, it's so useful to code the calculation of Probit marginal effects. I have just have two questions:
1. In the code, the means are evaluated using @dnorm, however wooldridge (2006) in chapter 17 evaluates his Probit marginal effect using the standard normal CDF, why don't we use @cnorm?
2. If it's not too much hassle, could you add a feature to the code so that the marginal effect is calculated based on a configurable unit increase? As it stands they are all evaluated at the mean, which is the most useful. However, in some cases, it may be useful to specify a value to evaluate it at. Like say a variable for children less than 6 as in the example, in Wooldridge 17.1 he shows how going from 0 to 1 unit change in x affects probability that y=1, and then how going from 1 unit to 2 in x affects y=1, as the marginal effect diminishes in the probit model.
Thanks for this program in the first place.
I tried my best to explain it, but sometimes a picture makes things more comprehensible.
1. In the code, the means are evaluated using @dnorm, however wooldridge (2006) in chapter 17 evaluates his Probit marginal effect using the standard normal CDF, why don't we use @cnorm?
2. If it's not too much hassle, could you add a feature to the code so that the marginal effect is calculated based on a configurable unit increase? As it stands they are all evaluated at the mean, which is the most useful. However, in some cases, it may be useful to specify a value to evaluate it at. Like say a variable for children less than 6 as in the example, in Wooldridge 17.1 he shows how going from 0 to 1 unit change in x affects probability that y=1, and then how going from 1 unit to 2 in x affects y=1, as the marginal effect diminishes in the probit model.
Thanks for this program in the first place.
I tried my best to explain it, but sometimes a picture makes things more comprehensible.
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: [Urgent] Marginal effects in probit
Presumably you'd use the @cnorm if you are comparing the difference between two unit values of a variable (like your children example). In this case, you'd probably want to use a model to solve the probabilities under different scenarios.
http://www.eviews.com/help/helpintro.ht ... 038.2.html
has a discussion of a similar computation. Scroll down to Demonstrations.
http://www.eviews.com/help/helpintro.ht ... 038.2.html
has a discussion of a similar computation. Scroll down to Demonstrations.
Who is online
Users browsing this forum: No registered users and 2 guests
