--------------------------------------- Background: In probit or logistic regressions, one can not base statistical inferences based on simply looking at the co-efficient and statistical significance of the interaction terms (Ai et al., 23). A basic introduction on what is meant by interaction effect is explained in http://glimo.vub.ac.be/downloads/interaction.htm (What is interaction effect?) and in Interaction effects between continuous variables, published in http://www.nd.edu/~rwilliam/stats2/l55.pdf, and some detailed introduction on interaction is provided in A Primer on Interaction Effects in Multiple Linear Regression (http://www.unc.edu/~preacher/interact/interactions.htm); interaction effects in CART type model is given in, Correlation and Interaction Effects with Random Forests (http://www.goldenhelix.com/correlation_interaction.html). For interaction effect in factorial models, see http://www.amazon.com/gp/product/769225/2-8548866- 23335?v=glance&n=28355 or Box and Hunter, Design of Experiments. A nice introduction by Norton and Ai (see references) who did pioneering work on computational aspects of interaction effects for non-linear models is http://www.academyhealth.org/24/ppt/norton2.ppt. With interaction terms, one has to be very careful when interpreting any of the terms involved in the interaction. This write-up examines the models with interactions and applies Dr. Norton s method to arrive at the size, standard errors and significance of the interaction terms. However, Dr. Norton s program is not able to handle 94, observations; it took approximately hours to estimate 75, observations for a model with interaction (old_old, endo_vis, old_old*endo_vis) and continuous variable. Therefore, we looked for alternatives using nlcom. This write-up examines comparisons of interest in the presence of interaction terms, using STATA 8.2. Some tutorials: The paper is organized as follows: a. Difference between probability and odds b. logistic command in STATA gives odds ratios c. logit command in STATA gives estimates d. difficulties interpreting main effects when the model has interaction terms e. use of STATA command to get the odds of the combinations of old_old and endocrinologist visits ([,], [,], [,], [,]) f. use of these cells to get the odds ratio given in the output and not given in the output g. use of lincom in STATA to estimate specific cell h. use of probabilities to do comparisons i. use of nlcom to estimate risk difference j. probit regression k. Interpretation of probit co-efficients l. Converting probit co-efficients to change in probabilities for easy interpretation Copyrights 26 CRMportals Inc.,
--------------------------------------- i. continuous independent variable (use of function normd) and for dummy independent variable (use of function norm) ii. calculate marginal effects hand calculation iii. calculate marginal effects use of dprobit iv. calculate marginal effects use of mfx command v. calculate marginal effects use of nlcom m. Probit regression with interaction effects (for, observations) i. Calculate interaction effect using nlcom ii. Using Dr.Norton s ineff program n. Logistic regression i. calculate marginal effects hand calculation ii. calcualte marginal effects use of mfx command iii. calculate effect using nlcom iv. calculate interaction effect using nlcom using Dr. Norton s method Odds versus probability: Odds: The ratio of the probability of a patient catching flu to the probability not catching the flu. For example, if the odds of having allergy this season are 2: (read "twenty to one"). The sizes of the numbers on either side of the colon represent the relative chances of not catching flu (on the left) and catching flu (on the right). In other words, what you are told is that the chance of not catching flu is 2 times as great as the chance of having allergy. Note that odds of : are not the same as a probability of /. If an event has a probability of /, then the probability of the event not happening is 9/. So the chance of the event not happening is nine times as great as the chance of the event happening; the odds are 9:. Probability: Probability is the expected number of flu patients divided by the total number of patients. Relationship: Odds = probability divided by ( probability). = Pr obabilty probability Example: If an event has a probability of /, then the probability of the event not happening is 9/. So the chance of the event not happening is nine times as great as the chance of the event happening; the odds are 9:. odds Probability = odds divided by ( + odds) = + odds Copyrights 26 CRMportals Inc., 2
--------------------------------------- Example: If the odds are : then the probability = / In this case we assume that there are likely outcomes and events not happening is and event happening is. So the probability of the even happening = /. Simple Model: ^ p logit( p) = β + β old _ old or ln = β + β old _ old ^ p. logistic ac_test old_old Logistic regression Number of obs = 94772 LR chi2() = 7. Prob > chi2 =. Log likelihood = -7729.9 Pseudo R2 =. ac_test Odds Ratio Std. Err. z P> z [95% Conf. Interval] old_old.9585854.97972-4.4..9395742.977983 Std. Err for odds ratios is not meaningful.. logit Logit estimates Number of obs = 94772 LR chi2() = 7. Prob > chi2 =. Log likelihood = -7729.9 Pseudo R2 =. ac_test Coef. Std. Err. z P> z [95% Conf. Interval] old_old -.422966.225-4.4. -.623285 -.222648 _cons.8989483.63666 4.2..88647.94266 When old_old =, the risk of Ac test is ^ ) logit ( p = β + β When old_old = the risk of Ac test is ^ logit ( p ) = β Take the difference: logit ( ^ p Odds ratio: ^ ) logit( p ) = ([ β + β ] β ) = β Copyrights 26 CRMportals Inc., 3
--------------------------------------- ^ ^ /( ) ln p p ^ ^ p/( p ) = ln( OR) = β Model with interaction Let us fit the following model with interaction: logit( p) = β + β old _ old + β 2 endo _ vis + β3 old _ old * endo _ vis ( Interaction) p ln β + βold _ old + β 2endo _ vis + β 3old _ old * endo _ vis p = Given below are the odds ratios produced by the logistic regression in STATA. Now we can see that one can not look at the interaction term alone and interpret the results. logistic ac_test old_old endo_vis oldxendo Logistic regression Number of obs = 94772 LR chi2(3) = 56.73 Prob > chi2 =. Log likelihood = -6985.8 Pseudo R2 =.64 ac_test Odds Ratio Std. Err. z P> z [95% Conf. Interval] old_old.96249.6487-3.58..944788.9822243 endo_vis.65284.28952 28.6..59553.795 oldxendo.67382.34229 2.22.27.7538.378 With interaction terms, one has to be very careful when interpreting any of the terms involved in the interaction. For example, in the above model endo_vis can not be interpreted as the overall comparison of endocrinologist visit to no endocrinologist visit, because this term is part of an interaction. It is the effect of endocrinologist visit when the other terms in the interaction term are at the reference values (ie. when old_old = ). Similarly, the old_old cannot be interpreted as the overall comparison of old_old to young-old. It is the effect of old-old when other terms in the interaction term is at the reference value (ie. endo_vis = ). To help in the interpretation of the odds ratios, let's obtain the odds of receiving an Ac-test for each of the 4 cells formed by this 2 x 2 design using the adjust command.. adjust, by (old_old endo_vis) exp Endocronologist Age >= 75 ----------+----------------- 2.25 3.7557 2.6264 3.876 Copyrights 26 CRMportals Inc., 4
--------------------------------------- ---------------------------- ) The odds ratio for old_old represents the odds ratio of old_old when there is no endocrinologist visit is =.96. (Note: The odds ratio for the old_old, when endocrinologist visit = can be read directly from the output which is.96 (.94,.98) because the interaction term and endocrinologist visit drop out). Interpretation: When there is no endocrinologist visit, the odds of a old_old having an Ac test is.96 times that of an young_old.. display 2.6264/2.25.962 2) the odds ratio endo_vis is the odds ratio formed by comparing an endocrinologist to no endocrinologist visit for young_old (because this is the reference group for old_old). (Note: The odds ratio for the endocrinologist, old_old = can be read directly from the output which is.65 (.6,.7) because the interaction term and endocrinologist visit drop out).. display 3.7557/2.25.6528 3) the odds ratio old_old seeing an endocrinologist compared to an young-old seeing an endocrinologist (not given in the logistic estimates). display 3.876/3.7557.2588 Using logit estimates to do comparisons: Logit estimates Number of obs = 94772 LR chi2(3) = 56.73 Prob > chi2 =. Log likelihood = -6985.8 Pseudo R2 =.64 ac_test Coef. Std. Err. z P> z [95% Conf. Interval] old_old -.39659.794-3.58. -.63662 -.79356 endo_vis.5553.7533 28.6..467888.53597 oldxendo.6529.294392 2.22.27.7593.22989 _cons.89787.6968 6.5..7973358.824626 a) risk of Ac test with old_old = given endocrinologist visit = logit ( p) = β + β + β 2 + β 3 Copyrights 26 CRMportals Inc., 5
--------------------------------------- (b) risk of Ac test with old_old = given endocrinologist visit = β,β logit ( p ) =β + β 2 The terms ( ) are gone because old_old = and the interaction term becomes zero. 3 Then take the differences: logit ( p) logit( po ) = [ β + β + β 2 + β3 ] [ β + β 2 ] logit ( p ) logit( p = β + β o ) If we represent logit as ln (p/-p) then p p ln ln = [ β + β + β 2 + β 3 ] [ β + β 2 ] = β + β 3 p p 3 These are the co-efficients for old_old and old_old*endo_vis exp( β + β 3 ) = odds ratio = exp (-.39659 +.6529) =.258876.. display exp(-.39659 +.6529).258876 Use of lincom: One can use STATA s commands to produce this: Variance is calculated by lincom using matrix algebra.. lincom old_old + oldxendo, or ( ) old_old + oldxendo = ac_test Odds Ratio Std. Err. z P> z [95% Conf. Interval] ().25888.27989.94.349.9724863.8222 We can use the following table of ln odds for the cross classification of old_old and endo_vis Endo_vis = Endo_vis = Old_old = β + β + β 2 + β 3 β + β Old_old = β + β 2 β For example, the odds of Ac test among old_old and with endo_vis = is: exp (β + β) Results Summary in terms of odds ratios: Copyrights 26 CRMportals Inc., 6
--------------------------------------- a) The association between HbAc test and old_old =.96 among those not seeing an endocrinologist b) The association between HbAc test and old_old =.258 among those seeing an endocrinologist Presenting estimates Predicted Probabilities As stated earlier, with interaction terms, co-efficients of variables that are involved in interactions do not have a straightforward interpretation. One way to interpret these models with interactions may be through predicted probabilities. If we write out the non-linear combinations of interest, STATA s nlcom will produce the point estimates and confidence intervals. Comparisons with Probabilities: Use the simple relationship between odds and risk. p odds If Odds = then p = p +odds Estimate change in probability of receiving Ac test for old_old when endocrinologist visit = : exp( β + β) + (exp( β + β)) exp (β + β ) = 2.626. display exp(.89787+(-.39659)) 2.626359 + (exp ((β + β ). display + (exp(.89787+(-.39659))) 3.626359 Numerator/Denominator: display 2.626359/3.626359.683885 In the same way estimate change in probability receiving Ac test for old_old when endocrinologist visit = : Exp (β + β + β 2 + β 3 ). display exp(.89787+( -.39659) +.5553 +.6529) 3.87557 + exp ((β + β + β 2 + β 3 ). display + (exp(.89787+( -.39659) +.5553 +.6529)) 4.87557 Numerator/Denominator: Copyrights 26 CRMportals Inc., 7
---------------------------------------. display 3.87557/4.87557.7927565 Using nlcom risk difference. logit ac_test old_old Iteration : log likelihood = -7738.45 Iteration : log likelihood = -7729.9 Iteration 2: log likelihood = -7729.9 Logit estimates Number of obs = 94772 LR chi2() = 7. Prob > chi2 =. Log likelihood = -7729.9 Pseudo R2 =. ac_test Coef. Std. Err. z P> z [95% Conf. Interval] old_old -.422966.225-4.4. -.623285 -.222648 _cons.8989483.63666 4.2..88647.94266 p p = + exp( β β ) + exp( β ). nlcom /(+exp(-_b[old_old] - _b[_cons])) - /(+exp(- _b[_cons] )) _nl_: /(+exp(-_b[old_old] - _b[_cons])) - /(+exp(- _b[_cons] )) ac_test Coef. Std. Err. z P> z [95% Conf. Interval] _nl_ -.87727.224-4.3. -.29356 -.4698 cs ac_test old_old Age >= 75 Exposed Unexposed Total -----------------+------------------------+---------- Cases 52487 85288 37775 Noncases 22285 3472 56997 -----------------+------------------------+---------- Total 74772 2 94772 Risk.7966.77333.773655 Point estimate [95% Conf. Interval] ------------------------+---------------------- Risk difference -.87727 -.29356 -.4698 Risk ratio.9876568.98844.993539 Prev. frac. ex..23432.6496.8559 Prev. frac. pop.47385 +----------------------------------------------- chi2() = 7.3 Pr>chi2 =. Copyrights 26 CRMportals Inc., 8
--------------------------------------- It is probably useful to tabulate results as follows and then calculate predicted probabilities rather than odds. Old_old Endo_vis Cardio_vis OldoldXendo OldoldXCardio Log-likelihood X 2 X X 3 X X X 4 X X X X 6 X X X X X PROBIT REGRESSION Probit Coefficients Continuous variable (dxg):. probit ac_test dxg Iteration : log likelihood = -7738.45 Iteration : log likelihood = -7737.67 Iteration 2: log likelihood = -7737.67 Probit estimates Number of obs = 94772 LR chi2() =.56 Prob > chi2 =.22 Log likelihood = -7737.67 Pseudo R2 =. ac_test Coef. Std. Err. z P> z [95% Conf. Interval] dxg -.7647.436 -.25.22 -.45353.59 _cons.5486867.38349 43.8..5476.556229 Interpretation: The co-efficient for dxg (-.7647) represents the effect of an infinitesimal change in x on the standardized probit index. If dxg is changed by an infinitesimal (or small) amount, the standardized probit index decreases, on average, by. of a standard deviation Marginal Effects: Prob(yi = ) Φ = = φ( x i ' β ) β k xk xk where φ( ) denotes the probability density function for the standard normal. The probability density function gives the height of the curve at the relevant index value x i ' β. What is the effect of a small change in dxg on the probability of Ac test? a) Get mean of dxg. sum dxg Variable Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- Copyrights 26 CRMportals Inc., 9
--------------------------------------- dxg 94772.6877 2.8394.68 25.829 b) Evaluate mean standardized probit index at this mean. display.5486867 + (-.7647)*.6877.545784 c) Find the height of the standardized normal curve at this point using the pdf table entries and use this to translate the probit coefficient into a probability effect. display normd(.545784)*-.7647 -.6662 So marginal effect of dxg = -.6 ~= -.; This implies that an infinitesimally small change in x decreases the probability of receiving hbac test by.% at the average. Check your hand calculation by dprobit (canned routine in STATA). dprobit ac_test dxg Iteration : log likelihood = -7738.45 Iteration : log likelihood = -7737.67 Iteration 2: log likelihood = -7737.67 Probit estimates Number of obs = 94772 LR chi2() =.56 Prob > chi2 =.22 Log likelihood = -7737.67 Pseudo R2 =. ac_test df/dx Std. Err. z P> z x-bar [ 95% C.I. ] ---------+-------------------------------------------------------------------- dxg -.666.4859 -.25.22.6877 -.559.346 ---------+-------------------------------------------------------------------- obs. P.773655 pred. P.773668 (at x-bar) z and P> z are the test of the underlying coefficient being use nlcom. probit ac_test dxg Iteration : log likelihood = -7738.45 Iteration : log likelihood = -7737.67 Iteration 2: log likelihood = -7737.67 Probit estimates Number of obs = 94772 LR chi2() =.56 Prob > chi2 =.22 Log likelihood = -7737.67 Pseudo R2 =. ac_test Coef. Std. Err. z P> z [95% Conf. Interval] dxg -.7647.436 -.25.22 -.45353.59 Copyrights 26 CRMportals Inc.,
--------------------------------------- _cons.5486867.38349 43.8..5476.556229. quietly sum dxg. local dxgmean = r(mean). local xb _b[dxg]*`dxgmean'+_b[_cons]. nlcom normd(`xb') * _b[dxg] _nl_: normd(_b[dxg]*.6877893987+_b[_cons]) * _b[dxg] ac_test Coef. Std. Err. z P> z [95% Conf. Interval] _nl_ -.666.4859 -.25.22 -.559.3458 Marginal effects dummy variable (old_old): For a dummy variable, it makes no sense to compute a derivative. If D i = then: Prob[y i = x i, D i = ] = Φ( x i ' β + δ) If D i = then: Prob[y i = x i, D i = ] = Φ( x i ' β ) The impact effect for gender is then given by the differences between the two CDF values: = Φ( x i ' β + δ) Φ( x i ' β ). probit ac_test old_old dxg Iteration : log likelihood = -7738.45 Iteration : log likelihood = -7729.4 Iteration 2: log likelihood = -7729.4 Probit estimates Number of obs = 94772 LR chi2(2) = 8.8 Prob > chi2 =. Log likelihood = -7729.4 Pseudo R2 =. ac_test Coef. Std. Err. z P> z [95% Conf. Interval] old_old -.2592.6722-4.7. -.37885 -.29939 dxg -.3964.468 -.99.324 -.4732.385 _cons.5577377.44369 25.7..54945.566434 Old-old Impact: What is the effect of old_old on the probability of Ac test? a) Get mean of dxg. sum dxg Variable Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- dxg 94772.6877 2.8394.68 25.829 b) Evaluate mean standardized probit index at this mean and at old_old =. display.5577377 + (-.3964 *.69) + (-.2592).5328658 Copyrights 26 CRMportals Inc.,
--------------------------------------- c) Evaluate mean standardized probit index at this mean and at old_old =. display.5577377 + (-.3964 *.69).55537778 d) Find difference between the two CDF values (Notice the use of norm rather than normd). display norm(.5328658) - norm(.55537778) -.863848 Being an old_old decreases the probability of testing (holing comorbidity at the sample mean level) by.86 percentage points. Check your hand calculation by using mfx compute command (canned routine in STATA). probit ac_test old_old dxg Iteration : log likelihood = -7738.45 Iteration : log likelihood = -7729.4 Iteration 2: log likelihood = -7729.4 Probit estimates Number of obs = 94772 LR chi2(2) = 8.8 Prob > chi2 =. Log likelihood = -7729.4 Pseudo R2 =. ac_test Coef. Std. Err. z P> z [95% Conf. Interval] old_old -.2592.6722-4.7. -.37885 -.29939 dxg -.3964.468 -.99.324 -.4732.385 _cons.5577377.44369 25.7..54945.566434. mfx compute Marginal effects after probit y = Pr(ac_test) (predict) =.773865 variable dy/dx Std. Err. z P> z [ 95% C.I. ] X ---------+-------------------------------------------------------------------- old_old* -.86385.23-4.6. -.28 -.4467.383895 dxg -.48.49 -.99.324 -.435.475.6877 (*) dy/dx is for discrete change of dummy variable from to Use nlcom. probit ac_test old_old dxg Iteration : log likelihood = -7738.45 Iteration : log likelihood = -7729.4 Iteration 2: log likelihood = -7729.4 Copyrights 26 CRMportals Inc., 2
--------------------------------------- Probit estimates Number of obs = 94772 LR chi2(2) = 8.8 Prob > chi2 =. Log likelihood = -7729.4 Pseudo R2 =. ac_test Coef. Std. Err. z P> z [95% Conf. Interval] old_old -.2592.6722-4.7. -.37885 -.29939 dxg -.3964.468 -.99.324 -.4732.385 _cons.5577377.44369 25.7..54945.566434. quietly sum dxg. local dxgmean = r(mean). local xb _b[dxg]*`dxgmean'+_b[old_old]* + _b[_cons]. local xb _b[dxg]*`dxgmean'+_b[old_old]* + _b[_cons]. nlcom norm(`xb') - norm(`xb') _nl_: norm(_b[dxg]*.6877893987+_b[old_old]* + _b[_cons]) - norm(_b[dxg]*.6877893987+_b[old_old]* + > _b[_cons]) ac_test Coef. Std. Err. z P> z [95% Conf. Interval] _nl_ -.86385.2282-4.6. -.2897 -.44672 PROBIT REGRESSION with Interaction Effects. probit ac_test old_old endo_vis oldxendo dxg Iteration : log likelihood = -646.3976 Iteration : log likelihood = -5996.9948 Iteration 2: log likelihood = -5996.896 Iteration 3: log likelihood = -5996.896 Probit estimates Number of obs = LR chi2(4) = 99. Prob > chi2 =. Log likelihood = -5996.896 Pseudo R2 =.82 ac_test Coef. Std. Err. z P> z [95% Conf. Interval] old_old.763.2983.57.566 -.43595.755722 endo_vis.358482.4453 8.5..2729.445766 oldxendo -.85596.75369 -.25.85 -.66284.296 dxg -.25473.6227 -.4.682 -.4752.96574 _cons.48266.2874 23...44563.5229668. mfx compute Marginal effects after probit y = Pr(ac_test) (predict) =.792 variable dy/dx Std. Err. z P> z [ 95% C.I. ] X ---------+-------------------------------------------------------------------- old_old*.58573.2.57.566 -.427.2584.386 Copyrights 26 CRMportals Inc., 3
--------------------------------------- endo_vis*.44986.287 8.9..89275.39722.888 oldxendo* -.6392.266 -.25.86 -.57473.44693.643 dxg -.8732.23 -.4.682 -.557.33.6728 (*) dy/dx is for discrete change of dummy variable from to Use the formula and get correct marginal effects Think of all the possible contrasts and evaluate the estimated equation for ) for Old_old = and endo_vis = (xb) 2) for old_old = and endo_vis = (xb2) 3) for old_old = and endo_vis = (xb3) 4) for old_old = and endo_vis = (xb4) 5) calculate mean of dxg 6) evaluate the following formula using nlcom 2 F( u) = Φ ( β o + β + β 2 + β 3 + β 4 * dxgmean ) Φ ( β o + β + β 4 * dxgmean ) x x2 Φ ( β o + β 2 + β 4 * dxgmean) + Φ ( β o + β 4 * dxgmean).quietly sum dxg. local dxgmean = r(mean). local xb /* > */ _b[old_old] /* > */ + _b[endo_vis] /* > */ + _b[oldxendo] /* > */ + _b[dxg]*`dxgmean' /* > */ + _b[_cons]. local xb2 /* > */ _b[old_old] /* > */ + _b[dxg]*`dxgmean' /* > */ + _b[_cons].. local xb3 /* > */ _b[endo_vis] /* > */ + _b[dxg]*`dxgmean' /* > */ + _b[_cons].. local xb4 /* > */ _b[dxg]*`dxgmean' /* > */ + _b[_cons]. nlcom norm(`xb') - norm(`xb2') - norm(`xb3') + norm(`xb4') _nl_: norm(_b[old_old] + _b[endo_vis] + _b[oldxendo] + _b[dxg]*.6728328588 > + _b[_cons]) - norm(_b[old_old] + _b[dxg]*.6728328588 + _b[_cons]) > norm(_b[endo_vis] + _b[dxg]*.6728328588 + _b[_cons]) + > norm(_b[dxg]*.6728328588 + _b[_cons]) Copyrights 26 CRMportals Inc., 4
--------------------------------------- ac_test Coef. Std. Err. z P> z [95% Conf. Interval] _nl_ -.6472.22576 -.29.77 -.4992.36956 Interpretation: The interaction effect is negative and insignificant. In our case, all the approaches to estimate marginal effect give similar results. Check with Dr. Nortons s inteff program. probit ac_test old_old endo_vis oldxendo dxg Iteration : log likelihood = -646.3976 Iteration : log likelihood = -5996.9948 Iteration 2: log likelihood = -5996.896 Iteration 3: log likelihood = -5996.896 Probit estimates Number of obs = LR chi2(4) = 99. Prob > chi2 =. Log likelihood = -5996.896 Pseudo R2 =.82 ac_test Coef. Std. Err. z P> z [95% Conf. Interval] old_old.763.2983.57.566 -.43595.755722 endo_vis.358482.4453 8.5..2729.445766 oldxendo -.85596.75369 -.25.85 -.66284.296 dxg -.25473.6227 -.4.682 -.4752.96574 _cons.48266.2874 23...44563.5229668. inteff ac_test old_old endo_vis oldxendo dxg, Probit with two dummy variables interacted Variable Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- _probit_ie -.6472.76 -.66553 -.64586 _probit_se.22575.98.22888.23249 _probit_z -.29294.398 -.292395 -.2877969 LOGISTIC REGRESSION MARGINAL EFFECTS prob(y i = ) = ' exp( xiβ) ' + exp( xiβ) and prob(y i = ) = ' + exp( xiβ) Continuous variable: Copyrights 26 CRMportals Inc., 5
--------------------------------------- The effect of a small change in the independent variable on the log odds ratio of the event occurring. Prob(yi = ) xk = F xk = ' exp( xiβ) ' + exp( xiβ) ' exp( xiβ) * * β ' k + exp( xiβ) The marginal effect is then simply the gradient of the logistic CDF at this mean value. It can also be represented by Prob(yi = ) = P i ( P) i β k = xk + exp ( x β) ' i * + exp( x β) ' i * β k. logit ac_test dxg Iteration : log likelihood = -7738.45 Iteration : log likelihood = -7737.66 Iteration 2: log likelihood = -7737.66 Logit estimates Number of obs = 94772 LR chi2() =.57 Prob > chi2 =.2 Log likelihood = -7737.66 Pseudo R2 =. ac_test Coef. Std. Err. z P> z [95% Conf. Interval] dxg -.29539.2354 -.25.2 -.75676.6599 _cons.887666.63787 39.5..87545.987. mfx compute Marginal effects after logit y = Pr(ac_test) (predict) =.773679 variable dy/dx Std. Err. z P> z [ 95% C.I. ] X ---------+-------------------------------------------------------------------- dxg -.64.49 -.25.2 -.566.344.6877 Hand Calculation: a) Get mean of dxg. sum dxg Variable Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- dxg 94772.6877 2.8394.68 25.829 b) Evaluate logistic CDF at this mean and take exponent of the negative of this. display exp(-((-.29539 *.6877) +.887666)) Copyrights 26 CRMportals Inc., 6
---------------------------------------.4369294 c) Evaluate logistic CDF at this mean and take exponent. display exp((-.29539 *.6877) +.887666) 2.47258 d) Multiply : /(+436) * /+2.472) and the co-efficient of the dxg variable With nlcom:. display (/(+.4369294)) * (/(+2.47258)) * -.29539 -.645. quietly sum dxg. local dxgmean = r(mean). local xb _b[dxg]*`dxgmean'+_b[_cons]. nlcom (/(+exp(-(`xb')))) * (/(+exp(`xb'))) * _b[dxg] _nl_: (/(+exp(-(_b[dxg]*.6877893987+_b[_cons])))) * (/(+exp(_b[dxg]*.6877 > 893987+_b[_cons]))) * _b[dxg] ac_test Coef. Std. Err. z P> z [95% Conf. Interval] _nl_ -.64.4873 -.25.2 -.5665.3436 Dummy variable old_old. logit ac_test dxg old_old Iteration : log likelihood = -7738.45 Iteration : log likelihood = -7729.4 Iteration 2: log likelihood = -7729.4 Logit estimates Number of obs = 94772 LR chi2(2) = 8. Prob > chi2 =. Log likelihood = -7729.4 Pseudo R2 =. ac_test Coef. Std. Err. z P> z [95% Conf. Interval] dxg -.2358.236 -..39 -.69772.22737 old_old -.46555.248-4.7. -.6727 -.25839 _cons.926764.73869 22.2..888983.97545. mfx compute Marginal effects after logit y = Pr(ac_test) (predict) =.773847 Copyrights 26 CRMportals Inc., 7
--------------------------------------- variable dy/dx Std. Err. z P> z [ 95% C.I. ] X ---------+-------------------------------------------------------------------- dxg -.4868.49 -..39 -.444.47.6877 old_old* -.86395.23-4.6. -.28 -.4469.383895 (*) dy/dx is for discrete change of dummy variable from to Hand Calculation: a) Get mean of dxg. sum dxg Variable Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- dxg 94772.6877 2.8394.68 25.829 b) Evaluate function when old_old = P( Y = old _ old, dxg =.6877) = + exp ( β + β (.68) +.display exp(-(.926764 + (-.2358*.6877) + (-.46555))).42445. display /(+.42445).72443 c) Evaluate function when old_old = P( Y = old _ old, dxg =.6877) = + exp ( β +. display exp(-(.926764 + (-.2358*.6877))).47956. display /(+.47956).768377 d) The difference between the two values is the difference in the probability of receiving hbac test because of age. With nlcom:. display.72443-.768377 -.863946 β 2 β (.68) ) ()). quietly sum dxg. local dxgmean = r(mean). local xb _b[_cons]+(_b[dxg]*`dxgmean'). local xb _b[_cons]+(_b[dxg]*`dxgmean')+_b[old_old]. nlcom /(+exp(-(`xb'))) - /(+exp(-(`xb'))) _nl_: /(+exp(-(_b[_cons]+(_b[dxg]*.6877893987)+_b[old_old]))) - /(+exp(-(_b[_ > cons]+(_b[dxg]*.6877893987)))) Copyrights 26 CRMportals Inc., 8
--------------------------------------- ac_test Coef. Std. Err. z P> z [95% Conf. Interval] _nl_ -.86395.228-4.6. -.284 -.44685 LOGISTIC REGRESSION with Interaction Effects Use the formula and get correct marginal effects 2 F( u) = x x2 + exp ( β o + β + β 2 + β 3 + β 4 * dxgmean) + exp ( β o + β + β 4 * dxgmean ) + exp ( β o + β 4 * dxgmean) + exp ( β o + β 2 + β 4 * dxgmean ) Think of all the possible contrasts and evaluate the estimated equation for ) for Old_old = and endo_vis = (xb) 2) for old_old = and endo_vis = (xb2) 3) for old_old = and endo_vis = (xb3) 4) for old_old = and endo_vis = (xb4) 5) calculate mean of dxg 6) evaluate the following formula using nlcom. logit ac_test old_old endo_vis oldxendo dxg Iteration : log likelihood = -646.3976 Iteration : log likelihood = -5997.3365 Iteration 2: log likelihood = -5996.8874 Iteration 3: log likelihood = -5996.8873 Logit estimates Number of obs = LR chi2(4) = 99.2 Prob > chi2 =. Log likelihood = -5996.8873 Pseudo R2 =.82 ac_test Coef. Std. Err. z P> z [95% Conf. Interval] old_old.28896.495.57.566 -.68429.24522 endo_vis.66646.77566 7.87..455677.7576742 oldxendo -.3983.3546 -.24.83 -.286775.2249385 dxg -.4348.454 -.42.676 -.24769.6658 _cons.7776468.344863 22.55..7549.8452387. mfx compute Marginal effects after logit + Copyrights 26 CRMportals Inc., 9
--------------------------------------- y = Pr(ac_test) (predict) =.7964843 variable dy/dx Std. Err. z P> z [ 95% C.I. ] X ---------+-------------------------------------------------------------------- old_old*.582.9.57.565 -.3978.25578.386 endo_vis*.44238.28 8.93..8939.39538.888 oldxendo* -.6464.272 -.24.84 -.5976.4693.643 dxg -.8959.25 -.42.676 -.52.33.6728 (*) dy/dx is for discrete change of dummy variable from to. *------------------------------------. * nlcom to get differences in p. * Old-old. *------------------------------------. quietly sum dxg. local dxgmean = r(mean). local xb /* > */ _b[old_old] /* > */ + _b[endo_vis] /* > */ + _b[oldxendo] /* > */ + _b[dxg]*`dxgmean' /* > */ + _b[_cons].. local xb2 /* > */ _b[old_old] /* > */ + _b[dxg]*`dxgmean' /* > */ + _b[_cons].. local xb3 /* > */ _b[endo_vis] /* > */ + _b[dxg]*`dxgmean' /* > */ + _b[_cons].. local xb4 /* > */ _b[dxg]*`dxgmean' /* > */ + _b[_cons].. nlcom /(+(exp(-(`xb')))) - /(+(exp(-(`xb2')))) - /(+(exp(-(`xb3')))) + /(+(exp(-( > `xb4')))) _nl_: /(+(exp(-(_b[old_old] + _b[endo_vis] + _b[oldxendo] + _b[dxg]*.672832858 > 8 + _b[_cons])))) - /(+(exp(-(_b[old_old] + _b[dxg]*.6728328588 + _b[_cons])))) - /( > +(exp(-(_b[endo_vis] + _b[dxg]*.6728328588 + _b[_cons])))) + /(+(exp(- (_b[dxg]*.672 > 8328588 + _b[_cons])))) ac_test Coef. Std. Err. z P> z [95% Conf. Interval] _nl_ -.6547.2256 -.29.769 -.499296.3692 Copyrights 26 CRMportals Inc., 2
--------------------------------------- REFERENCES: Ai C, Norton EC: Interaction Term in Logit and Probit Models. Economic Letters 8:23-29. Norton EC, Ai. C: Computing interaction effects and standard errors in logit and probit models The Stata Journal, 24, 4(2):3-6 Copyrights 26 CRMportals Inc., 2