set trace off capture log close log using gcpaper05-model3-fig11, replace text // program: gcpaper05-model3-fig11.do // task: model 3: data for 3d figure 11 for full model // project: Group comparisons in logit and probit // using predicted probabilities // author: jsl \ 2009-05-26 // #0 // program setup version 10 clear all set linesize 80 matrix drop _all set scheme s2manual local pgm "gcpaper05" local dte "2009-05-26" // #1 // load the tenure data use gc_tenure01, clear datasignature confirm keep if allisonsmr // use allison sample // #2 // Model 3 using GC // #2a - gcsetup & gcmodel gcsetup year yearsq select articles prestige, details grpvar(male) /// gr0var(f0) gr0label(women) gr1var(m1) gr1label(men) gcmodel year yearsq select articles prestige, label(M3_full) details // #2b - estimate model using global rhsinteract from -gcmodel- logit tenure $rhsinteract, nocon nolog // #3 // create csv files to plotting in matlab local tag "`pgm'" // prefix used for csv files local mdl "M3i" local x1var "prestige" local x1st = 1 local x1en = 5 local x1gap = .1 local x2var "articles" local x2st = 0 local x2en = 50 local x2gap = 1 * get predictions local colnm "" forvalues x1 = `x1st'(`x1gap')`x1en' { local x1x = string(`x1'*100,"%4.0f") // since can't name variables with decimals * generate predictons gcprgen `x2var', from(`x2st') to(`x2en') gap(`x2gap') /// gen(`mdl'`x1x') x(year=7 yearsq=47 `x1var'=`x1') local colnm "`colnm' x1_`x1x'" * grab results from matrix and accumulate matrix tmp = `mdl'`x1x'[1...,4] matrix `tag'_dc = (nullmat(`tag'_dc),tmp) matrix tmp = `mdl'`x1x'[1...,5] matrix `tag'_lb = (nullmat(`tag'_lb),tmp) matrix tmp = `mdl'`x1x'[1...,6] matrix `tag'_ub = (nullmat(`tag'_ub),tmp) matrix tmp = `mdl'`x1x'[1...,7] matrix `tag'_sig = (nullmat(`tag'_sig),tmp) } * vector of values for predictors forvalues x = `x1st'(`x1gap')`x1en' { matrix `tag'_`x1var' = (nullmat(`tag'_`x1var') \ `x') } forvalues x = `x2st'(`x2gap')`x2en' { matrix `tag'_`x2var' = (nullmat(`tag'_`x2var') \ `x') } * drop variables and generate csv files drop _all foreach v in x1var x2var { local nm "``v''" svmat `tag'_`nm', name(`tag'_`nm') outfile `tag'_`nm'* using `tag'_`nm'.csv, comma wide replace drop `tag'_`nm'* } foreach m in dc lb ub sig { matrix colnames `tag'_`m' = `colnm' svmat `tag'_`m', name(`tag'_`m') outfile `tag'_`m'* using `tag'_`m'.csv, comma wide replace drop `tag'_`m'* } dir *.csv log close exit