Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Part 1/2 of the Stata code for replicating Bollen & Paxton's (2000) "Subjective measures of liberal democracy" (Comparative Political Studies, 33(58), pp. 58-86).
* Replication of Bollen & Paxton's (2000) "Subjective measures of liberal democracy"
* Comparative Political Studies, 33(58), pp. 58-86
log using mylog-part1.log, replace
set more off
use "/Users/thiagomarzagao/Desktop/SCpaper/data-bollenpaxton.dta"
* part 1: 1979-1981, 1983-1987
local years "79"
foreach x of local years {
confa (pollib`x': party`x' broad`x' print`x' civlib`x') (demrul`x': leg`x' polrt`x' compet`x' effec`x'), vce(sbentler) from(smart) usenames difficult
matrix b_t = e(b)
estat fit
matrix y19`x't = (((e(lr_indep) - e(chi2)) / (e(lr_indep) - e(df_m))) , e(Tsc) , e(p_Tsc) , e(Tadj) , e(p_Tadj) , e(T2) , e(p_T2) , e(lr_indep) , e(ll) , e(df_m) , r(AIC) , r(BIC) , r(CFI) , r(TLI) , r(RMSR) , 1-r(RMSEA) , 1-r(RMSEA05) , 1-r(RMSEA95))
preserve
predict f1 f2, bartlett
foreach v of varlist party`x' broad`x' print`x' civlib`x' {
qui replace `v' = `v' - [lambda_`v'_pollib`x']_cons*f1
}
foreach v of varlist leg`x' polrt`x' compet`x' effec`x' {
qui replace `v' = `v' - [lambda_`v'_demrul`x']_cons*f2
}
confa (sussman`x': broad`x' print`x') (gastil`x': civlib`x' polrt`x') (banks`x': leg`x' compet`x' effec`x'), from(smart) usenames iter(20)
matrix b_res = e(b)
restore
matrix bb = (b_t[1,1..19], b_res[1,8..27])
constraint define 1 [phi_demrul`x'_sussman`x']_cons = 0
constraint define 2 [phi_pollib`x'_sussman`x']_cons = 0
constraint define 3 [phi_demrul`x'_gastil`x']_cons = 0
constraint define 4 [phi_pollib`x'_gastil`x']_cons = 0
constraint define 5 [phi_gastil`x'_banks`x']_cons = 0
constraint define 6 [phi_sussman`x'_banks`x']_cons = 0
constraint define 7 [phi_demrul`x'_banks`x']_cons = 0
constraint define 8 [phi_pollib`x'_banks`x']_cons = 0
constraint define 9 [theta_polrt`x']_cons = 0
constraint define 10 [theta_compet`x']_cons = 0
confa (pollib`x': party`x' broad`x' print`x' civlib`x') (demrul`x': leg`x' polrt`x' compet`x' effec`x') (sussman`x': broad`x' print`x') (gastil`x': civlib`x' polrt`x') (banks`x': leg`x' compet`x' effec`x'), constr(1 2 3 4 5 6 7 8 9 10) vce(sbentler) from(bb) usenames difficult iter(75)
matrix init = e(b)
estat fit
matrix y19`x'f = (((e(lr_indep) - e(chi2)) / (e(lr_indep) - e(df_m))) , e(Tsc) , e(p_Tsc) , e(Tadj) , e(p_Tadj) , e(T2) , e(p_T2) , e(lr_indep) , e(ll) , e(df_m) , r(AIC) , r(BIC) , r(CFI) , r(TLI) , r(RMSR) , 1-r(RMSEA) , 1-r(RMSEA05) , 1-r(RMSEA95))
matrix y19`x' = y19`x't , y19`x'f
matrix colnames y19`x' = delta2t tsct ptsct tadjt ptadjt t2t pt2t chi2ti llt dft aict bict cfit tlit rmsrt irmseat irmsea05t irmsea95t delta2f tscf ptscf tadjf ptadjf t2f pt2f chi2fi llf dff aicf bicf cfif tlif rmsrf irmseaf irmsea05f irmsea95f
matrix rownames y19`x' = y19`x'
matrix drop y19`x't
matrix drop y19`x'f
}
local years "80 81 83 84 85 86 87"
foreach x of local years {
matrix coleq init = mean_party`x':_cons mean_broad`x':_cons mean_print`x':_cons mean_civlib`x':_cons mean_leg`x':_cons mean_polrt`x':_cons mean_compet`x':_cons mean_effec`x':_cons lambda_party`x'_pollib`x':_cons lambda_broad`x'_pollib`x':_cons lambda_print`x'_pollib`x':_cons lambda_civlib`x'_pollib`x':_cons lambda_leg`x'_demrul`x':_cons lambda_polrt`x'_demrul`x':_cons lambda_compet`x'_demrul`x':_cons lambda_effec`x'_demrul`x':_cons lambda_broad`x'_sussman`x':_cons lambda_print`x'_sussman`x':_cons lambda_civlib`x'_gastil`x':_cons lambda_polrt`x'_gastil`x':_cons lambda_leg`x'_banks`x':_cons lambda_compet`x'_banks`x':_cons lambda_effec`x'_banks`x':_cons phi_pollib`x'_pollib`x':_cons phi_demrul`x'_demrul`x':_cons phi_pollib`x'_demrul`x':_cons phi_sussman`x'_sussman`x':_cons phi_demrul`x'_sussman`x':_cons phi_pollib`x'_sussman`x':_cons phi_gastil`x'_gastil`x':_cons phi_sussman`x'_gastil`x':_cons phi_demrul`x'_gastil`x':_cons phi_pollib`x'_gastil`x':_cons phi_banks`x'_banks`x':_cons phi_gastil`x'_banks`x':_cons phi_sussman`x'_banks`x':_cons phi_demrul`x'_banks`x':_cons phi_pollib`x'_banks`x':_cons theta_party`x':_cons theta_broad`x':_cons theta_print`x':_cons theta_civlib`x':_cons theta_leg`x':_cons theta_polrt`x':_cons theta_compet`x':_cons theta_effec`x':_cons
confa (pollib`x': party`x' broad`x' print`x' civlib`x') (demrul`x': leg`x' polrt`x' compet`x' effec`x'), vce(sbentler) from(smart) usenames difficult iter(75)
matrix b_t = e(b)
estat fit
matrix y19`x't = (((e(lr_indep) - e(chi2)) / (e(lr_indep) - e(df_m))) , e(Tsc) , e(p_Tsc) , e(Tadj) , e(p_Tadj) , e(T2) , e(p_T2) , e(lr_indep) , e(ll) , e(df_m) , r(AIC) , r(BIC) , r(CFI) , r(TLI) , r(RMSR) , 1-r(RMSEA) , 1-r(RMSEA05) , 1-r(RMSEA95))
constraint define 1 [phi_demrul`x'_sussman`x']_cons = 0
constraint define 2 [phi_pollib`x'_sussman`x']_cons = 0
constraint define 3 [phi_demrul`x'_gastil`x']_cons = 0
constraint define 4 [phi_pollib`x'_gastil`x']_cons = 0
constraint define 5 [phi_gastil`x'_banks`x']_cons = 0
constraint define 6 [phi_sussman`x'_banks`x']_cons = 0
constraint define 7 [phi_demrul`x'_banks`x']_cons = 0
constraint define 8 [phi_pollib`x'_banks`x']_cons = 0
constraint define 9 [theta_polrt`x']_cons = 0
constraint define 10 [theta_compet`x']_cons = 0
confa (pollib`x': party`x' broad`x' print`x' civlib`x') (demrul`x': leg`x' polrt`x' compet`x' effec`x') (sussman`x': broad`x' print`x') (gastil`x': civlib`x' polrt`x') (banks`x': leg`x' compet`x' effec`x'), constr(1 2 3 4 5 6 7 8 9 10) vce(sbentler) from(init) usenames difficult iter(75)
matrix init = e(b)
estat fit
matrix y19`x'f = (((e(lr_indep) - e(chi2)) / (e(lr_indep) - e(df_m))) , e(Tsc) , e(p_Tsc) , e(Tadj) , e(p_Tadj) , e(T2) , e(p_T2) , e(lr_indep) , e(ll) , e(df_m) , r(AIC) , r(BIC) , r(CFI) , r(TLI) , r(RMSR) , 1-r(RMSEA) , 1-r(RMSEA05) , 1-r(RMSEA95))
matrix y19`x' = y19`x't , y19`x'f
matrix colnames y19`x' = delta2t tsct ptsct tadjt ptadjt t2t pt2t chi2ti llt dft aict bict cfit tlit rmsrt irmseat irmsea05t irmsea95t delta2f tscf ptscf tadjf ptadjf t2f pt2f chi2fi llf dff aicf bicf cfif tlif rmsrf irmseaf irmsea05f irmsea95f
matrix rownames y19`x' = y19`x'
matrix drop y19`x't
matrix drop y19`x'f
}
* part 2: 1972-1978, 1982, 1988
matrix initb = init[1,1],init[1,4..9],init[1,12..16],init[1,19..26],init[1,30],init[1,32..35],init[1,37..39],init[1,42..46]
local years "72 73 74 75 76 77 78 82 88"
foreach x of local years {
confa (pollib`x': party`x' civlib`x') (demrul`x': leg`x' polrt`x' compet`x' effec`x'), vce(sbentler) from(smart) usenames difficult iter(75)
matrix b_t = e(b)
estat fit
matrix y19`x't = (((e(lr_indep) - e(chi2)) / (e(lr_indep) - e(df_m))) , e(Tsc) , e(p_Tsc) , e(Tadj) , e(p_Tadj) , e(T2) , e(p_T2) , e(lr_indep) , e(ll) , e(df_m) , r(AIC) , r(BIC) , r(CFI) , r(TLI) , r(RMSR) , 1-r(RMSEA) , 1-r(RMSEA05) , 1-r(RMSEA95))
constraint define 3 [phi_demrul`x'_gastil`x']_cons = 0
constraint define 4 [phi_pollib`x'_gastil`x']_cons = 0
constraint define 5 [phi_gastil`x'_banks`x']_cons = 0
constraint define 7 [phi_demrul`x'_banks`x']_cons = 0
constraint define 8 [phi_pollib`x'_banks`x']_cons = 0
constraint define 9 [theta_polrt`x']_cons = 0
constraint define 10 [theta_compet`x']_cons = 0
matrix coleq initb = mean_party`x':_cons mean_civlib`x':_cons mean_leg`x':_cons mean_polrt`x':_cons mean_compet`x':_cons mean_effec`x':_cons lambda_party`x'_pollib`x':_cons lambda_civlib`x'_pollib`x':_cons lambda_leg`x'_demrul`x':_cons lambda_polrt`x'_demrul`x':_cons lambda_compet`x'_demrul`x':_cons lambda_effec`x'_demrul`x':_cons lambda_civlib`x'_gastil`x':_cons lambda_polrt`x'_gastil`x':_cons lambda_leg`x'_banks`x':_cons lambda_compet`x'_banks`x':_cons lambda_effec`x'_banks`x':_cons phi_pollib`x'_pollib`x':_cons phi_demrul`x'_demrul`x':_cons phi_pollib`x'_demrul`x':_cons phi_gastil`x'_gastil`x':_cons phi_demrul`x'_gastil`x':_cons phi_pollib`x'_gastil`x':_cons phi_banks`x'_banks`x':_cons phi_gastil`x'_banks`x':_cons phi_demrul`x'_banks`x':_cons phi_pollib`x'_banks`x':_cons theta_party`x':_cons theta_civlib`x':_cons theta_leg`x':_cons theta_polrt`x':_cons theta_compet`x':_cons theta_effec`x':_cons
confa (pollib`x': party`x' civlib`x') (demrul`x': leg`x' polrt`x' compet`x' effec`x') (gastil`x': civlib`x' polrt`x') (banks`x': leg`x' compet`x' effec`x'), constr(3 4 5 7 8 9 10) vce(sbentler) from(initb) usenames difficult iter(75)
matrix initb = e(b)
estat fit
matrix y19`x'f = (((e(lr_indep) - e(chi2)) / (e(lr_indep) - e(df_m))) , e(Tsc) , e(p_Tsc) , e(Tadj) , e(p_Tadj) , e(T2) , e(p_T2) , e(lr_indep) , e(ll) , e(df_m) , r(AIC) , r(BIC) , r(CFI) , r(TLI) , r(RMSR) , 1-r(RMSEA) , 1-r(RMSEA05) , 1-r(RMSEA95))
matrix y19`x' = y19`x't , y19`x'f
matrix colnames y19`x' = delta2t tsct ptsct tadjt ptadjt t2t pt2t chi2ti llt dft aict bict cfit tlit rmsrt irmseat irmsea05t irmsea95t delta2f tscf ptscf tadjf ptadjf t2f pt2f chi2fi llf dff aicf bicf cfif tlif rmsrf irmseaf irmsea05f irmsea95f
matrix rownames y19`x' = y19`x'
matrix drop y19`x't
matrix drop y19`x'f
}
matrix A = y1972 \ y1973 \ y1974 \ y1975 \ y1976 \ y1977 \ y1978 \ y1979 \ y1980 \ y1981 \ y1982 \ y1983 \ y1984 \ y1985 \ y1986 \ y1987 \ y1988
matsave A, replace saving
preserve
use "/Users/thiagomarzagao/Desktop/SCpaper/A.dta"
destring _rowname, ignore("y") generate(year)
line irmseat year || line irmseaf year || line delta2t year || line delta2f year
rename irmseat IRMSEAT
rename delta2t IFI
line IRMSEAT year || line IRMSEAT year || line IFI year || line IFI year
line tsct year || line tscf year || line tadjt year || line tadjf year || line t2t year || line t2f year
line aict year || line aicf year || line bict year || line bicf year
line rmsrt year || line rmsrf year || line cfit year || line cfif year
restore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment