# Marginal Effects and Average Marginal Effects

The marginal effect of a change in xij on Pi is

dF-

= Ф(в 1 + в2Хі2 + взХіз)ві (16.2)

where ф() is the standard normal probability density. That means that the marginal effect depends on all of the parameters of the model as well as the values of the variables themselves. In the travel example, suppose we want to estimate the marginal effect of increasing public transportation time. Given that travel via public transport currently takes 20 (dtime=2) minutes longer than auto, the marginal effect would be

dP-

„ , – = ф(ві + @2dtime-) = ф(—0.0644 + 0.3000 x 2)(0.3000) = 0.1037 (16.3)

d dtimei

This computation is easily done in a script:

1 open "@gretldirdatapoetransport. gdt"

2 probit auto const dtime

3 scalar i_20 = $coeff(const)+$coeff(dtime)*2

4 scalar d_20 = dnorm(i_20)*$coeff(dtime)

5 printf "nThe value of the index for dtime=20 is %8.4fn

6 The probability of choosing auto is %8.4f n", i_20, d_20 which produces

The value of the index for dtime=20 is 0.5355 The probability of choosing auto is 0.1037

Rather than evaluate marginal effects at specific points in the data, some authors report average marginal effects. The average marginal effect of a change in xij on Pi is

__ і N л л

AMEj = N ^2 Ф(ві + @2Xi2 + /T3Xis)/3j (16.4)

N i=1

With these, you compute the marginal effect at each point in your dataset and average them.

There is one other way that people use to estimate marginal effects, and that is to evaluate the marginal effect at the means of the data. That would be

MEj = фф і + /З2Х2 + фзХз)ф (16.5)

These are computed and reported by gretl and labeled ‘slope’ in the output. The biggest disadvantage of using these is that the average values of the variables may not be representative of anyone in your sample. This is especially true if one or more of the variables is an indicator. For this reason, I generally favor the use of the AME, unless there are specific cases that I want to consider. You can actually get a pretty good idea of what the (average) marginal effects will be by looking at the estimated slopes from a linear probability model.

Below is a simple script to compute the average marginal effects (AME) for the travel example. The model has only one regressor and a constant. We will compute the AME for an increase in travel time.

1 series me = dnorm($coeff(const)+$coeff(dtime)*dtime)*$coeff(dtime)

2 scalar amf = mean(me)

3 summary me –simple

The first line computes a new variable, me, that holds the marginal effect for each individual. The mean function, which takes the average of a series) finds the average marginal effect. The simple summary statistis also reveal the AME and give us an idea of how variable it is (minimum, maximum, and standard deviation). The result is:

Summary statistics, using the observations 1-21 for the variable ‘me’ (21 valid observations)

Mean 0.048407

Minimum 0.0024738

Maximum 0.11526

Standard deviation 0.036457

The average marginal effect in the sample is 0.0484. The smallest is 0.0024738 and the largest

0.11526. That is a fairly large range, actually.

To facilitate the computation of AME, I have written a function that will compute them for an arbitrary probit model. The function is called ame and it needs two pieces of information to compute the marginal effects. First, it needs the parameters from estimation of probit. Then, it needs the list of explanatory variables that are in the model. The function will print the average marginal effects and output a N x K matrix that contains each of the marginal effects for every observation and variable. This matrix is handy to have for further computations.

1 function matrix ame(matrix *param, list x)

2 matrix p = lincomb(x, param)

3 matrix me_matrix = dnorm(p)*param’

4 matrix amfx = meanc(me_matrix)

5 printf "nThe average marginal effects are %8.4f n", amfx

6 return me_matrix

7 end function

The function is quite simple, but uses what is referred to as a pointer. The *param is the pointer. This is technically not necessary, but saves some computer overhead. It also requires special handling when the function is called. More on that detail in a moment.

The second line uses the lincomb function, which takes a linear combination of its arguments. The first argument should be a list that contains the desired series, the second argument is a vector of coefficients to use with the series. The result can be a series, or in this case, a matrix. So for instance, suppose X is T x K and contains variables and в is K x 1 parameters. The linear combination Хв is T x 1. Line 3 computes the matrix that contains all of the marginal effects. The meanc function in line 4 computes the column means of the matrix (AME), which gets printed in line 5. The entire matrix of marginal effects is returned when the function is called.

Once the function is loaded (highlight it and run it) it is ready to be used. Create the variable list, estimate the probit model, and save the coefficients using matrix coef = $coeff. Given the variable list and the parameter estimates, you can call the function as in line 4 of the script below.

1 list x = const dtime

2 probit auto x

4 ame(&coef, x)

Since I used a pointer to identify the parameter vector in the function (matrix *param), you have to use the ampersand (&) in front of the parameter matrix being passed to the function, i. e., ame(&coef, x). Thus, pointers require a pair of markers, * and &, when used. The * tells gretl to use the memory address of what follows rather than make a copy of the object to pass through the function. The & tells gretl to go get that object from the memory address when called. Basically, the use of pointers means that copies of objects do not have to be made, and it also means that whatever is getting passed around in this fashion can be modified in the process. That may not sound like a great idea, but it can make your programs more modular. See section 10.4 of the Gretl Users Guide for more details.

The use of ame(&coef, x) in line 4 will print the AME to the screen. If you want to save the matrix output from the function, use matrix me_probit = ame(&coef, x) and the result will be saved to me_probit.

The result for the travel time example is:

The average marginal effects are -0.0104 0.0484

The average marginal effect of a 10 minute (dtime = 1) increase in travel time is 0.0484.

## Leave a reply