Using gret l for Principles of Econometrics, 4th Edition

Standard Errors and Confidence Intervals for Marginal Effects

Obtaining confidence intervals for the marginal effects (and the AME) is relatively straightfor­ward as well. To estimate the standard error of the marginal effect, we resort to the Delta method. This method of finding the variance of functions of parameters was discussed in section 5.3.2. You may want to take a look at this section again (page 99), before proceeding.

Using the Delta method means taking analytic or numerical derivatives of the marginal effect or AME to be used in the computation of the standard error of the AME. The analytic derivatives are not that hard to take, but why bother when numerical ones are available. This is the approach taken in commercial software that includes the ability to estimate nonlinear combinations of parameters and their standard errors.

The function in gretl that takes numeric derivatives is fdjac, which stands for first difference Jacobian. To use the Delta method, you want to take the partial derivatives of a function with respect to the model’s parameters. Not surprisingly, the fdjac function requires two arguments: a function and a vector of parameters. To illustrate its use, consider the new function for marginal effects below.

1 function matrix me1(matrix *param, list x, scalar *q)

2 matrix p = lincomb(x, param)

3 return dnorm(p)*param[q]

4 end function

It is very similar to the ame function, except in this instance we have added an extra scalar input. The scalar *q will be used to locate the desired parameter in the model. So, if we want to compute the marginal effect for x2, and list x = const x2 x3, then q will be set to 2; x2 is the second variable in the list. Rather than return all of the marginal effects, this function only returns the set for a given variable. This makes using fdjac easier to use and to explain.

Once the function is defined, you are ready to use fdjac in the Delta method.

1 open "@gretldirdatapoetransport. gdt"

2 list x = const dtime

3 probit auto x

4 matrix coef = $coeff

5 matrix covmat = $vcv

6 scalar q = 2

7 series mfx = me1(&coef, x, &q)

8 matrix amfx = mean(mfx)

9 matrix jac = fdjac(coef, me1(&coef, x, &q))

10 matrix mjac = meanc(jac)

11 matrix variance = qform(mjac, covmat)

12 matrix se = sqrt(variance)

13 printf "nThe average marginal effect of dtime = %6.4f with

14 standard error %6.4f n", amfx, se

15

15 scalar ub = amfx + critical(z,0.025)*se

16 scalar lb = amfx + critical(z,0.025)*se

17 printf "nThe 95%% confidence interval for the AME is (%6.4f, %6.4f) n",lb, ub

The first six lines of the script are standard. Open the data, create the variable list, estimate the model by probit, create the matrix to hold the coefficients, create the matrix to hold the estimated covariance matrix, and choose the scalar q that identifies the location of the desired marginal effect in the variable list, which in this case is the second one.

Lines 7 and 8 get the sample marginal effects for the second coefficient and their mean. The next line takes the derivative of the marginal effect function using fdjac. Since we used pointers in the function, the ampersand needs to precede the coefficient and scalar inputs.

As shown in the appendix of chapter 16 in POE4, taking the average of the derivatives is what is needed for the variance calculation. In line 11 the quadratic form is taken. Basically, qform(x, A) computes xAxT; this is exactly what is involved in the variance expression in equation (5.10). The square root provides the standard error of the AME. The average marginal effect = 0.0484 with standard error 0.0034. The 95% confidence interval for the AME is (0.0413, 0.0556).

Finally, we can automate the evaluation of marginal effects at certain points. Recall that we computed the marginal effect for someone who is currently taking 20 (dtime=2) minutes longer to travel by bus than auto. The marginal effect was easy enough to compute, but now we want to add a confidence interval. The function will be modified slightly to accept a row vector that contains the values of the explanatory variables at the desired evaluation point. The function is:

1 function matrix me_at(matrix *param, matrix *xx, scalar *q)

2 scalar p = xx*param

3 return dnorm(p)*param[q]

4 end function

Now instead of using lincomb, we use a matrix calculation in line 2. This requires a matrix input in the function definition in line 1, which we have marked with a pointer.

The script to execute this is

1 open "@gretldirdatapoetransport. gdt"

