Clarfy Outlne Installaton The Basc Idea of Smulaton (and why t makes sense for substante nterpretaton) Components of Clarfy estsmp setx smq A Real Le Example Logt odel Contnuous IVs Bnary IVs Concludng Ponts odels Supported How to Clarfy other odels Installaton Type: net from http://gkng.harard.edu/clarfy
Installaton Type: net nstall clarfy Installaton clarfy wll ether nstall or tell you t s already nstalled.
The Basc Idea of Smulaton So you estmate a model and you want to say somethng substante wth quanttes of nterest: Predcted or Expected Values of DV = Frst Dfferences = X X + σ µ X µ The problem s that our s are uncertan! The soluton s we know how uncertan. ( σ) The Basc Idea of Smulaton: Parameters In order to capture the uncertanty we draw smulated s from the multarate* normal dstrbuton. Standard Deaton = σ Then we use these smulated parameters to calculate many draws of the same quantty of nterest. 3
4 = γ ( ) = γ V L L L we smulate parameters wth draws from the multarate normal dstrbuton ( ) V N γ γ L. Choose a startng scenaro X c.. Draw one alue of and compute. 3. Smulate the outcome by takng a random draw from. 4. Repeat tmes to get the dstrbuton of. γ ( ) θ c X c g = c Y ( ) θ c f Y c ( ) ( ) θ θ X g f Y = ( ) ( ) L + + + = = 0 µ σ µ X X X g N Y The Basc Idea of Smulaton: Quanttes of Interest In practce Components of Clarfy estsmp estmates the model and smulates the parameters Ths command must precede your regresson command e.g.: estsmp logt y x x x3 x4 Ths wll sae smulated s to your dataset! setx sets the alues for the IVs (the Xs) Used after model estmaton to set alues of the Xs e.g.: setx x mean x p0 x3.4 x4[6] nocwdel functons = mean medan mn max p# math # macro arname[#] reset alues by re-ssung the command e.g.: setx x medan smq smulates the quanttes of nterest Automates the smulaton of quanttes of nterest for the X alues you just set. e.g.: smq pral() e.g.: smq fd(pral()) changex(x4 p5 p75) There are lots of optons: Explore on your own!
Onto the achnes. clear the current data. Increase memory Type: set mem 50m 3. Re-open the NES data set Type: use "I:\general\Spost&Clarfy\NES 99.dta " We ll do a Smple Logt Type: estsmp logt ote pd deology gulfwarworth educaton sms(500) genname(smb) Note that Clarfy has added 5 new arables to our data set. 5
. Summarze the new arables to see that they make sense.. Then set all Xs to ther means so we can start.. Type: sum smb-smb5. Type: setx mean Tables of Frst Dfferences Type: smq pral() Type: setx pd -3 Type: smq pral() Type: setx pd - Type: smq pral() Or Type: fd(pral()) changex(pd 3 )) 6
Probablty of Bush Vote as PID Vares Party ID -3 - - 0 3 P(Bush) 0.049 0.089 0.56 0.63 0.408 0.57 0.79 95% CI (.05.09) (.056.4) (..3) (.04.330) (.33.487) (.475.669) (.63.88) And snce we know P(Bush) s.73(..339) when eery arable s held at ts mean we can calculate percentage changes ourseles to ncrease substante nterpretablty. But a pcture s worth a thousand words so t would be nce to use Clarfy to generate pctures lke ths: From Kng et al. AJPS 000 Adanced Graphng wth Clarfy 7
P(Bush) Vote 0..4.6 5 0 5 0 Educaton phwar/plowar phnowar/plonowar mdwar mdnowar erson 8.0 set more off # delmt; gen plowar=.; gen phwar=.; gen eduaxs = _n + 5 n /; setx gulfwarworth deology mean pd mean; local = 6; whle `' <= 7 {; setx educaton `'; smq pral() genpr(p); _pctle p p(.597.5); replace plowar = r(r) feduaxs==`'; replace phwar = r(r) feduaxs==`'; drop p; local = `'+; }; gen plonowar=.; gen phnowar=.; setx gulfwarworth 0 deology mean pd mean; local = 6; whle `' <= 7 {; setx educaton `'; smq pral() genpr(p); _pctle p p(.597.5); replace plonowar = r(r) feduaxs==`'; replace phnowar = r(r) feduaxs==`'; drop p; local = `'+; }; gen eduaxs = eduaxs -.; sort eduaxs; gen mdwar = (plowar+phwar)/; gen mdnowar = (plonowar+phnowar)/; graph twoway rspke phwar plowar eduaxs lne mdwar eduaxs rspke phnowar plonowar eduaxs lne mdnowar eduaxs yttle(p(bush) Vote) xttle(educaton); 8
Concluson odels Currently Supported by Clarfy regress logt probt ologt oprobt mlogt posson nbreg sureg webull But you really don t need Clarfy to do ths so you can smulate quanttes of nterest for any model! Easy to smulate parameters because Stata saes them after estmaton! Program the correct lnk functon yourself! 9