Logit Modeling in Stata: Lecture 13, Study notes of Quantitative Techniques

A stata lecture script for logit modeling, including generating a risk allocation index, recoding variables, and running logit models. It also demonstrates generating a conditional effects plot to illustrate variable effects.

Typology: Study notes

2011/2012

Uploaded on 12/22/2012

devkumar
devkumar 🇮🇳

4.5

(70)

153 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
*** Lecture 13: Logit Modeling
clear
set mem 60m
set matsize 400
use “… aaas_comb_article_3.dta"
* Here is the calculation of something we'll call the "risk allocation index"
generate c4_35_rec=(-1*c4_35_wr)+8
table c4_35_rec
generate riskindx=(c4_34_im + c4_35_rec + c4_36_ok + c4_37_ac)/4
summarize riskindx
* Here is the dose-response certainty variable (remaned):
gen DR_cert=c4_29_ce
gen GCC_cert=c4_32_ct
* let's also rename the ideology variable
gen ideology=c4_1_ide
* And the gender variable:
gen sex=c5_4_gen
* Now let's turn to the dependent variable. The radiation dose-response
* measures needs to be recoded to order the response more intuitively.
* The recode sets the quadratic to zero, then linear to 1 (all else=.).
generate DR_correct = c4_28_ra
recode DR_correct (2=0) (1=1) (3=.) (4=.)
* Check it!
tabulate DR_correct
* Now similarly recode the D-R function that is preferred for standard setting:
generate DR_standard = c4_30_pb
recode DR_standard (2=0) (1=1) (3=.) (4=.)
tabulate DR_standard if DR_correct==0
* Now we can run a simple logit model predicting the choice of quad or linear
* risk standards for those who believe the quad is the most probable dose
* response function:
logit DR_standard DR_cert ideology sex if DR_correct==0
* model fit statistics are generated using the "lstat" command:
docsity.com
pf2

Partial preview of the text

Download Logit Modeling in Stata: Lecture 13 and more Study notes Quantitative Techniques in PDF only on Docsity!

*** Lecture 13: Logit Modeling clear set mem 60m set matsize 400 use “… aaas_comb_article_3.dta"

  • Here is the calculation of something we'll call the "risk allocation index" generate c4_35_rec=(-1*c4_35_wr)+ table c4_35_rec generate riskindx=(c4_34_im + c4_35_rec + c4_36_ok + c4_37_ac)/ summarize riskindx
  • Here is the dose-response certainty variable (remaned): gen DR_cert=c4_29_ce gen GCC_cert=c4_32_ct
  • let's also rename the ideology variable gen ideology=c4_1_ide
  • And the gender variable: gen sex=c5_4_gen
  • Now let's turn to the dependent variable. The radiation dose-response
  • measures needs to be recoded to order the response more intuitively.
  • The recode sets the quadratic to zero, then linear to 1 (all else=.). generate DR_correct = c4_28_ra recode DR_correct (2=0) (1=1) (3=.) (4=.)
  • Check it! tabulate DR_correct
  • Now similarly recode the D-R function that is preferred for standard setting: generate DR_standard = c4_30_pb recode DR_standard (2=0) (1=1) (3=.) (4=.) tabulate DR_standard if DR_correct==
  • Now we can run a simple logit model predicting the choice of quad or linear
  • risk standards for those who believe the quad is the most probable dose
  • response function: logit DR_standard DR_cert ideology sex if DR_correct==
  • model fit statistics are generated using the "lstat" command:

docsity.com

lstat

  • Illustrating variable effects is best done by generating a "conditional effects plot".
  • For this illustration, we'll set all other independent variables at their mean, and estimate
  • the effect of certainty as it ranges from zero to ten.
  • first, calculate the mean values for ideology and sex (when DR_correct==0) sum ideology if DR_correct== sum sex if DR_correct==
  • these turn out to be 3.480769 for ideology and .8436658 for sex. Now plug these
  • values into a formula that generates the logit value across the range of DR_cert: generate L1= _b[_cons] + _b[ideology]3.480769 + _b[sex].8436658 + _b[DR_cert]*DR_cert
  • Next, take the "anti-logit" using the appropriate formula: generate Phat1=1/(1 + exp(-L1)) label variable Phat1 "Probability by Certainty, Other IV at Means" graph twoway mspline Phat1 DR_cert, bands(50)
  • What remains in this do-file will help you with the recodes and logits for the homework generate DR_standard2 = c4_30_pb recode DR_standard2 (2=0) (1=.) (3=1) (4=.) tabulate DR_standard
  • Now we can run a simple logit model predicting the shift from Quad to LD-HR: logit DR_standard2 DR_cert ideology riskindx sex if DR_correct==

docsity.com