capture log close *cd C:\prison_injunctions\ *cd H:\Articles\prison_injunctions\ cd H:\Articles\prison_injunctions\appendix log using log.log, text replace set more 1 clear *** JAIL AND PRISON COURT ORDERS *** ANALYSIS *** STATA 9 *** MARGO SCHLANGER *** April 2006 *** USER COMMANDS: tabchi and grc1leg set memory 30m *use "H:\Data\BJS\allcensuses\jail_and_prison_panel_final.dta", clear use jail_and_prison_panel_final.dta, clear drop if fed == 1 *** Change the delimiter #delimit ; *** THERE's a problem with the variable "ordsm" ; *** Need to regenerate ; order prison-serch oth oth2 ; recode crowd popcp total-oth2 (-9 = .) ; egen ordsm2 = rsum(crowd popcp total-oth2) if ordsm ~= -9 ; replace ordsm2 = 1 if ordsm > 0 & ordsm ~=. ; replace ordsm = ordsm2 if ordsm ~= -9 & s == 1 ; replace ordsm = 1 if order == 1 & year == 1983 ; *** (Note: no apparent problem with lead_ord or lag_ord) ; *** MISSING DATA ; *** Generate an "unreported" variable ; gen unreported = 1 if ordsm == -9 ; replace unreported = 0 if (ordsm == 0 | ordsm == 1) ; gen year_missing = year if (year == 1993 | year == 1999) ; *** MISSING DATA PROBLEM. ; *** Basic descriptives and size comparison ; replace adp = 1 if adp == 0 ; by year, sort : ttest adp if year == 1993 | year == 1999, by(unreported) ; by year, sort : ttest ln_adp if year == 1993 | year == 1999, by(unreported) ; *** Region comparison ; by year, sort : tabulate region unreported if year == 1993 | year == 1999, chi2 column nofreq ; * findit tabchi [user command- will need to install if not there] ; *** Residuals ; tabchi region unreported if year == 1993, raw pearson cont adjust noo noe ; tabchi region unreported if year == 1999, raw pearson cont adjust noo noe ; *** Order in prior year ; by year, sort : ttest lag_ord if (year == 1993 | year == 1999) & (lag_ord ~= -9 & lag_ord ~= -8), by(unreported); ************************************************* ************************************************* ************************************************* ************************************************* *** ANALYSIS OF THE DATA THAT ARE THERE ; *** Jails vs. prisons ; gsort +prison +year -adp ; by prison year: egen adp_by_year = sum(adp) ; by prison year: gen adp_cum = sum(adp) ; *** NOTE DIFFERENCE BETWEEN egen and gen above ; *** gen is a running total. egen is an overall total ; gen size_rank = . ; replace size_rank = 1 if year ~= year[_n-1] ; replace size_rank = size_rank[_n-1] + 1 if year == year[_n-1] & s > 0 ; gen size_prop = adp_cum/adp_by_year ; replace adp_cum = . if s == 0 ; replace adp_by_year = . if s == 0 ; label var size_prop "Proportion of total population in this size or larger" ; twoway (scatter size_rank size_prop if year == 1999 & size_rank < 50) (scatter size_rank size_prop if year == 2000 & size_rank < 50), title("1999 Jail and 2000 Prison Size Distribution") subtitle("by size rank of facility") xlabel(0(.05).5) ylabel(0(5)50) legend(order(1 "jail" 2 "prison")) ; graph save size_and_population_totals.gph, replace ; * Created size-normalized variables ; sort prison year ; bysort prison year: egen year_adp = sum(adp) ; sort prison id year ; gen per0_adp = year_adp if period == 0 ; replace per0_adp = per0_adp[_n-1] if period == 1 ; replace per0_adp = per0_adp[_n-2] if period == 2 ; replace per0_adp = per0_adp[_n-3] if period == 3 ; gen adp_adj = year_adp/per0_adp ; gen normed_adp = adp/adp_adj ; gen ln_normed_adp = ln(normed_adp) ; label variable year_adp "Total adp by year" ; label variable per0_adp "Total adp in period 0" ; label variable adp_adj "Adp adjustment for normalizing" ; label variable normed_adp "ADP normed to period 0" ; label variable ln_normed_adp "Ln normed adp" ; save c:\temp\working1.dta, replace ; *** DIFFERENCE AMONG YEARS ; *************************** ; gen ord = ordsm if (ordsm == 1 | ordsm == 0) ; by prison, sort : prtest ord if period == 0 | period == 1, by (year) ; by prison, sort : prtest ord if period == 1 | period == 2, by (year) ; by prison, sort : prtest ord if period == 2 | period == 3, by (year) ; bysort prison: tab prison year ; bysort prison: tab prison year [fweight = adp] ; bysort prison: table year, contents(n adp sum adp mean adp sd adp) ; *** COMPUTE PERCENTAGES. ; bysort prison: tabulate ord year [fweight=adp], column ; *** OLD ORDERS AND NEW ORDERS ; *** I have two order age variables: ord_age and ord_age2. ; tabulate ord_age ord_age2 ; *** They're not very different: *** just 67 orders that are old according to ord_age *** but new according to ord_age2 ; *** USE ORD_AGE *** oops: THERE IS SOMETHING WRONG WITH THIS VARIABLE. ; sort prison id year ; gen new_ord_2 = 0 if ord == 0 ; gen old_ord_2 = 0 if ord == 0 ; replace old_ord_2 = 1 if ord == 1 & id == id[_n-1] & ord[_n-1] == 1 ; replace new_ord_2 = 1 if ord == 1 & id == id[_n-1] & ord[_n-1] == 0 ; replace new_ord_2 = 1 if ord == 1 & id == id[_n-1] & s[_n-1] == 0 ; replace new_ord_2 = 1 if ord == 1 & (year == 1983 | year == 1984) ; replace new_ord_2 = . if id == id[_n-1] & unreported[_n-1] == 1 ; replace old_ord_2 = . if id == id[_n-1] & unreported[_n-1] == 1 ; gen ordagesum = 0 if old_ord_2 == 0 & new_ord_2 == 0 ; replace ordagesum = 1 if old_ord_2 == 1 ; replace ordagesum = 2 if new_ord_2 == 1 ; label define ordage 0 "No order" ; label define ordage 1 "Old order", add ; label define ordage 2 "New order", add ; label values ordagesum ordage ; by prison, sort : tabulate ordagesum year ; by prison, sort : tabulate ordagesum year [fweight = adp] ; *** ONE BIG GRAPH: ; save c:\temp\working1.dta, replace ; *** SAVE MEANS BY POP ; collapse (mean) ord old_ord_2 new_ord_2 [fweight=adp], by(prison year) ; rename ord ord_adp ; rename old_ord_2 old_adp ; rename new_ord_2 new_adp ; sort prison year ; save ord.dta, replace ; *** NEXT SAVE MEANS BY FACILITY ; use c:\temp\working1.dta, clear ; collapse (mean) ord old_ord_2 new_ord_2 (sum) adp (sum) n, by(prison year) ; rename ord ord_fac ; rename old_ord_2 old_fac ; rename new_ord_2 new_fac ; sort prison year ; *** MERGE THE TWO ; merge prison year using ord.dta, unique ; save ord.dta, replace ; drop _merge ; save ord.dta, replace ; *** Graphics ; label define prison 0 "jail", modify ; label define prison 1 "prison", modify ; gen period = 1 if year == 1983 | year == 1984 ; replace period = 2 if year == 1988 | year == 1990 ; replace period = 3 if year == 1993 | year == 1995 ; replace period = 4 if year == 1999 | year == 2000 ; gen period2 = period - 0.2 ; gen period3 = period + 0.2 ; save ord.dta, replace ; drop if prison == 1 ; twoway bar old_fac period2, bcolor(blue*.8) barw(0.4) || rbar old_fac ord_fac period2, bcolor(blue*.5) barw(0.4) || bar old_adp period3, bcolor(red*.8) barw(0.4) || rbar old_adp ord_adp period3, bcolor(red*.5) barw(0.4) legend(off) ylabel(0(.1).5, grid) xlabel( 1 "1983" 2 "1988" 3 "1993" 4 "1999" ) subtitle("Jails") saving(JailOrders.gph, replace) ; twoway bar ord_fac period2, bcolor(blue*.5) barw(0.4) || bar ord_adp period3, bcolor(red*.5) barw(0.4) legend(off) ytitle(" ") ylabel(0(.1).5, grid) xlabel( 1 "1983" 2 "1988" 3 "1993" 4 "1999" ) subtitle("Jails") saving(JailOrders_all.gph, replace) ; gen fill = 0 ; twoway bar ord_fac period2, bcolor(red*.5) barw(0.4) || bar fill period3, bcolor(red*.0) barw(0.4) legend(off) xlabel( 1 "1983" 2 "1988" 3 "1993" 4 "1999" ) ylabel(0(.1).5, grid) subtitle("Jails") saving(JailOrders_fac.gph, replace) ; use ord.dta, clear ; drop if prison == 0 ; twoway bar old_fac period2, bcolor(blue*.8) barw(0.4) || rbar old_fac ord_fac period2, bcolor(blue*.5) barw(0.4) || bar old_adp period3, bcolor(red*.8) barw(0.4) || rbar old_adp ord_adp period3, bcolor(red*.5) barw(0.4) legend(order(2 "Facilities w/ new regulation" 1 "Facilities w/ cont. regulation" 4 "Population w/ new regulation" 3 "Population w/ cont. regulation") colfirst) ylabel(0(.1).5, grid) xlabel( 1 "1984" 2 "1990" 3 "1995" 4 "2000" ) subtitle("Prisons") saving(PrisonOrders.gph, replace) ; twoway bar ord_fac period2, bcolor(blue*.5) barw(0.4) || bar ord_adp period3, bcolor(red*.5) barw(0.4) legend(order(1 "Orders by facility" 2 "Orders by population" 3 " " 4 " ") ) ytitle(" ") ylabel(0(.1).5, grid) xlabel( 1 "1984" 2 "1990" 3 "1995" 4 "2000" ) subtitle("Prisons") saving(PrisonOrders_all.gph, replace) ; gen fill = 0 ; twoway bar ord_fac period2, bcolor(red*.5) barw(0.4) || bar fill period3, bcolor(blue*.0) barw(0.4) legend(order(1 "Orders by facility" 2 " " 3 " " 4 " ")) xlabel( 1 "1984" 2 "1990" 3 "1995" 4 "2000" ) ylabel(0(.1).5, grid) subtitle("Prisons") saving(PrisonOrders_fac.gph, replace) ; grc1leg JailOrders.gph PrisonOrders.gph, legendfrom(PrisonOrders.gph) cols(1) note("Source: Derived from Bureau of Justice Statistics Censuses") l1title(Proportion of all reporting) title("Court order incidence")ycommon ; graph save orders.gph, asis replace ; grc1leg JailOrders_all.gph PrisonOrders_all.gph, legendfrom(PrisonOrders_all.gph) note("Source: Derived from Bureau of Justice Statistics Censuses") cols(1) l1title(Proportion of all reporting) title("Court order incidence")ycommon ; graph save All_orders.gph, asis replace ; grc1leg JailOrders_fac.gph PrisonOrders_fac.gph, legendfrom(PrisonOrders_fac.gph) note("Source: Derived from Bureau of Justice Statistics Censuses") cols(1) l1title(Proportion of all reporting) title("Court order incidence")ycommon ; graph save fac_orders.gph, asis replace ; *** NOTE: need to save "asis" because of a bug in grc1leg ; **** Run the 1995-2000 prison stuff again, without New York and Ohio ; do NY_ohio.do ; ******************************* *END NY/OHIO STUFF ; cd h:\articles\prison_injunctions ; *cd c:\prison_injunctions ; *** COURT ORDER COVERAGE WITHIN STATES ; use c:\temp\working1.dta, clear ; *** FIRST, SAVE ORDER MEANS BY POPULATION ; sort state prison year ; collapse (mean) ord [fweight=adp], by(state prison year) ; rename ord ord_adp ; sort state prison year ; save states.dta, replace ; *** NEXT SAVE MEANS BY FACILITY ; use c:\temp\Working1.dta, clear ; sort state prison year ; collapse (mean) ord (sum) adp (sum) n, by(state prison year) ; rename ord ord_fac ; sort state prison year ; *** MERGE THE TWO ; merge state prison year using states.dta, unique ; drop _merge ; save states.dta, replace ; *** SYSTEM STATE COVERAGE ; gen system = ord_fac ; replace system = 1 if (ord_fac > .7 | ord_adp > .7) ; replace system = 1 if (ord_fac + ord_adp >=.99 ) ; replace system = 0 if system ~= 1 ; gen any = 0 ; replace any = 1 if ord_fac > 0 ; gen sum = ord_fac + ord_adp ; gen sysstate = system ; sort prison state ; replace sysstate = 1 if state == state[_n-1] & sysstate[_n-1] == 1 ; replace sysstate = 1 if state == state[_n+1] & sysstate[_n+1] == 1 ; replace sysstate = 1 if state == state[_n+1] & sysstate[_n+1] == 1 ; replace sysstate = 1 if state == state[_n+1] & sysstate[_n+1] == 1 ; save states.dta, replace ; *** THIS IS THE FINAL VERSION ; *** Statistical testing ; * T-test for mean ; *** FIRST REORDER DATA ; drop adp n system any sum sysstate ; rename ord_fac fac ; rename ord_adp adp ; reshape wide fac adp, i( state prison) j( year) ; ttest fac1983 == fac1988 ; ttest fac1988 == fac1993 ; ttest fac1993 == fac1999 ; ttest fac1984 == fac1990 ; ttest fac1990 == fac1995 ; ttest fac1995 == fac2000 ; ttest adp1983 == adp1988 ; ttest adp1988 == adp1993 ; ttest adp1993 == adp1999 ; ttest adp1984 == adp1990 ; ttest adp1990 == adp1995 ; ttest adp1995 == adp2000 ; sdtest fac1983 == fac1988 ; sdtest fac1988 == fac1993 ; sdtest fac1993 == fac1999 ; sdtest fac1984 == fac1990 ; sdtest fac1990 == fac1995 ; sdtest fac1995 == fac2000 ; sdtest adp1983 == adp1988 ; sdtest adp1988 == adp1993 ; sdtest adp1993 == adp1999 ; sdtest adp1984 == adp1990 ; sdtest adp1990 == adp1995 ; sdtest adp1995 == adp2000 ; *** FOR TESTING THE DIFFERENCE IN CHANGES ACROSS YEARS ; use states.dta, clear ; drop adp n system any sum sysstate ; rename ord_fac fac ; rename ord_adp adp ; sort state prison year ; gen fac_d = fac - fac[_n-1] if year > 1984 ; gen adp_d = adp - adp[_n-1] if year > 1984 ; drop fac adp ; drop if year == 1983 ; drop if year == 1984 ; rename fac_d fac ; rename adp_d adp ; reshape wide fac adp, i( state prison) j( year) ; *** test variance first ; sdtest fac1988 == fac1993 ; sdtest fac1993 == fac1999 ; sdtest fac1990 == fac1995 ; sdtest fac1995 == fac2000 ; sdtest adp1988 == adp1993 ; sdtest adp1993 == adp1999 ; sdtest adp1990 == adp1995 ; sdtest adp1995 == adp2000 ; ttest fac1988 == fac1993, unpaired unequal ; ttest fac1993 == fac1999, unpaired unequal ; ttest fac1990 == fac1995, unpaired unequal ; ttest fac1995 == fac2000, unpaired unequal ; ttest adp1988 == adp1993, unpaired unequal ; ttest adp1993 == adp1999, unpaired unequal ; ttest adp1990 == adp1995, unpaired unequal ; ttest adp1995 == adp2000, unpaired unequal ; use states.dta, clear ; bysort prison: tab any year ; bysort prison: tab system year ; drop ord_fac adp n ord_adp any sum sysstate ; drop if system ~= 1 ; reshape wide system, i( prison state ) j( year ) ; order prison state system1983 system1988 system1993 system1999 system1984 system1990 system1995 system2000 ; sort state prison ; replace system1984 = system1984[_n+1] if state == state[_n+1] ; replace system1990 = system1990[_n+1] if state == state[_n+1] ; replace system1995 = system1995[_n+1] if state == state[_n+1] ; replace system2000 = system2000[_n+1] if state == state[_n+1] ; drop if state == state[_n-1] ; drop prison ; save system, replace ; *** MOVE THIS OVER INTO WORD PROCESSING, DO A BIT OF MESSING AND IT'S DONE ; *** CHECKING AROUND CUT POINTS ; *** SUMMARIZE ; use states.dta, clear ; drop if sysstate ~= 1 ; drop ord_fac adp n ord_adp any system ; reshape wide sum, i( prison state ) j( year ) ; order prison state sum1983 sum1988 sum1993 sum1999 sum1984 sum1990 sum1995 sum2000 ; sort state prison ; replace sum1984 = sum1984[_n+1] if state == state[_n+1] ; replace sum1990 = sum1990[_n+1] if state == state[_n+1] ; replace sum1995 = sum1995[_n+1] if state == state[_n+1] ; replace sum2000 = sum2000[_n+1] if state == state[_n+1] ; drop if state == state[_n-1] ; drop prison ; drop sysstate ; save system_states_sum.dta, replace ; *** FACILITY ; use states.dta, clear ; drop if sysstate ~= 1 ; drop sum adp n ord_adp any system ; rename ord_fac fac ; reshape wide fac, i( prison state ) j( year ) ; order prison state fac1983 fac1988 fac1993 fac1999 fac1984 fac1990 fac1995 fac2000 ; sort state prison ; replace fac1984 = fac1984[_n+1] if state == state[_n+1] ; replace fac1990 = fac1990[_n+1] if state == state[_n+1] ; replace fac1995 = fac1995[_n+1] if state == state[_n+1] ; replace fac2000 = fac2000[_n+1] if state == state[_n+1] ; drop if state == state[_n-1] ; drop prison ; drop sysstate ; save system_states_fac.dta, replace ; *** adp ; use states.dta, clear ; drop if sysstate ~= 1 ; drop ord_fac adp n any sum system ; rename ord_adp adp ; reshape wide adp, i( prison state ) j( year ) ; order prison state adp1983 adp1988 adp1993 adp1999 adp1984 adp1990 adp1995 adp2000 ; sort state prison ; replace adp1984 = adp1984[_n+1] if state == state[_n+1] ; replace adp1990 = adp1990[_n+1] if state == state[_n+1] ; replace adp1995 = adp1995[_n+1] if state == state[_n+1] ; replace adp2000 = adp2000[_n+1] if state == state[_n+1] ; drop if state == state[_n-1] ; drop prison ; drop sysstate ; save system_states_adp.dta, replace ; merge state using system_states_fac.dta system_states_sum.dta, unique sort ; drop _merge* ; save system_states.dta, replace ; *** MEANS ETC. ; use states.dta, clear ; by prison year, sort : summarize ord_fac ord_adp ; ***Or, to produce something nicer to look at, collapse again ; sort prison year ; collapse (mean) ord_fac ord_adp (median) med_ord_fac=ord_fac med_ord_adp = ord_adp (sd) sd_ord_fac=ord_fac sd_ord_adp = ord_adp (sum) adp (sum) n, by(prison year) ; gen ord_n = ord_fac * n ; *** NEED TO CHECK THIS ; *** reorder variables: ; order year n adp ord_n ord_fac med_ord_fac sd_ord_fac ord_adp med_ord_adp sd_ord_adp ; save state_sum.dta, replace ; *** Can use this to cut and paste into excel; *** Convert the display to %, change the column headings *** and move into the actual document. ; *** STATE HISTOGRAMS ; use states.dta, clear ; label define prison 0 "Jail", modify ; label define prison 1 "Prison", modify ; histogram ord_adp, ylabel(0(.2).6, grid) ysize(15) xsize(8) bin(10) xtitle("") fcolor(red*.5) blcolor(red*.8) fraction by(prison year, ix iy colfirst cols(2) title("Distribution by state of" "court order coverage" "by population") note("Source: Derived from Bureau of Justice Statistics Censuses")) ; graph save state_adp_histograms_red, replace ; * title("Distribution by state of" "court order coverage" "by population") ; histogram ord_adp, ylabel(0(.2).6, grid) ysize(15) xsize(8) bin(10) xtitle("Proportion of incarcerated population subject to court order") ytitle("Fraction of states") fcolor(gs5) lcolor(gs3) fraction by(prison year, ix iy colfirst cols(2) note(" " "Source: Derived from Bureau of Justice Statistics Censuses")) scheme(s1mono) ; graph save state_adp_histograms_b&w, replace ; *** NEED TWO, FOR POWERPOINT, etc. ; histogram ord_adp if year < 1993, ylabel(0(.2).6, grid) ysize(7.5) xsize(8) bin(10) xtitle("") bcolor(red*.5) blcolor(red*.8) fraction by(prison year, ix iy colfirst cols(2) title("Distribution by state of" "court order coverage" "by population") note("Source: Derived from Bureau of Justice Statistics Censuses")) ; graph save state_adp_histograms_80s, replace ; **********THIS IS FIGURE 2 *title("Distribution by state of" "court order coverage" "by population") *note("Source: Derived from Bureau of Justice Statistics Censuses")) histogram ord_adp if year > 1990, scheme(s1mono) ylabel(0(.2).6, grid) ysize(7.5) xsize(8) bin(10) xtitle("Fraction of state's prison population under court order" " ") ytitle("Fraction of states") fcolor(gs5) lcolor(gs3) fraction by(prison year, ix iy colfirst cols(2) note( ., size(minuscule) color(none))) ; graph save state_adp_histograms_90s, replace ; graph export state_adp_histograms_90s.emf, fontface("Times New Roman") replace; *** ALTERNATE LOOK: *histogram ord_adp if year > 1990, ylabel(0 "0%" 20 "20%" 40 "40%" 60 "60%", grid) ysize(9) xsize(8) bin(10) xlabel(0 "0%" .5 "50%" 1 "100%") bcolor(red*.5) blcolor(red*.8) percent xtitle("Court order coverage") ytitle("Percentage of states") by(prison year, ix iy colfirst cols(2) title("Distribution by state of" "court order coverage" "by population") note(" " "Source: Derived from Bureau of Justice Statistics Censuses")) ; *graph save state_adp_histograms_90s, replace ; *** INTRASTATE CHANGES ; use states.dta, clear ; label define prison 0 "Jail", modify ; label define prison 1 "Prison", modify ; gen delta_ord_adp = (ord_adp - ord_adp[_n-1]) if state == state[_n-1] ; replace delta_ord_adp = . if year == 1984 ; *** title("Figure 1: Change, by state, in proportion" "of population housed in entities" "subject to court order") ; histogram delta_ord_adp if year > 1984, fraction ylabel(0(.1).4, grid) ysize(10) xsize(8) ytitle("Fraction of states") xtitle("Intrastate change in court-order coverage") bcolor(gs5) blcolor(gs3) scheme(s1mono) by(prison year, ix iy colfirst cols(2) note( ., size(minuscule) color(none))) ; graph save intrastate_changes_histograms, replace ; graph export intrastate_changes_histograms.emf, fontface("Times New Roman") replace; *** OR, with percentages; histogram delta_ord_adp if year > 1984, percent ylabel(0 "0%" 20 "20%" 40 "40%", grid) ysize(10) xsize(8) ytitle("Percentage of states") xtitle("Intrastate change in court-order coverage") bcolor(gs5) blcolor(gs3) scheme(s1mono) by(prison year, ix iy colfirst cols(2) note( ., size(minuscule) color(none))) ; graph save intrastate_changes_histograms_percent, replace ; graph export intrastate_changes_histograms_percent.emf, fontface("Times New Roman") replace; *** to change the size of the text, use "iscale(*1.2)" or whatever, after cols(2); *** IN COLOR; *histogram delta_ord_adp if year > 1984, ylabel(0(.1).4, grid) ysize(10) xsize(8) ytitle("Fraction of states") xtitle("Intrastate change in court-order coverage") bcolor(gs5) blcolor(gs3)fraction by(prison year, ix iy colfirst cols(2) title("Figure 1: Change, by state, in proportion" "of population housed in entities" "subject to court order") note(" " "Source: Derived from Bureau of Justice Statistics Censuses, supra notes 79-80")) scheme(s1mono) ; *** IT WOULD BE NICE TO KNOW HOW TO GET SUB FIGURE NUMBERS ON THIS. ; *** Putting "addlabels" before the word "percent" adds labels, *** but too many digits ; *** It would be nice to make these display w/o decimals. *** But yvarformat changes the yvar, not the label format. *** COLLAPSE FOR EASE OF TRANSFER. ; by prison year, sort : summarize delta_ord_adp ; ***Or, to produce something nicer to look at, collapse again ; sort prison year ; collapse (mean) delta_ord_adp (median) med_delta_ord_adp = delta_ord_adp (sd) sd_delta_ord_adp = delta_ord_adp, by(prison year) ; *** MERGE WITH PRIOR FILE. ; merge prison year using state_sum.dta, unique ; save state_sum.dta, replace ; drop _merge ; save state_sum.dta, replace ; ********************ORDER DEPTH ; use c:\temp\working1.dta, clear ; *drop the unreporteds ; gen tot = total if (total == 0 | total == 1) ; *** THERE ARE A BUNCH OF PROBLEMS WITH THE SUMMARIES: REGENERATE THEM ALL ; drop crowdsm noncrowd non_cro non_ord non_pop pop_only ; replace ord = 1 if popcp == 1 ; generate crowdsm = popcp if (ord == 0 | ord == 1) ; replace crowdsm = 1 if crowd == 1 ; generate non_cro = ord if (ord == 0 | ord == 1) ; replace non_cro = 0 if crowdsm == 1 ; generate non_pop = crowd if (crowd == 0 | crowd == 1) ; replace non_pop = 0 if popcp == 1 ; generate non_ord = ord if (ord == 0 | ord == 1) ; replace non_ord = 0 if (crowdsm == 1 | tot == 1) ; generate non_ord2 = 0 if ord == 0 ; replace non_ord2 = 0 if crowdsm == 0 ; replace non_ord2 = 1 if (adseg == 1 | disc == 1 | griev == 1 | staff == 1 | food == 1 | med == 1 | visit == 1 | rec == 1 | fire == 1 | coun == 1 | class == 1 | libr == 1 | relig == 1 | educ == 1 | prot == 1 | mh == 1 | discr == 1 | disab == 1 | serch == 1 | oth == 1 | oth2 == 1) ; generate noncrowd = non_ord2 ; replace noncrowd = 1 if total == 1 ; generate nonpop = noncrowd ; replace nonpop = 1 if crowd == 1 ; generate pop_only = popcp if (popcp == 0 | popcp == 1) ; replace pop_only = 0 if nonpop == 1 ; label variable ord "Any order" ; label variable crowdsm "Pop cap or other crowding order" ; label variable popcp "Pop cap" ; label variable crowd "Non-pop cap crowding order" ; label variable non_cro "Order & no crowding order" ; label variable non_pop "Crowding & no pop cap" ; label variable tot "Totality order" ; label variable non_ord "Order & no crowding order, no totality order" ; label variable non_ord2 "Order other than crowding, totality" ; label variable noncrowd "Order other than crowding" ; label variable nonpop "Order other than pop cap" ; label variable pop_only "Pop cap only" ; order prison-ordnum ord crowdsm popcp crowd non_cro non_pop tot non_ord non_ord2 noncrowd nonpop pop_only ; ; recode ord - pop_only (-9 = .) ; *** COMPUTE PERCENTAGES. ; bysort prison: tabulate ord year, column ; bysort prison: tabulate ord year [fweight=adp], column ; bysort prison: tabulate crowdsm year, column ; bysort prison: tabulate crowdsm year [fweight=adp], column ; bysort prison: tabulate popcp year, column ; bysort prison: tabulate popcp year [fweight=adp], column ; bysort prison: tabulate crowd year, column ; bysort prison: tabulate crowd year [fweight=adp], column ; bysort prison: tabulate non_cro year, column ; bysort prison: tabulate non_cro year [fweight=adp], column ; bysort prison: tabulate non_pop year, column ; bysort prison: tabulate non_pop year [fweight=adp], column ; bysort prison: tabulate tot year, column ; bysort prison: tabulate tot year [fweight=adp], column ; bysort prison: tabulate non_ord year, column ; bysort prison: tabulate non_ord year [fweight=adp], column ; bysort prison: tabulate non_ord2 year, column ; bysort prison: tabulate non_ord2 year [fweight=adp], column ; bysort prison: tabulate noncrowd year, column ; bysort prison: tabulate noncrowd year [fweight=adp], column ; bysort prison: tabulate nonpop year, column ; bysort prison: tabulate nonpop year [fweight=adp], column ; bysort prison: tabulate pop_only year, column ; bysort prison: tabulate pop_only year [fweight=adp], column ; *** MAKES MORE SENSE TO MAKE A NEW DATASET WITH THIS sort prison year ; save working2.dta, replace ; collapse (mean) ord crowdsm popcp crowd non_cro non_pop tot non_ord non_ord2 noncrowd nonpop pop_only [fweight=adp], by(prison year) ; rename ord ord_adp ; rename crowdsm crowdsm_adp ; rename popcp popcp_adp ; rename crowd crowd_adp ; rename non_cro non_cro_adp ; rename non_pop non_pop_adp ; rename tot tot_adp ; rename non_ord non_ord_adp ; rename non_ord2 non_ord2_adp ; rename noncrowd noncrowd_adp ; rename nonpop nonpop_adp ; rename pop_only pop_only_adp ; sort prison year ; save totality_etc.dta, replace ; use working2.dta, clear ; collapse (mean) ord crowdsm popcp crowd non_cro non_pop tot non_ord non_ord2 noncrowd nonpop pop_only, by (prison year) ; merge prison year using totality_etc.dta, unique ; drop _merge ; *** THIS MAKES A FILE THAT CAN BE TRANSFERRED INTO EXCEL *** FIXED FOR NUMBER FORMAT AND THEN MOVED INTO WP *** Graphics ; label define prison 0 "jail", modify ; label define prison 1 "prison", modify ; label variable tot_adp "Incidence by population" ; label variable tot "Incidence by facility" ; graph bar (asis) tot tot_adp, over(year) nofill by(prison, title("Prevalence of Totality of Conditions Orders" "among jails and prisons with any court order") note("Source: Bureau of Justice Statistics")) ; graph save totality, replace ; label variable ord "Any order" ; label variable crowdsm "Pop cap or other crowding order" ; label variable popcp "Pop cap" ; label variable crowd "Non-pop cap crowding order" ; label variable non_cro "Order & no crowding order" ; label variable non_pop "Crowding & no pop cap" ; label variable tot "Totality order" ; label variable non_ord "Order & no crowding order, no totality order" ; label variable non_ord2 "Order other than crowding, totality" ; label variable noncrowd "Order other than crowding" ; label variable nonpop "Order other than pop cap" ; label variable pop_only "Pop cap only" ; label variable ord_adp "Any order (by ADP)" ; label variable crowdsm_adp "Pop cap or other crowding order(by ADP)" ; label variable popcp_adp "Pop cap(by ADP)" ; label variable crowd_adp "Non-pop cap crowding order(by ADP)" ; label variable non_cro_adp "Order & no crowding order(by ADP)" ; label variable non_pop_adp "Crowding & no pop cap(by ADP)" ; label variable tot_adp "Totality order(by ADP)" ; label variable non_ord_adp "Order & no crowding order, no totality order(by ADP)" ; label variable non_ord2_adp "Order other than crowding, totality(by ADP)" ; label variable noncrowd_adp "Order other than crowding(by ADP)" ; label variable nonpop_adp "Order other than pop cap(by ADP)" ; label variable pop_only_adp "Pop cap only (by ADP)" ; save totality_etc.dta, replace ; *** OTHER TOPICS ; use working2.dta, clear ; sort prison year ; collapse (mean) ord [fweight=adp], by(prison year) ; rename ord ord_adp ; save c:\temp\order_any.dta, replace ; use working2.dta, clear ; sort prison year ; collapse (mean) ord , by(prison year) ; merge prison year using c:\temp\order_any.dta, unique ; drop _merge ; sort prison year ; save c:\temp\order_any.dta, replace ; use working2.dta, clear ; drop if ord ~= 1 ; sort prison year ; gen med_mh = 0 if med == 0 ; replace med_mh = 1 if med == 1 | mh == 1 ; collapse (mean) total crowdsm crowd popcp med_mh med mh adseg disc griev staff food visit rec fire coun class libr relig educ prot discr disab serch oth [fweight=adp], by(prison year) ; rename total total_adp ; rename crowdsm crowdsm_adp ; rename crowd crowd_adp ; rename med_mh med_mh_adp ; rename popcp popcp_adp ; rename adseg adseg_adp ; rename disc disc_adp ; rename griev griev_adp ; rename staff staff_adp ; rename food food_adp ; rename med med_adp ; rename visit visit_adp ; rename rec rec_adp ; rename fire fire_adp ; rename coun coun_adp ; rename class class_adp ; rename libr libr_adp ; rename relig relig_adp ; rename educ educ_adp ; rename prot prot_adp ; rename mh mh_adp ; rename discr discr_adp ; rename disab disab_adp ; rename serch serch_adp ; rename oth oth_adp ; sort prison year ; save c:\temp\order_topics.dta, replace ; use working2.dta, clear ; drop if ord ~= 1 ; sort prison year ; gen med_mh = 0 if med == 0 ; replace med_mh = 1 if med == 1 | mh == 1 ; collapse (mean) total crowdsm crowd popcp med_mh med mh adseg disc griev staff food visit rec fire coun class libr relig educ prot discr disab serch oth, by(prison year) ; merge prison year using c:\temp\order_topics.dta, unique ; drop _merge ; sort prison year ; merge prison year using c:\temp\order_any.dta, unique ; drop _merge ; order prison year ord ord_adp ; *** THIS MAKES A FILE THAT CAN BE TRANSFERRED INTO EXCEL *** FIXED FOR NUMBER FORMAT AND THEN MOVED INTO WP ; *** Graphics ; label define prison 0 "jail", modify ; label define prison 1 "prison", modify ; save order_topics.dta, replace ; *** NUMBER OF TOPICS ; use working2.dta, clear ; *** recode crowd-oth2 (missing = 0) (I don't need this) ; egen fin_ord_num = rsum(crowd adseg-oth2) ; replace fin_ord_num = fin_ord_num + 1 if crowd == 0 & popcp == 1 ; replace fin_ord_num = . if fin_ord_num < 0 ; replace fin_ord_num = 12 if fin_ord_num > 11 & fin_ord_num < . ; label define fin_ord_num 12 "12+", modify ; label values fin_ord_num ord_num ; replace fin_ord_num = . if year == 1983 ; label variable fin_ord_num "Number of order topics" ; label define prison 0 "jail", modify ; label define prison 1 "prison", modify ; ** title("Number of regulated topics" "among entities with court orders" " ") ; gen prisonyear = 0; replace prisonyear = 1 if year == 1999 ; replace prisonyear = 2 if year == 1993 ; replace prisonyear = 3 if year == 1988 ; replace prisonyear = 4 if year == 1983 ; replace prisonyear = 5 if year == 2000 ; replace prisonyear = 6 if year == 1995 ; replace prisonyear = 7 if year == 1990 ; replace prisonyear = 8 if year == 1984 ; la def prisonyear 1 "Jail, 1999" 2 "Jail, 1993" 3 "Jail, 1988" 4 "Jail, 1983" 5 "Prison, 2000" 6 "Prison, 1995" 7 "Prison, 1990" 8 "Prison, 1984" ; la val prisonyear prisonyear ; * histogram fin_ord_num if ord == 1 & fin_ord_num > 0 & year > 1983 , xsize(20) ysize(14) yscale(alt) xlabel(1 3 6 9 12 "12+") fraction fcolor(red*.5) lcolor(red*.8) by(prison year, ix cols(4) holes(1) title("Number of regulated topics" "among entities with topic-specific court orders" " ", size(*1.1)) note (" " "Data source: Bureau of Justice Statistics Censuses")) ; histogram fin_ord_num if ord == 1 & fin_ord_num > 0 & year > 1983, ysize(10) xsize(15) fcolor(gs5) lcolor(gs3) scheme(s1mono) ytitle ("Fraction of states") xtitle ("Number of court-order topics") xlabel(1 3 6 9 12 "12+") fraction by(prisonyear, cols(4) holes(4) ixaxes note (., size(minuscule) color(none))) ; graph save topic_histograms, replace ; graph export topic_histograms.emf, fontface("Times New Roman") replace; *** Same thing weighted by population and unweighted ; *** Make a variable for total adp of facilities with orders, *** by prison/year ; sort prison year ; gen ord_adp = adp if unreported == 0 & fin_ord_num > 0 & ord == 1 ; by prison year: egen tot_adp = sum(ord_adp) ; by prison year: egen ord_count = count(ord_adp) ; *** Make a variable for portion of population in each facility ; gen portion = ord_adp/tot_adp ; gen portion_n = 1/ord_count if ord_adp ~= . ; *** NEED TO COLLAPSE ; sort prison year ord fin_ord_num ; save working3.dta, replace ; collapse (sum) portion ord_adp, by(prison year ord fin_ord_num) ; drop if fin_ord_num == 0 ; drop if year == 1983 ; save ord_num.dta, replace ; rename fin_ord_num num ; rename ord_adp adp ; reshape wide portion adp ord, i(year) j(num) ; drop ord* ; order year prison portion* adp* ; egen tot_adp = rsum(adp*) ; order year prison tot_adp ; label variable portion1 "1" ; label variable portion2 "." ; label variable portion3 "3" ; label variable portion4 "." ; label variable portion5 "." ; label variable portion6 "6" ; label variable portion7 "." ; label variable portion8 "." ; label variable portion9 "9" ; label variable portion10 "." ; label variable portion11 "." ; label variable portion12 "12+" ; sort prison year ; egen portion_all = rsum(portion1-portion12) ; order year prison tot_adp portion1-portion12 portion_all ; label variable portion_all "all" ; save ordernum_adp.dta, replace ; *** ONE MONSTER GRAPH ; gen prisonyear = 0; replace prisonyear = 1 if year == 1999 ; replace prisonyear = 2 if year == 1993 ; replace prisonyear = 3 if year == 1988 ; replace prisonyear = 4 if year == 1983 ; replace prisonyear = 5 if year == 2000 ; replace prisonyear = 6 if year == 1995 ; replace prisonyear = 7 if year == 1990 ; replace prisonyear = 8 if year == 1984 ; la def prisonyear 1 "Jail, 1999" 2 "Jail, 1993" 3 "Jail, 1988" 4 "Jail, 1983" 5 "Prison, 2000" 6 "Prison, 1995" 7 "Prison, 1990" 8 "Prison, 1984" ; la val prisonyear prisonyear ; *title("Number of regulated topics" "among entities with court orders" "(weighted by incarcerated population)" ) graph bar (asis) portion1-portion12 if year > 1983, bar(1, bcolor(gs5) blc(gs3)) scheme(s1mono) ytitle ("Fraction of incarcerated population in facility with court order") ysize(10) xsize(15) ascategory ylabel(0(.2).6) by(prisonyear, legend(off) cols(4) holes(4) title ("Number of court-order topics", position(6) size(medium)) note (., size(minuscule) color(none))) ; graph save topic_histograms_adp, replace ; graph export topic_histograms_adp.emf, fontface("Times New Roman") replace; ****Need to separate it to be able to see: ; *graph bar (asis) portion1-portion12 if year > 1983 & year < 1991, ysize(20) xsize(20) ylabel(0(.05).2) bar(1, fcolor(red*.5) lcolor(red*.8)) ascategory by(prison year, legend(off) colfirst cols(2) holes(1) title("Number of regulated topics" "among entities with court orders" "weighted by incarcerated population") note (" " "Data source: Bureau of Justice Statistics Censuses")) ; *graph save topic_histograms_adp_1, replace ; *graph bar (asis) portion1-portion12 if year > 1990, ysize(20) xsize(20) ylabel(0(.05).2) bar(1, fcolor(red*.5) lcolor(red*.8)) ascategory by(prison year, legend(off) colfirst cols(2) holes(1) title("Number of regulated topics" "among entities with court orders" "weighted by incarcerated population") note (" " "Data source: Bureau of Justice Statistics Censuses")) ; *graph save topic_histograms_adp_2, replace ; *** UNWEIGHTED ; use working3.dta, clear ; replace ord_adp = 1 if ord_adp ~= . ; collapse (sum) portion_n ord_adp, by(prison year ord fin_ord_num) ; drop if fin_ord_num == 0 ; drop if year == 1983 ; rename ord_adp n ; save ord_num_n.dta, replace ; rename fin_ord_num num ; rename portion_n portion ; reshape wide portion n ord, i(year) j(num) ; drop ord* ; order year prison portion* n* ; egen tot_n = rsum(n*) ; order year prison tot_n ; label variable portion1 "1" ; label variable portion2 "." ; label variable portion3 "3" ; label variable portion4 "." ; label variable portion5 "." ; label variable portion6 "6" ; label variable portion7 "." ; label variable portion8 "." ; label variable portion9 "9" ; label variable portion10 "." ; label variable portion11 "." ; label variable portion12 "12+" ; sort prison year ; egen portion_all = rsum(portion1-portion12) ; order year prison tot_n portion1-portion12 portion_all ; label variable portion_all "all" ; save ordernum_n.dta, replace ; *** ONE MONSTER GRAPH ; gen prisonyear = 0; replace prisonyear = 1 if year == 1999 ; replace prisonyear = 2 if year == 1993 ; replace prisonyear = 3 if year == 1988 ; replace prisonyear = 4 if year == 1983 ; replace prisonyear = 5 if year == 2000 ; replace prisonyear = 6 if year == 1995 ; replace prisonyear = 7 if year == 1990 ; replace prisonyear = 8 if year == 1984 ; la def prisonyear 1 "Jail, 1999" 2 "Jail, 1993" 3 "Jail, 1988" 4 "Jail, 1983" 5 "Prison, 2000" 6 "Prison, 1995" 7 "Prison, 1990" 8 "Prison, 1984" ; la val prisonyear prisonyear ; graph bar (asis) portion1-portion12 if year > 1983, bar(1, bcolor(gs5) blc(gs3)) scheme(s1mono) ytitle ("Fraction of facilities with court order") ysize(10) xsize(15) ascategory ylabel(0(.2).6) by(prisonyear, legend(off) cols(4) holes(4) title ("Number of court-order topics", position(6) size(medium)) note (., size(minuscule) color(none))) ; graph save topic_histograms_2, replace ; graph export topic_histograms2.emf, fontface("Times New Roman") replace; *graph bar (asis) portion1-portion12 if year > 1983, ylabel(0(.2).6) bar(1, bcolor(red*.5) blc(red*.8)) ysize(10) xsize(15) ascategory yscale(alt) by(prison year, legend(off) cols(4) holes(1) title("Number of regulated topics" "among entities with court orders" ) note (" " "Data source: Bureau of Justice Statistics Censuses")) ; capture log close cd h:\articles\prison_injunctions\ log using size_effect.log, text replace set more 1 clear set memory 30m #delimit ; *** EXPLANATIONS: SIZE EFFECT ; *** TWO BIG MODELS ; use c:\temp\working1.dta, clear ; gen y1983 = 0 ; gen y1988 = 0 ; gen y1993 = 0 ; gen y1999 = 0 ; gen y1984 = 0 ; gen y1990 = 0 ; gen y1995 = 0 ; gen y2000 = 0 ; replace y1983 = 1 if year == 1983 ; replace y1988 = 1 if year == 1988 ; replace y1993 = 1 if year == 1993 ; replace y1999 = 1 if year == 1999 ; replace y1984 = 1 if year == 1984 ; replace y1990 = 1 if year == 1990 ; replace y1995 = 1 if year == 1995 ; replace y2000 = 1 if year == 2000 ; gen y1983_adp = y1983*adp ; gen y1988_adp = y1988*adp ; gen y1993_adp = y1993*adp ; gen y1999_adp = y1999*adp ; gen y1984_adp = y1984*adp ; gen y1990_adp = y1990*adp ; gen y1995_adp = y1995*adp ; gen y2000_adp = y2000*adp ; gen flag = 1 if adp == 0 ; replace adp = 1 if adp == 0 ; gen prison_ln = prison*ln(adp) ; gen jail_ln = 0 ; replace jail_ln = ln(adp) if prison == 0 ; gen y1983_ln = y1983*ln(adp) ; gen y1988_ln = y1988*ln(adp) ; gen y1993_ln = y1993*ln(adp) ; gen y1999_ln = y1999*ln(adp) ; gen y1984_ln = y1984*ln(adp) ; gen y1990_ln = y1990*ln(adp) ; gen y1995_ln = y1995*ln(adp) ; gen y2000_ln = y2000*ln(adp) ; * NORMALIZE FOR SIZE ; sort prison year ; replace adp = 0 if flag == 1 ; drop year_adp adp_adj norm ln_normed_adp ; bysort prison year: egen year_adp = sum(adp) ; sort prison id year ; drop per0_adp ; gen per0_adp = year_adp if period == 0 ; replace per0_adp = per0_adp[_n-1] if period == 1 ; replace per0_adp = per0_adp[_n-2] if period == 2 ; replace per0_adp = per0_adp[_n-3] if period == 3 ; gen adp_adj = year_adp/per0_adp ; gen norm = adp/adp_adj ; gen ln_normed_adp = ln(norm) ; label variable year_adp "Total adp by year" ; label variable per0_adp "Total adp in period 0" ; label variable adp_adj "Adp adjustment for normalizing" ; label variable norm "ADP normed to period 0" ; label variable ln_normed_adp "Ln normed adp" ; gsort +prison +year -adp ; gen norm_square = norm^2 ; gen norm_cube = norm^3 ; gen y1983_norm = y1983*norm ; gen y1988_norm = y1988*norm ; gen y1993_norm = y1993*norm ; gen y1999_norm = y1999*norm ; gen y1984_norm = y1984*norm ; gen y1990_norm = y1990*norm ; gen y1995_norm = y1995*norm ; gen y2000_norm = y2000*norm ; gen prison_norm = prison*norm ; gen jail_norm = 0 ; replace jail_norm = norm if prison == 0 ; *** LOGGED AND NORMED ; replace adp = 1 if adp == 0 ; gen prison_ln_n = prison*ln(norm) ; gen jail_ln_n = 0 ; replace jail_ln_n = ln(norm) if prison == 0 ; gen y1983_ln_n = y1983*ln(norm) ; gen y1988_ln_n = y1988*ln(norm) ; gen y1993_ln_n = y1993*ln(norm) ; gen y1999_ln_n = y1999*ln(norm) ; gen y1984_ln_n = y1984*ln(norm) ; gen y1990_ln_n = y1990*ln(norm) ; gen y1995_ln_n = y1995*ln(norm) ; gen y2000_ln_n = y2000*ln(norm) ; *** A PICTURE ; gen adp_orig = adp ; replace adp = adp/200 ; label variable adp "adp/200" ; gen adp_square = adp^2 ; gen adp_cube = adp^3 ; replace y1983_adp = y1983*adp ; replace y1988_adp = y1988*adp ; replace y1993_adp = y1993*adp ; replace y1999_adp = y1999*adp ; replace y1984_adp = y1984*adp ; replace y1990_adp = y1990*adp ; replace y1995_adp = y1995*adp ; replace y2000_adp = y2000*adp ; gen y1983_adp2 = y1983*adp_square ; gen y1988_adp2 = y1988*adp_square ; gen y1993_adp2 = y1993*adp_square ; gen y1999_adp2 = y1999*adp_square ; gen y1984_adp2 = y1984*adp_square ; gen y1990_adp2 = y1990*adp_square ; gen y1995_adp2 = y1995*adp_square ; gen y2000_adp2 = y2000*adp_square ; gen y1983_adp3 = y1983*adp_cube ; gen y1988_adp3 = y1988*adp_cube ; gen y1993_adp3 = y1993*adp_cube ; gen y1999_adp3 = y1999*adp_cube ; gen y1984_adp3 = y1984*adp_cube ; gen y1990_adp3 = y1990*adp_cube ; gen y1995_adp3 = y1995*adp_cube ; gen y2000_adp3 = y2000*adp_cube ; gen y1983_adp4 = y1983*adp^4 ; gen y1988_adp4 = y1988*adp^4; gen y1993_adp4 = y1993*adp^4 ; gen y1999_adp4 = y1999*adp^4 ; gen y1984_adp4 = y1984*adp^4 ; gen y1990_adp4 = y1990*adp^4 ; gen y1995_adp4 = y1995*adp^4 ; gen y2000_adp4 = y2000*adp^4 ; save c:\temp\working3.dta, replace ; *** JAILS *** LARGE ONLY. ; use c:\temp\working3.dta, clear ; drop if prison == 1 ; drop if ordsm == -9 ; drop if adp_orig < 1000 ; logistic ord y1983_adp y1988_adp y1993_adp y1999_adp y1983_adp2 y1988_adp2 y1993_adp2 y1999_adp2 y1983_adp3 y1988_adp3 y1993_adp3 y1999_adp3 ; test (y1983_adp + y1983_adp2 + y1983_adp3 = y1988_adp + y1988_adp2 + y1988_adp3 ) ; test (y1988_adp + y1988_adp2 + y1988_adp3 = y1993_adp + y1993_adp2 + y1993_adp3 ) ; test (y1993_adp + y1993_adp2 + y1993_adp3 = y1999_adp + y1999_adp2 + y1999_adp3 ) ; predict fitted1999adp if year == 1999 ; predict fitted1993adp if year == 1993 ; predict fitted1988adp if year == 1988 ; predict fitted1983adp if year == 1983 ; gen adp_graph = adp_orig ; label variable adp_graph "Facility population" ; line fitted1999adp adp_graph if year == 1999, scheme(s2mono)|| line fitted1993adp adp_graph if year == 1993|| line fitted1988adp adp_graph if year == 1988|| line fitted1983adp adp_graph if year == 1983, title("Size effect in jails") ytitle("Estimated Order Probability") legend(order(1 "1999" 2 "1993" 3 "1988" 4 "1983")) ; graph save large_adp_and_orders_jail.gph, replace ; *** ALL ; use c:\temp\working3.dta, clear ; drop if ordsm == -9 ; drop if prison == 1 ; *** NOTE, ALL ARE IN FOR ESTIMATION, BUT NOT FOR PICTURE ; *drop if adp_orig > 3000 ; *by prison year: egen adp_pile = pctile(adp_orig), p(99.5) ; *drop if adp_orig >= adp_pile ; logistic ord y1983_adp y1988_adp y1993_adp y1999_adp y1983_adp2 y1988_adp2 y1993_adp2 y1999_adp2 y1983_adp3 y1988_adp3 y1993_adp3 y1999_adp3 ; test (y1983_adp + y1983_adp2 + y1983_adp3 = y1988_adp + y1988_adp2 + y1988_adp3 ) ; test (y1988_adp + y1988_adp2 + y1988_adp3 = y1993_adp + y1993_adp2 + y1993_adp3 ) ; test (y1993_adp + y1993_adp2 + y1993_adp3 = y1999_adp + y1999_adp2 + y1999_adp3 ) ; predict fitted1999adp if year == 1999 ; predict fitted1993adp if year == 1993 ; predict fitted1988adp if year == 1988 ; predict fitted1983adp if year == 1983 ; gen adp_graph = adp_orig ; label variable adp_graph "Facility population" ; *drop if adp_orig > 3000 ; line fitted1999adp adp_graph if year == 1999, scheme(s1mono)|| line fitted1993adp adp_graph if year == 1993, lpattern(dash)|| line fitted1988adp adp_graph if year == 1988, lpattern(longdash)|| line fitted1983adp adp_graph if year == 1983, lpattern(dash_dot) title("Size effect in jails") ytitle("Estimated Order Probability") legend(order(4 "1983" 2 "1993" 3 "1988" 1 "1999")) xscale(log) xlabel(50 200 500 1000 3000 10000 "10,000") xsize(8) ; graph save adp_and_orders_jail.gph, replace ; *** Create a datafile that's just for the one picture of jails and prisons together ; drop if year ~= 1993 ; save c:\temp\1993.dta, replace ; *** CHECK ON THE FOURTH ORDER EXPONENTIATION ; use c:\temp\working3.dta, clear ; drop if ordsm == -9 ; drop if prison == 1 ; logistic ord y1983_adp y1988_adp y1993_adp y1999_adp y1983_adp2 y1988_adp2 y1993_adp2 y1999_adp2 y1983_adp3 y1988_adp3 y1993_adp3 y1999_adp3 y1983_adp4 y1988_adp4 y1993_adp4 y1999_adp4 ; predict fitted1999adp if year == 1999 ; predict fitted1993adp if year == 1993 ; predict fitted1988adp if year == 1988 ; predict fitted1983adp if year == 1983 ; gen adp_graph = adp_orig ; label variable adp_graph "Facility population" ; *drop if adp_orig > 3000 ; line fitted1999adp adp_graph if year == 1999, scheme(s2mono)|| line fitted1993adp adp_graph if year == 1993|| line fitted1988adp adp_graph if year == 1988|| line fitted1983adp adp_graph if year == 1983, title("Size effect in jails") ytitle("Estimated Order Probability") legend(order(4 "1983" 2 "1993" 3 "1988" 1 "1999")) xscale(log) xlabel(50 200 500 1000 3000 10000 "10,000") xsize(8) ; *** IT'S THE SAME PICTURE. ; *** CONTROL FOR YEAR FIXED EFFECTS ; *** CHECK THAT THIS MAKES SENSE ; use c:\temp\working3.dta, clear ; drop if ordsm == -9 ; drop if prison == 1 ; *** NOTE, ALL ARE IN FOR ESTIMATION BUT NOT FOR PICTURE ; *drop if adp_orig > 3000 ; *by prison year: egen adp_pile = pctile(adp_orig), p(99.5) ; *drop if adp_orig >= adp_pile ; logistic ord y1988 y1993 y1999 y1983_adp y1988_adp y1993_adp y1999_adp y1983_adp2 y1988_adp2 y1993_adp2 y1999_adp2 y1983_adp3 y1988_adp3 y1993_adp3 y1999_adp3 ; test (y1983_adp + y1983_adp2 + y1983_adp3 = y1988_adp + y1988_adp2 + y1988_adp3 ) ; test (y1988_adp + y1988_adp2 + y1988_adp3 = y1993_adp + y1993_adp2 + y1993_adp3 ) ; test (y1993_adp + y1993_adp2 + y1993_adp3 = y1999_adp + y1999_adp2 + y1999_adp3 ) ; predict fitted1999adp if year == 1999 ; predict fitted1993adp if year == 1993 ; predict fitted1988adp if year == 1988 ; predict fitted1983adp if year == 1983 ; gen adp_graph = adp_orig ; label variable adp_graph "Facility population" ; *drop if adp_orig > 3000 ; line fitted1999adp adp_graph if year == 1999, scheme(s2mono)|| line fitted1993adp adp_graph if year == 1993|| line fitted1988adp adp_graph if year == 1988|| line fitted1983adp adp_graph if year == 1983, title("Size effect in jails") ytitle("Estimated Order Probability") legend(order(4 "1983" 2 "1993" 3 "1988" 1 "1999")) xscale(log) xlabel(50 200 500 1000 3000 10000 "10,000") xsize(8) ; graph save adp_and_orders_jail_year_fixed.gph, replace ; *** PRISONS ; use c:\temp\working3.dta, clear ; drop if ordsm == -9 ; drop if prison == 0 ; logistic ord y1984_adp y1990_adp y1995_adp y2000_adp y1984_adp2 y1990_adp2 y1995_adp2 y2000_adp2 y1984_adp3 y1990_adp3 y1995_adp3 y2000_adp3 ; test (y1984_adp + y1984_adp2 + y1984_adp3 = y1990_adp + y1990_adp2 + y1990_adp3 ) ; test (y1995_adp + y1995_adp2 + y1995_adp3 = y1990_adp + y1990_adp2 + y1990_adp3 ) ; test (y1995_adp + y1995_adp2 + y1995_adp3 = y2000_adp + y2000_adp2 + y2000_adp3 ) ; predict fitted2000adp if year == 2000 ; predict fitted1995adp if year == 1995 ; predict fitted1990adp if year == 1990 ; predict fitted1984adp if year == 1984 ; *drop if adp_orig > 3000 ; gen adp_graph = adp_orig ; label variable adp_graph "Facility population" ; line fitted2000adp adp_graph if year == 2000, scheme(s1mono)|| line fitted1995adp adp_graph if year == 1995, lpattern(dash)|| line fitted1990adp adp_graph if year == 1990, lpattern(longdash)|| line fitted1984adp adp_graph if year == 1984, lpattern(dash_dot) title("Size effect in prisons") ytitle("Estimated Order Probability") legend(order(4 "1984" 2 "1995" 3 "1990" 1 "2000")) xscale(log) xlabel(50 200 500 1000 3000 10000 "10,000") xsize(8) ; graph save adp_and_orders_prison.gph, replace ; save c:\temp\prison_size_estimations.dta, replace ; *** Create a datafile that's just for the one picture of jails and prisons together ; drop if year ~= 1995 ; append using c:\temp\1993.dta ; save c:\temp\1993-1995.dta, replace ; *title("Estimated probability of order, given facility size") *note("Source: Data from Bureau of Justice Statistics") *note( ., size(minuscule) color(none)); twoway (line fitted1995adp adp_graph if year == 1995, lcolor(black) lpattern(solid) ) (line fitted1993adp adp_graph if year == 1993, lcolor(black) lpattern(dash)), legend(order(1 "prisons in 1995" 2 "jails in 1993")) ytitle("Estimated Order Probability") ylabel(0(.2)1, grid) xscale(log) xlabel(50 200 500 1000 3000 10000 "10,000") xsize(8) scheme(s1mono) ; graph save size_in_jail_and_prison.gph, replace ; graph export size_in_jail_and_prison.emf, fontface("Times New Roman") replace; *** CONTROL FOR YEAR FIXED EFFECTS ; *** CHECK THAT THIS MAKES SENSE ; use c:\temp\prison_size_estimations.dta, clear ; logistic ord y1990 y1995 y2000 y1984_adp y1990_adp y1995_adp y2000_adp y1984_adp2 y1990_adp2 y1995_adp2 y2000_adp2 y1984_adp3 y1990_adp3 y1995_adp3 y2000_adp3 ; test (y1984_adp + y1984_adp2 + y1984_adp3 = y1990_adp + y1990_adp2 + y1990_adp3 ) ; test (y1995_adp + y1995_adp2 + y1995_adp3 = y1990_adp + y1990_adp2 + y1990_adp3 ) ; test (y1995_adp + y1995_adp2 + y1995_adp3 = y2000_adp + y2000_adp2 + y2000_adp3 ) ; drop fitted* ; predict fitted2000adp if year == 2000 ; predict fitted1995adp if year == 1995 ; predict fitted1990adp if year == 1990 ; predict fitted1984adp if year == 1984 ; line fitted2000adp adp_graph if year == 2000, scheme(s2mono)|| line fitted1995adp adp_graph if year == 1995|| line fitted1990adp adp_graph if year == 1990|| line fitted1984adp adp_graph if year == 1984, title("Size effect in prisons") ytitle("Estimated Order Probability") legend(order(4 "1984" 2 "1995" 3 "1990" 1 "2000")) xscale(log) xlabel(50 200 500 1000 3000 10000 "10,000") xsize(8) ; graph save adp_and_orders_prison_year_fixed.gph, replace ; *** RUN WITHOUT NY & OHIO & TENN ; use c:\temp\working3.dta, clear ; drop if ordsm == -9 ; drop if (state == 36 | state == 33| state == 43) ; logistic ord y1984_adp y1990_adp y1995_adp y2000_adp y1984_adp2 y1990_adp2 y1995_adp2 y2000_adp2 y1984_adp3 y1990_adp3 y1995_adp3 y2000_adp3 ; test (y1984_adp + y1984_adp2 + y1984_adp3 = y1990_adp + y1990_adp2 + y1990_adp3 ) ; test (y1995_adp + y1995_adp2 + y1995_adp3 = y1990_adp + y1990_adp2 + y1990_adp3 ) ; test (y1995_adp + y1995_adp2 + y1995_adp3 = y2000_adp + y2000_adp2 + y2000_adp3 ) ; predict fitted2000adp_0 if year == 2000 ; predict fitted1995adp_0 if year == 1995 ; predict fitted1990adp_0 if year == 1990 ; predict fitted1984adp_0 if year == 1984 ; *drop if adp_orig > 3000 ; gen adp_graph = adp_orig ; line fitted2000adp adp_graph if year == 2000, scheme(s2mono)|| line fitted1995adp adp_graph if year == 1995|| line fitted1990adp adp_graph if year == 1990|| line fitted1984adp adp_graph if year == 1984, title("Size effect in prisons" "without NY, Ohio, or Tenn.") ytitle("Estimated Order Probability") legend(order(4 "1984" 2 "1995" 3 "1990" 1 "2000")) xscale(log) xlabel(50 200 500 1000 3000 10000 "10,000") xsize(8) ; graph save adp_and_orders_prison_xNYOhioTenn.gph, replace ; *** IT'S NOT A NY/OHIO EFFECT ; ***COMBINE THEM. ; graph combine adp_and_orders_jail.gph adp_and_orders_prison.gph, cols(1) ycommon xcommon xsize(10) ysize(14) ; graph save adp_and_orders.gph, replace ; graph combine adp_and_orders_jail_year_fixed.gph adp_and_orders_prison_year_fixed.gph, cols(1) ycommon xcommon xsize(10) ysize(14) ; graph save adp_and_orders_year_fixed.gph, replace ; *** OR NORMED PICTURE ; use c:\temp\working3.dta, clear ; drop if ordsm == -9 ; gen adp_orig_200 = adp ; replace adp = norm/200 ; label variable adp "normed adp/200" ; replace adp_square = adp^2 ; replace adp_cube = adp^3 ; replace y1983_adp = y1983*adp ; replace y1988_adp = y1988*adp ; replace y1993_adp = y1993*adp ; replace y1999_adp = y1999*adp ; replace y1984_adp = y1984*adp ; replace y1990_adp = y1990*adp ; replace y1995_adp = y1995*adp ; replace y2000_adp = y2000*adp ; replace y1983_adp2 = y1983*adp_square ; replace y1988_adp2 = y1988*adp_square ; replace y1993_adp2 = y1993*adp_square ; replace y1999_adp2 = y1999*adp_square ; replace y1984_adp2 = y1984*adp_square ; replace y1990_adp2 = y1990*adp_square ; replace y1995_adp2 = y1995*adp_square ; replace y2000_adp2 = y2000*adp_square ; replace y1983_adp3 = y1983*adp_cube ; replace y1988_adp3 = y1988*adp_cube ; replace y1993_adp3 = y1993*adp_cube ; replace y1999_adp3 = y1999*adp_cube ; replace y1984_adp3 = y1984*adp_cube ; replace y1990_adp3 = y1990*adp_cube ; replace y1995_adp3 = y1995*adp_cube ; replace y2000_adp3 = y2000*adp_cube ; save c:\temp\working4.dta, replace ; drop if prison == 1 ; logistic ord y1983_adp y1988_adp y1993_adp y1999_adp y1983_adp2 y1988_adp2 y1993_adp2 y1999_adp2 y1983_adp3 y1988_adp3 y1993_adp3 y1999_adp3 ; test (y1983_adp + y1983_adp2 + y1983_adp3 = y1988_adp + y1988_adp2 + y1988_adp3 ) ; test (y1988_adp + y1988_adp2 + y1988_adp3 = y1993_adp + y1993_adp2 + y1993_adp3 ) ; test (y1993_adp + y1993_adp2 + y1993_adp3 = y1999_adp + y1999_adp2 + y1999_adp3 ) ; predict fitted1999adp if year == 1999 ; predict fitted1993adp if year == 1993 ; predict fitted1988adp if year == 1988 ; predict fitted1983adp if year == 1983 ; gen adpn_graph = norm ; label variable adpn_graph "Facility Population" ; *drop if adp_orig > 3000 ; line fitted1999adp adpn_graph if year == 1999, scheme(s2mono)|| line fitted1993adp adpn_graph if year == 1993|| line fitted1988adp adpn_graph if year == 1988|| line fitted1983adp adpn_graph if year == 1983, title("Size effect in jails") ytitle("Estimated Order Probability") legend(order(4 "1983" 2 "1993" 3 "1988" 1 "1999")) xsize(8) ; *xlabel(50 200 500 1000 3000 10000 "10,000") ; *xscale(log) ; graph save adp_and_orders_jail_norm.gph, replace ; use c:\temp\working4.dta, clear ; drop if prison == 0 ; logistic ord y1984_adp y1990_adp y1995_adp y2000_adp y1984_adp2 y1990_adp2 y1995_adp2 y2000_adp2 y1984_adp3 y1990_adp3 y1995_adp3 y2000_adp3 ; test (y1984_adp + y1984_adp2 + y1984_adp3 = y1990_adp + y1990_adp2 + y1990_adp3 ) ; test (y1995_adp + y1995_adp2 + y1995_adp3 = y1990_adp + y1990_adp2 + y1990_adp3 ) ; test (y1995_adp + y1995_adp2 + y1995_adp3 = y2000_adp + y2000_adp2 + y2000_adp3 ) ; predict fitted2000adp if year == 2000 ; predict fitted1995adp if year == 1995 ; predict fitted1990adp if year == 1990 ; predict fitted1984adp if year == 1984 ; *drop if adp_orig > 3000 ; gen adpn_graph = norm ; label variable adpn_graph "Facility Population" ; * Something is wrong with below and log scale, so I dont use it ; * FIGURE THIS OUT ; line fitted2000adp adpn_graph if year == 2000, scheme(s2mono)|| line fitted1995adp adpn_graph if year == 1995|| line fitted1990adp adpn_graph if year == 1990|| line fitted1984adp adpn_graph if year == 1984, title("Size effect in prisons") ytitle("Estimated Order Probability") legend(order(4 "1984" 2 "1995" 3 "1990" 1 "2000")) xlabel(50 200 500 1000 3000 10000 "10,000") xsize(8) ; *xscale(log) ; graph save adp_and_orders_prison_norm.gph, replace ; ***COMBINE THEM. ; graph combine adp_and_orders_jail_norm.gph adp_and_orders_prison_norm.gph, cols(1) ycommon xcommon xsize(10) ysize(14) ; graph save adp_and_orders_normalized.gph, replace ; capture log close