There are five basic cases to learn:
1. If our model is a simple regression model, Yi = b1 + b2 Xi + ei, then the slope of this function with respect to Xi is given simply by b2. This slope is the same at all values of Xi where we might want to compute a slope. Straight lines have constant slope.
2. If our model is a multiple regression model, Yi = b1 + b2 Xi + b3Zi + ei, then its slope with respect to Xi is still constant and equal to b2. Its slope with respect to Zi is constant and equal to b3. Taking the derivative of a sum of terms yields the sum of the derivatives of each term. Since Xi appears only in the second term in the sum, and nowhere else, only the derivative of this second term with respect to Xi is relevant to the derivative of the whole expression with respect to Xi.
3. If we have elected to use a quadratic model to capture curvature in the relationship between E[Yi] and Xi, then our regression model (if X is the only explanatory variable) will be Yi = b1 + b2 Xi + b3 Xi2+ ei. In general, the derivative of x2 with respect to x is 2x. Thus, the derivative of this function for Yi with respect to Xi will be b2 + 2(b3)Xi. Again, we take the derivative term-by-term. The derivative of b2Xi is just b2 (the coefficient on Xi). The derivative of b3 Xi2 is b3 times the derivative of Xi2 with respect to Xi, which is just 2Xi, so the complete derivative of the third term in the sum above is just 2(b3)Xi.
Note that this derivative (slope) is not constant everywhere over the surface of the function. It changes according to the value of Xi at which it is being assessed.
- In particular, if b3 is a positive number, the slope of the function in the Xi direction gets larger as Xi gets larger. This could mean, as you move from left to right along the X-axis, that the slope starts out negative and then becomes positive after a certain point. This would make the function a parabolic curve opening at the top (i.e opening "upwards").
- If b3 is a negative number, the slope of the function in the Xi direction gets smaller as Xi gets larger. This could mean, as you move from left to right along the X-axis, that the slope starts out positive and then becomes negative after a certain point. This would make the function a parabolic curve opening at the bottom (i.e. opening "downwards").
In either of these cases, it is often useful to solve for the level of Xi at which the slope changes sign. In the first case, it would give us the location along the X-axis of the smallest fitted value of Y. In the second case, it would give us the location along the X-axis of the largest fitted value of Y. We find the crucial value of X by setting the formula for the derivative equal to zero and solving for the value of X which makes this equality true:
Note that if the coefficients b2 (on
Xi in the regression equation) and b3 (on
Xi2
in the regression equation) are of opposite signs, this crucial value of
Xi* will be a positive value. If both coefficients
have negative signs, or both have positive signs, then Xi*
will be a negative number. Sometimes when we fit a quadratic form, the
only relevant part of the parabolic curve that is implied is one of the
"shoulders" of the curve.
NOTE: We have developed a very helpful Java Applet, called the 2D Function Studio to help visualize quadratic functions and their derivatives, for different values of the intercept, slope and quadratic term coefficients. This Applet forms the basis of a lab session currently under development.
4. If we use interaction terms, our model might be of the form
In this case, we usually need to consider both the slope of the function (surface) in the X-direction and the slope of the function in the Z-direction. If it were not for the interaction term (the b4 XiZi term), this would be an ordinary linear-in-variables model with constant derivatives (slopes) b2 and b3, as before. The presence of the interaction term means that the slopes in each direction are NOT constant, but depend on the level of the OTHER explanatory variable in the model.
For example, the slope of this function with respect to Xi is b2 + b4Zi. Depending on the sign of the estimated coefficient b4, the slope of the function in the X-direction will get either larger or smaller as Zi differs.
The slope of this function with respect to Zi is b3 + b4Xi. Again, depending upon the sign of the estimated coefficient b4 (on the interaction term), the slope of this function in the Z-direction will get either larger or smaller as Xi differs.
Intuitively, the use of an interaction term change
our regression model from a flat, planar surface, to a "twisted" surface,
with the degree of "twist" depending on the size of b4.
5. When the relationships between variables are curves, but the slopes of these curves do not change sign, it is sometimes appropriate to consider models that involve logarithms of the variables. Fully logarithmic models (with all variables logged) are convenient for economists because they exhibit constant elasticities of Y with respect to (each) X. Logarithmic models can be of the following basic forms:
The geometric shapes of these relationships can be inferred by making use of the fact that the derivative of log(x) is (1/x) times the derivative of x.
Thus, for the first case above (the LOG-LIN model), the slope of the function in the X-direction can be determined as follows:
Thus, the slope in the X-direction depends on the current fitted value of Y at that point on the regression line. The sign of b2 will determine whether the slope increases or decreases as Y gets larger.
For the second case above (the LIN-LOG model), the slope of the function in the X-direction can be determined as follows:
Thus, the slope in the X-direction depends on the current value of X at that point on the regression line. The sign of b2 will determine whether the slope increases or decreases as X gets larger.
For the third case above (the LOG-LOG model), the slope of the function in the X-direction can be determined as follows:
Thus, the slope in the X-direction depends on the current values of both Y and X at that point on the regression line. The sign of b2 will determine what happens to this slope as Y and X change with movement along the regression line. Note that b2 in this case is conveniently equal to the elasticity of Y with respect to X: the percent change in Y for a percent change in X.