2 list x = const dtime

3 probit auto x

4 matrix coef = $coeff

5 matrix covmat = $vcv

6 scalar q = 2

7 matrix xx = { 1, 2 }

8 matrix mfx = me_at(&coef, &xx, &q)

9 matrix jac = fdjac(coef, me_at(&coef, &xx, &q))

10 matrix variance = qform(jac, covmat)

11 matrix se = sqrt(variance)

12 printf "nThe marginal effect of dtime when dtime=2 is %6.4f with

13 standard error %6.4f n", mfx, se

14

14 scalar ub = mfx + critical(z,0.025)*se

15 scalar lb = mfx + critical(z,0.025)*se

16 printf "nThe 95%% confidence interval the ME with dtime=2 is

17 (%6.4f, %6.4f) n", lb, ub

Lines 3-5 set the inputs to the function. Line 5 is a row vector that has a 1 in the first element for the constant and 2 in the second for dtime. This is sent to the me_at function to get the marginal effect and the fdjac evaluates the derivative with respect to coefficients, coef. Variance is computed using qform and then the standard error is taken from this. The result is:

The marginal effect of dtime when dtime=2 is 0.1037 with standard error 0.0326 The 95% confidence interval the ME with dtime=2 is (0.0397, 0.1677).

A perfect match for the result in POE4. Excellent!

Finally, the predicted probability that a, uto = 1 given a commuting time difference of 30 minutes is calculated and a confidence interval obtained using the Delta method. The function is very similar to the last one and it was used as a template.

1 function matrix mep(matrix *param, matrix *xx, scalar *q)

2 scalar p = xx*param

3 return cnorm(p)

4 end function

Notice that cnorm is used to get the cumulative probability. To use the function,

1 scalar q = 2

2 matrix coef = $coeff

3 matrix xx = { 1, 3 }

4 matrix mp = mep(&coef, &xx, &q)

5 matrix jac_3 = fdjac(coef, mep(&coef, &xx, &q))

6 matrix variance = qform(jac_3,covmat)

7 matrix se = sqrt(variance)

8 printf "nThe probability of driving when dtime=3 is %6.4f with standard

9 error %6.4f n", mp, se

10

її scalar ub = mp + critical(z,0.025)*se

12 scalar lb = mp - critical(z,0.025)*se

13 printf "nThe 95%% confidence interval the Prob with dtime=3 is

14 (%6.4f, %6.4f) n",lb, ub

The probability of driving when dtime=3 is 0.7983 with standard error 0.1425. The 95% confi­dence interval with dtime=3 is (0.5189, 1.0777). Obviously, the upper bound is not feasible since probabilities cannot exceed 1.

Добавить комментарий

Using gret l for Principles of Econometrics, 4th Edition

Simulation

In appendix 10F of POE4, the authors conduct a Monte Carlo experiment comparing the performance of OLS and TSLS. The basic simulation is based on the model y = x …

Hausman Test

The Hausman test probes the consistency of the random effects estimator. The null hypothesis is that these estimates are consistent-that is, that the requirement of orthogonality of the model’s errors …

Time-Varying Volatility and ARCH Models: Introduction to Financial Econometrics

In this chapter we’ll estimate several models in which the variance of the dependent variable changes over time. These are broadly referred to as ARCH (autoregressive conditional heteroskedas - ticity) …

Как с нами связаться:

Украина:
г.Александрия
тел./факс +38 05235  77193 Бухгалтерия

+38 050 457 13 30 — Рашид - продажи новинок
e-mail: msd@msd.com.ua
Схема проезда к производственному офису:
Схема проезда к МСД

Партнеры МСД

Контакты для заказов оборудования:

Внимание! На этом сайте большинство материалов - техническая литература в помощь предпринимателю. Так же большинство производственного оборудования сегодня не актуально. Уточнить можно по почте: Эл. почта: msd@msd.com.ua

+38 050 512 1194 Александр
- телефон для консультаций и заказов спец.оборудования, дробилок, уловителей, дражираторов, гереторных насосов и инженерных решений.