e stimation r esults with s tata g raphics lance erickson

54
ESTIMATION RESULTS WITH STATA GRAPHICS LANCE ERICKSON

Upload: lisa-garrett

Post on 17-Dec-2015

223 views

Category:

Documents


0 download

TRANSCRIPT

  • Slide 1
  • Slide 2
  • E STIMATION R ESULTS WITH S TATA G RAPHICS LANCE ERICKSON
  • Slide 3
  • OUTLINE Why we need graphics Why we need graphics Marginal effects Marginal effects Marginal effects at the means Marginal effects at the means Average marginal effects Average marginal effects Marginal effects at representative values Marginal effects at representative values Walking through an example Walking through an example Programming Programming Graph editor Graph editor
  • Slide 4
  • A SIMPLE CORRELATION Is parental control related to adolescent delinquency? Is parental control related to adolescent delinquency?. corr delinq parcon (obs=11) | delinq parcon -------------+------------------ delinq | 1.0000 parcon | 0.0000 1.0000
  • Slide 5
  • A SIMPLE REGRESSION Is parental control related to adolescent delinquency? Is parental control related to adolescent delinquency?. reg delinq parcon Source | SS df MS Number of obs = 11 -------------+------------------------------ F( 1, 9) = 0.00 Model | 1.4211e-14 1 1.4211e-14 Prob > F = 1.0000 Residual | 102.727273 9 11.4141414 R-squared = 0.0000 -------------+------------------------------ Adj R-squared = -0.1111 Total | 102.727273 10 10.2727273 Root MSE = 3.3785 ------------------------------------------------------------------------------ delinq | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- parcon | 1.76e-08.5598242 0.00 1.000 -1.26641 1.26641 _cons | 5.545454 2.208356 2.51 0.033.5498056 10.5411 ------------------------------------------------------------------------------
  • Slide 6
  • VISUALIZING THE DATA Is parental control related to adolescent delinquency? Is parental control related to adolescent delinquency?
  • Slide 7
  • REVISING THE MODEL Is parental control related to adolescent delinquency? Is parental control related to adolescent delinquency?. reg delinq c.parcon##c.parcon Source | SS df MS Number of obs = 11 -------------+------------------------------ F( 2, 8) = 930.87 Model | 102.287737 2 51.1438687 Prob > F = 0.0000 Residual |.439535405 8.054941926 R-squared = 0.9957 -------------+------------------------------ Adj R-squared = 0.9947 Total | 102.727273 10 10.2727273 Root MSE =.2344 ----------------------------------------------------------------------------------- delinq | Coef. Std. Err. t P>|t| [95% Conf. Interval] ------------------+---------------------------------------------------------------- parcon | -9.912351.2329897 -42.54 0.000 -10.44963 -9.375076 c.parcon#c.parcon | 1.41605.0328185 43.15 0.000 1.340371 1.49173 _cons | 18.20366.330967 55.00 0.000 17.44044 18.96687 -----------------------------------------------------------------------------------
  • Slide 8
  • OUTLINE Why we need graphics Why we need graphics Marginal effects Marginal effects Marginal effects at the means Marginal effects at the means Average marginal effects Average marginal effects Marginal effects at representative values Marginal effects at representative values Walking through an example Walking through an example Programming Programming Graph editor Graph editor
  • Slide 9
  • MARGINAL EFFECTS A [marginal effect], or partial effect, most often measures the effect on the conditional mean of y of a change in one of the regressors, say x k. In the linear regression model, the [marginal effect] equals the relevant slope coefficient, greatly simplifying analysis. For nonlinear models, this is no longer the case, leading to remarkably many different methods for calculating [marginal effects]. If x changes by one unit, how would y change?
  • Slide 10
  • MARGINAL EFFECTS AT THE MEAN Mean is the average characteristic in the data Mean is the average characteristic in the data Identify mean value and substitute into the regression equation Identify mean value and substitute into the regression equation
  • Slide 11
  • MARGINAL EFFECTS Average Say were interested in the AME for whites vs. blacks Say were interested in the AME for whites vs. blacks 1.Imagine the first case is white, regardless of the true race 2.Use other characteristics as measured 3.Estimate the individual prediction 4.Repeat 2 and 3 with the race as black 5.The difference in predictions is individual marginal effect 6.Repeat 1 through 5 for every case 7.Calculate mean for entire sample
  • Slide 12
  • MARGINAL EFFECTS at representative values Identify profiles for individuals that have some particular meaning Identify profiles for individuals that have some particular meaning
  • Slide 13
  • OUTLINE Why we need graphics Why we need graphics Marginal effects Marginal effects Marginal effects at the means Marginal effects at the means Average marginal effects Average marginal effects Marginal effects at representative values Marginal effects at representative values Walking through an example Walking through an example Programming Programming Graph Editor Graph Editor
  • Slide 14
  • Toxoplasmosis Gondii Parasite whose primary host is any member of the cat family Parasite whose primary host is any member of the cat family Transmitted by contact with feces Transmitted by contact with feces Lodges into neurons Lodges into neurons 30 percent of worlds human population carries the parasite 30 percent of worlds human population carries the parasite Not thought of as dangerous for healthy people Not thought of as dangerous for healthy people Maybe its not so benign
  • Slide 15
  • eststo m1: svy: regress sdl i.toxbin##c.pir female age higrade ib1.race Number of strata = 49 Number of obs = 4169 Number of PSUs = 98 Population size = 109225249 Design df = 49 F( 9, 41) = 157.93 Prob > F = 0.0000 R-squared = 0.2657 ------------------------------------------------------------------------------ | Linearized sdl | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- 1.toxbin |.9756481.3447252 2.83 0.007.282897 1.668399 pir | -.2212445.0501302 -4.41 0.000 -.321985 -.1205041 | toxbin#c.pir | 1 | -.2222757.0970269 -2.29 0.026 -.4172585 -.0272929 | female |.0780064.1505963 0.52 0.607 -.2246282.380641 age |.0936083.0070641 13.25 0.000.0794125.1078042 higrade | -.5190588.0388779 -13.35 0.000 -.597187 -.4409307 | race | Black | 1.741903.1750276 9.95 0.000 1.390172 2.093634 Hispanic | 2.414574.3088713 7.82 0.000 1.793874 3.035274 Other | 2.315488.5264093 4.40 0.000 1.257629 3.373347 | _cons | 7.715189.6056571 12.74 0.000 6.498076 8.932303 ------------------------------------------------------------------------------
  • Slide 16
  • estout m1, cells("b(star fmt(2)) ci") stats(N r2, fmt(0 2) label(N "R squared")) nolz /// collabels(b "95% CI") mlabels(none) /// prehead("Table 1.""Latent Toxoplasmosis and Symbol-Digit Learning Test:" /// "Poverty-to-income Ratio as Linear") /// drop(0b.toxbin 0b.toxbin#co.pir 1b.race) /// order(1.toxbin pir 1.toxbin#c.pir Controls female age higrade race) /// varlabels(1.toxbin "Toxoplasmosis (Toxo)" pir "Poverty-to-income ratio (PIR)" /// 1.toxbin#c.pir "Toxo X PIR" female " Female" age " Age" /// higrade " Highest grade achieved" race " Race" 2.race " Black" /// 3.race " Hispanic" 4.race " Other" _cons "Constant") /// refcat(2.race " White", label(---)) /// postfoot("Note:""* p |t| [95% Conf. Interval] --------">
  • ------------------------------------------------------------------------------ | Delta-method | Margin Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- _at#toxbin | 1 0 | 5.017781.1803758 27.82 0.000 4.655302 5.380259 1 1 | 5.993429.3785632 15.83 0.000 5.232678 6.75418 2 0 | 4.796536.144264 33.25 0.000 4.506627 5.086445 2 1 | 5.549909.2829059 19.62 0.000 4.981388 6.118429 3 0 | 4.575292.118806 38.51 0.000 4.336542 4.814041 3 1 | 5.106388.2005721 25.46 0.000 4.703324 5.509453 4 0 | 4.354047.1115513 39.03 0.000 4.129876 4.578218 4 1 | 4.662868.154565 30.17 0.000 4.352258 4.973478 5 0 | 4.132803.1256924 32.88 0.000 3.880214 4.385391 5 1 | 4.219348.1761228 23.96 0.000 3.865416 4.57328 6 0 | 3.911558.1554978 25.16 0.000 3.599073 4.224043 6 1 | 3.775828.2482254 15.21 0.000 3.277 4.274655 7 0 | 3.690313.1938727 19.03 0.000 3.300712 4.079915 7 1 | 3.332307.3401179 9.80 0.000 2.648815 4.0158 8 0 | 3.469069.2366849 14.66 0.000 2.993433 3.944705 8 1 | 2.888787.4395592 6.57 0.000 2.00546 3.772115 9 0 | 3.247824.2819202 11.52 0.000 2.681285 3.814364 9 1 | 2.445267.5424133 4.51 0.000 1.355247 3.535287 10 0 | 3.02658.3285792 9.21 0.000 2.366275 3.686884 10 1 | 2.001747.6470546 3.09 0.003.7014417 3.302052 11 0 | 2.805335.3761325 7.46 0.000 2.049469 3.561202 11 1 | 1.558227.7527383 2.07 0.044.0455422 3.070911 12 0 | 2.584091.4242795 6.09 0.000 1.731469 3.436712 12 1 | 1.114706.8590798 1.30 0.201 -.6116792 2.841092 ------------------------------------------------------------------------------. margins i.toxbin, at(pir=(0(1)12)) vsquish Expression : Linear prediction, predict() 1._at : pir = 0 2._at : pir = 1 3._at : pir = 2 4._at : pir = 3 5._at : pir = 4 6._at : pir = 5 7._at : pir = 6 8._at : pir = 7 9._at : pir = 8 10._at : pir = 9 11._at : pir = 10 12._at : pir = 11
  • Slide 20
  • . marginsplot
  • Slide 21
  • Toxoplasmosis Gondii At low poverty-to-income T. Gondii is related to reduced cognitive functioning At low poverty-to-income T. Gondii is related to reduced cognitive functioning At high PIR T. Gondii is related to increased cognitive functioning At high PIR T. Gondii is related to increased cognitive functioning
  • Slide 22
  • . lowess sdl pir, by(toxbin)
  • Slide 23
  • Table 2. Latent Toxoplasmosis and Symbol-Digit Learning Test: Poverty-to-income Ratio as Quadratic ----------------------------------------------------------- b 95% CI ----------------------------------------------------------- Toxoplasmosis (Toxo).93**.26,1.60 Poverty-to-income ratio (PIR) -.58*** -.90,-.26 PIR^2.04*.01,.08 Toxo X PIR -.22* -.40,-.03 Controls Female.06 -.24,.36 Age.09***.08,.11 Highest grade achieved -.51*** -.59,-.43 Race White --- Black 1.66*** 1.30,2.02 Hispanic 2.33*** 1.71,2.94 Other 2.29*** 1.22,3.36 Constant 8.12*** 6.80,9.44 ----------------------------------------------------------- N 4169 R squared.27 ----------------------------------------------------------- Note: * p