Dear Statalisters:
I'm not sure if this is a Stata question or a calculus question, but how does Stata calculate the marginal effects ("Margefct", last column) in "prchange"?
Here is some output from a logit model for the probability of having lived abroad with one continuous regressor (Inc1K, income in thousands / month) and one binary regressor, having family members abroad or no (FamAbroad):
LivedAbroad Coef. Std. Err. z P>z [95% Conf. Interval]
FamAbroad 1.391555 .1624504 8.57 0.000 1.073158 1.709952
Inc1K .0021335 .0187338 0.11 0.909 -.0345841 .0388511
_cons -2.777322 .1520807 -18.26 0.000 -3.075394 -2.479249
And here is the output from "prchange":
logit: Changes in Probabilities for LivedAbroad
min->max 0->1 -+1/2 -+sd/2 MargEfct
FamAbroad 0.1424 0.1424 0.1418 0.0693 0.1375
Inc1K 0.0043 0.0002 0.0002 0.0008 0.0002
0 1
Pr(y|x) 0.8889 0.1111
FamAbroad Inc1K
x= .495948 3.73314
sd_x= .500119 3.57373
The question is, how does "prchange" calculate the last column, described in the help file as the "partial derivative of the predicted probability or predicted rate with respect to the
independent variables." I've tried a couple of possibilities to calculate this by hand:
1) f(x+1) - f(x)
This seems to work for the continuous regressor, Inc1K:
. display [1 / (1+exp(-(1.391555*.495948 + 4.37314*.0021335 - 2.777322)))] - [1 / (1+exp(-(1.391555*.495948 + 3.37314*.0021335 - 2.777322)))]
.0002108
but not for the binary regressor:
. display [1 / (1+exp(-(1.391555*1.495948 + 3.37314*.0021335 - 2.777322)))] - [1 / (1+exp(-(1.391555*.495948 + 3.37314*.0021335 - 2.777322)))]
.22332479
2) The partial derivative of logit_-1(x), or exp(x) / (1+exp(x)), that is:
exp(x) / (exp(x)+1) - exp(2x) / (exp(x)+1)^2
. display exp(.0021355*3.37314) / (exp(3.37314*.0021335) + 1) - exp(2*.0021355*3.37314) / (exp(.0021355*3.37314) +1)^2
.24999846
All to no avail.
Somebody, throw me a bone here, please!
Thanks,
David
I'm not sure if this is a Stata question or a calculus question, but how does Stata calculate the marginal effects ("Margefct", last column) in "prchange"?
Here is some output from a logit model for the probability of having lived abroad with one continuous regressor (Inc1K, income in thousands / month) and one binary regressor, having family members abroad or no (FamAbroad):
LivedAbroad Coef. Std. Err. z P>z [95% Conf. Interval]
FamAbroad 1.391555 .1624504 8.57 0.000 1.073158 1.709952
Inc1K .0021335 .0187338 0.11 0.909 -.0345841 .0388511
_cons -2.777322 .1520807 -18.26 0.000 -3.075394 -2.479249
And here is the output from "prchange":
logit: Changes in Probabilities for LivedAbroad
min->max 0->1 -+1/2 -+sd/2 MargEfct
FamAbroad 0.1424 0.1424 0.1418 0.0693 0.1375
Inc1K 0.0043 0.0002 0.0002 0.0008 0.0002
0 1
Pr(y|x) 0.8889 0.1111
FamAbroad Inc1K
x= .495948 3.73314
sd_x= .500119 3.57373
The question is, how does "prchange" calculate the last column, described in the help file as the "partial derivative of the predicted probability or predicted rate with respect to the
independent variables." I've tried a couple of possibilities to calculate this by hand:
1) f(x+1) - f(x)
This seems to work for the continuous regressor, Inc1K:
. display [1 / (1+exp(-(1.391555*.495948 + 4.37314*.0021335 - 2.777322)))] - [1 / (1+exp(-(1.391555*.495948 + 3.37314*.0021335 - 2.777322)))]
.0002108
but not for the binary regressor:
. display [1 / (1+exp(-(1.391555*1.495948 + 3.37314*.0021335 - 2.777322)))] - [1 / (1+exp(-(1.391555*.495948 + 3.37314*.0021335 - 2.777322)))]
.22332479
2) The partial derivative of logit_-1(x), or exp(x) / (1+exp(x)), that is:
exp(x) / (exp(x)+1) - exp(2x) / (exp(x)+1)^2
. display exp(.0021355*3.37314) / (exp(3.37314*.0021335) + 1) - exp(2*.0021355*3.37314) / (exp(.0021355*3.37314) +1)^2
.24999846
All to no avail.
Somebody, throw me a bone here, please!

Thanks,
David
Comment