Spatial analysis (using STATA)

Tobler (1970: 236): "I invoke the first law of geography: everything is related to everything else, but near things are more related than distant things."

Spatial Analysis has been used widely by political scientists in different sub-fields for answering a wide variety of questions. Social scientists including political scientists employ spatial analysis in their analysis to either study/evaluate the spillover of a political outcome/mechanism from a neighboring country (Salehyan & Gleditsch 2006; Braithwaite, 2006), or control the spatial correlation and its adverse effect on the estimations of regression models. Below, I briefly discuss how to use STATA to present your spatial data and conduct spatial analysis. This note is in-progress; so if you found any errors, or you had any comments or suggestions, please email me srezaeed@ASU.edu.

The data that I discuss below is a simplified version of the data used in "Food Price Volatility and Rebel Violence in Africa" (RezaeeDaryakenari, Landis, and Thies forthcomin)

The topics discussed in this note are as follow:

  • Visual presentation of spatial data
  • Calculating W matrix
  • Testing Spatial Correlation using Moran’s I
  • Spatially weighted variables: Spatially Lagged Dependent Variable (SLDV)
In [9]:
## Loading stata kernel in jupyter notebook, using python code. IGNORE this part if you are using STATA.
import ipystata
from ipystata.config import config_stata
config_stata('C:\Program Files (x86)\Stata14\StataSE-64.exe') 

from IPython.display import display, HTML

display(HTML(data="""
<style>
    div#notebook-container    { width: 95%; }
    div#menubar-container     { width: 65%; }
    div#maintoolbar-container { width: 99%; }
</style>
"""))

First, install follwoing STATA user-written packages:

In [10]:
%%stata
ssc install geoinpoly, replace
ssc install sppack, replace
ssc install  spwmatrix, replace
ssc install splagvar, replace
*install spatgsa using findit spatgsa
checking geoinpoly consistency and verifying not already installed...
all files already exist and are up to date.

checking sppack consistency and verifying not already installed...
all files already exist and are up to date.

checking spwmatrix consistency and verifying not already installed...
all files already exist and are up to date.

checking splagvar consistency and verifying not already installed...
all files already exist and are up to date.

Second, download required datasets from here

Then, set the wordking directory and some options to get (visually) cleaner results.

In [27]:
%%stata 

* Set your working directory
qui cd "C:\Users\Babak-Lenovo2017\Dropbox\ASU-Babak\PoliSci\POS 604\Babak_CMPS"
clear
set cformat %5.4f
set pformat %5.3f
set more off

Assume that we want to study how civilian victimization/ violence against civilians are affected by the variations in food price, as is explored in RezaeeDaryakenari et al. (2018). I start with loading and preparing the data for the dependent variable, i.e. civilian victimzation by rebel groups/non-state actors from The Armed Conflict Location & Event Data Project (ACLED) dataset.

In [12]:
%%stata

***Open tha ACLED's raw data: ACLED Version 6 All Africa 1997-2015_csv_monadic.csv 

import delimited "ACLED Version 6 All Africa 1997-2015_csv_dyadic.csv", clear

**limiting data to violence aganist civilians by non-state actors
keep if event_typ=="Violence against civilians"
keep if inter1==2 | inter1==3 | inter1==4

** Get year, month, and day from the event_date field
split event_date, p(/)
gen Day=real(event_date1)
gen Month=real(event_date2)
gen Year=real(event_date3)

** Most packages use y and x for the geographic coordinates, so I rename latitude and longitude
rename latitude y
rename longitude x

save "ACLED_ViolenceCivilians.dta" , replace
(25 vars, 119,885 obs)

(86,492 observations deleted)

(10,618 observations deleted)

variables created as string: 
event_date1  event_date2  event_date3

(note: file ACLED_ViolenceCivilians.dta not found)
file ACLED_ViolenceCivilians.dta saved

Visual presentation of spatial data

I want to present spatial/geographic distribution of civilian victimization. To do so, I need a map.

I load a shape file of Africa at 1st adminstration level to STATA and change its format from shape to STATA .dta.

The command that does this for us is shp2dta, as follow:

In [28]:
%%stata

shp2dta using "Africa_admin1", ///
 database(AfricaAdmin) coordinates(coor) genid(id) gencentroids(centroid) replace

use AfricaAdmin, clear
* describe
type: 5

In [18]:
%%stata
spmap using coor.dta, id(id) fcolor(gold) ocolor(maroon) osize(thin)
graph export GoMaroonNGold.pdf, replace
(file GoMaroonNGold.pdf written in PDF format)

In [19]:
 %%stata
format Cultivated %5.1f
spmap  Cultivated using coor, id(id)  fcolor(BuRd) ///
 ocolor(black ..) osize(thin ..) legend(position(2)) ///
 legtitle("Cultivated lands %")  clmethod(quantile)
In [20]:
 %%stata
spmap  Cultivated using coor, id(id)  fcolor(BuRd) ///
 ocolor(black ..) osize(thin ..) legend(position(2)) ///
 legtitle("Cultivated lands %")  clmethod(quantile)  ///
   label( xcoord(x_centroid)     ///
    ycoord(y_centroid) label(HASC_1) color(black) size(*0.3))
 

Now, I want to show the locations that rebels attacked/targeted civilians on our map. You can use point as an option to load any geo-coded event and add it to your base map.

In [21]:
%%stata

spmap using "coor.dta", id(id) ///
 fcolor(gold) ocolor(black) osize(thin) ///
 point(data("ACLED_ViolenceCivilians.dta") x(x) y(y) ///
 size(*0.8) fcolor(maroon) ocolor(white) osize(vvthin)) ///
title("Civilian Victimization by non-State Actors 1997-2015") ///
subtitle("ACLED Dataset")
 
In [22]:
%%stata

** Specific year

** limit to year 2000 (as an example)
qui use "ACLED_ViolenceCivilians.dta", clear
qui keep if Year==2000

qui save  "ACLED_ViolenceCivilians_2000.dta", replace

use AfricaAdmin, clear
spmap using "coor.dta", id(id) ///
 fcolor(gs12) ocolor(white) osize(thin)  ///
 point(data("ACLED_ViolenceCivilians_2000.dta") x(x) y(y) ///
 size(*0.8) fcolor(black) ocolor(red) osize(vvthin)) ///
title("Civilian Victimization by non-State Actors in 2000")
In [23]:
%%stata
spmap Cultivated using "coor.dta", id(id) ///
 fcolor(Blues) ocolor(black) osize(thin) clmethod(quantile)  ///
 point(data("ACLED_ViolenceCivilians.dta") x(x) y(y) ///
 size(0.8) fcolor(gold) ocolor(maroon) ///
 osize(vvthin))  legend(position(8))  ///
legtitle("Cultivated lands %") 

graph export RezaeeEtAl2018.pdf, replace
(file RezaeeEtAl2018.pdf written in PDF format)

Preparing the data

We need to disaggregate the data to years, then aggregate the civilian vitimizations (our dependent variable) to first adminstration level

Spatial joint preparation

In [ ]:
%%stata

forvalues i=1997(1)2015 {
    qui use "ACLED_ViolenceCivilians.dta" , clear
    qui keep if Year==`i'
    qui save ACLED_ViolenceCivilians_`i'.dta, replace
    display as text "year " `i' ": done"
}

I want to mark each conflict event in year t with its administration ID based on coor.dta file that I made using shp2dta

In [ ]:
%%stata

use ACLED_ViolenceCivilians_1997.dta, clear
      
* Match the points to census tract polygons
geoinpoly  y x using "coor.dta"  
  
collapse (count) inter1, by(_ID Year)

rename inter1 Violence_count

label var Violence_count "Violence (count)"

save "ACLED_ViolenceCivilians_1997_count.dta", replace


forvalues i=1997(1)2015 {
    use ACLED_ViolenceCivilians_`i'.dta, clear
    geoinpoly  y x using "coor.dta"  
    collapse (count) inter1, by(_ID Year)
    rename inter1 Violence_count
    label var Violence_count "Violence (count)"
    save "ACLED_ViolenceCivilians_`i'_count.dta", replace
    rm "ACLED_ViolenceCivilians_`i'.dta" 
    display as text " year " `i' ": done"
}

use "ACLED_ViolenceCivilians_1997_count.dta", clear

forvalues i=1998(1)2015 {
    append using "ACLED_ViolenceCivilians_`i'_count.dta"
    rm "ACLED_ViolenceCivilians_`i'_count.dta"
}
rename _ID id
save "ACLED_ViolenceCivilians_count.dta", replace

Now, we need to merge all data sets.

In [ ]:
***Base data
use AfricaAdmin, clear

* Changing upper-case names to lower-case names

foreach v of varlist _all {
    capture rename `v' `=lower("`v'")'
 }

gen Year=1997

replace Year=2015 if objectid==65 

xtset objectid Year

tsfill, full

xtset objectid Year

 
forvalues i=-50(1)50 {
    replace iso=iso[_n+`i'] if objectid[_n]==objectid[_n+`i'] & iso==""
    replace name_0=name_0[_n+`i'] if objectid[_n]==objectid[_n+`i'] & name_0==""
    replace type_1=type_1[_n+`i'] if objectid[_n]==objectid[_n+`i'] & type_1==""
    replace engtype_1=engtype_1[_n+`i'] if objectid[_n]==objectid[_n+`i'] & engtype_1==""
    replace iso_2=iso_2[_n+`i'] if objectid[_n]==objectid[_n+`i'] & iso_2==""
    replace cultivated=cultivated[_n+`i'] if objectid[_n]==objectid[_n+`i'] & cultivated==.
    replace area=area[_n+`i'] if objectid[_n]==objectid[_n+`i'] & area==.
    replace x_centroid=x_centroid[_n+`i'] if objectid[_n]==objectid[_n+`i'] & x_centroid==.
    replace y_centroid=y_centroid[_n+`i'] if objectid[_n]==objectid[_n+`i'] & y_centroid==.
    replace id=id[_n+`i'] if objectid[_n]==objectid[_n+`i'] & id==.
}

***Now merge the prepared datasets with main dataset

*Violence aganst civilian data (This data comes from ACLED, but I aggregated it by month to 1st admin level)
joinby id Year using "ACLED_ViolenceCivilians_count.dta", unmatched(master)
drop _merge
replace Violence_count=0 if Violence_count==.

** Nightlight data
joinby objectid Year using "Africa_admin1_Nightlight.dta", unmatched(master)

drop _merge

** Population data
joinby objectid Year using "Africa_admin1_Population.dta", unmatched(master)

drop _merge

by objectid: ipolate Population_mean Year, gen(Population_mean_ipolate)

** Road denisty
joinby objectid using "Africa_admin1_RoadDensity.dta", unmatched(master)

drop _merge

joinby objectid using "Africa_admin1_Diamond.dta", unmatched(master)

drop _merge


joinby objectid using "Africa_admin1_InfantMR.dta", unmatched(master)

drop _merge


joinby objectid using "Africa_admin1_MineralSources.dta", unmatched(master)

drop _merge

joinby objectid using "Africa_admin1_Petroleum.dta", unmatched(master)

drop _merge

replace Petroleum=0 if Petroleum==.


** Local Foof price

joinby objectid Year using "RCK2015_Price_yearly.dta", unmatched(master)

drop _merge


xtset objectid Year

gen Violence_count_1=l.Violence_count

save "MainDataAllMerged.dta", replace

Calculating W matrix

In [ ]:
%%stata
use "MainDataAllMerged.dta", clear
set matsize 1000
spwmatrix gecon x_centroid y_centroid if Year==1997, wname(W) wtype(inv) cart row
  • Wname() specifies the name of the spatial weights matrix to be generated. This option is required.
  • wtype(bin|inv|econ|invecon|socnet|socecon) indicates whether binary, distance decay, economic distance, inverse economic distance, social network, or socio-economic spatial weights should be created.
  • row: row-standardize the spatial weights matrix{p_end}

Testing Spatial Correlation using Moran’s I

$$\mathcal{I}=\frac{n \sum_i \sum_{j\neq i} w_{ij}(y_i-\bar{y})(y_j-\bar{y})}{(\sum_i \sum_{j \neq i} w_{ij}) \sum_i (y_i-\bar{y})^2}$$

In [ ]:
%%stata
keep if Year==1997
spatgsa Violence_count, weights(W) moran

Based on these results, we can reject the null hypothesis that there is zero spatial autocorrelation present in the variable Violence if p_value< alpha = .05 (or, 1%, 10%).

Spatially weighted variables: Spatially Lagged Dependent Variable (SLDV)

$$ y_i=\textbf{x}_i \beta +\epsilon_i $$

$$ \epsilon_i=\phi \textbf{w}_i y_{-i}+u_i $$

$$ y_i=\textbf{x}_i \beta +\textbf{w}_i y_{-i}+u_i $$

In [ ]:
use "MainDataAllMerged.dta", clear
keep if Year==1997
quietly splagvar Violence_count, wname(W) wfrom(Stata) moran(Violence_count) 
save "MainDataAllMergedWeight_1997_1.dta", replace


************************************** NOTE: it takes about 26 minutes to calculate these spatially weighted variables **************** You may skip to the point NEXT
timer on 1
forvalues i=1997(1)2015 {
    use "MainDataAllMerged.dta", clear
    keep if Year==`i'
    quietly splagvar Violence_count, wname(W) wfrom(Stata) moran(Violence_count) 
    capture noisily splagvar Violence_count_1 , wname(W) wfrom(Stata) moran(Violence_count_1)
    save "MainDataAllMergedWeight_`i'.dta", replace
    display as text "year " `i' ": done"
}

timer off 1
timer list 1

* Append all and start estimations

use "MainDataAllMergedWeight_1997.dta", clear
rm "MainDataAllMergedWeight_1997.dta"

forvalues i=1998(1)2015 {
    append using "MainDataAllMergedWeight_`i'.dta"
    rm "MainDataAllMergedWeight_`i'.dta"
}

save "MainDataAllMergedWeight.dta", replace

Using data to merge the remaining data sets

In [31]:
%%stata
use "MainDataAllMergedWeight.dta", clear

*** Retrieve ccode using country name
rename name_0 country
qui do CountryToCcode

***

qui xtset objectid Year
joinby ccode Year using "p4v2015.dta", unmatched(master)

drop _merge

joinby objectid using "Africa_admin1_GrowingSeason.dta", unmatched(master)

drop _merge


****
qui gen comm1_log=log(comm1)
qui gen comm1_log_1=l.comm1_log

qui replace cultivated=cultivated/100
qui xtile cultivated_quart = cultivated, nq(4)


qui gen Violence_dum=0
qui replace Violence_dum=1 if Violence_count>0

qui replace area=area/1000000


label variable Violence_dum "Violence(dummy)"
label variable Violence_count "Violence"
label variable wy_Violence_count_1 "Spatially weighted lag violence"
label variable polity2 "Polity"
label variable Nightlight_mean "Stable nightlight"
label variable RoadDensity_mean "Road density"
label variable Diamond "Diamond mines"
label variable InfantMortality_mean "Infant mortality"
label variable Mineral "Mineral mines"
label variable Petroleum "Petroleum fields"
label variable Population_mean_ipolate "Population"
label variable area "District size"
label variable cultivated "Cultivated land"
label variable comm1_log "Local food price"

Estimating regression models

In [7]:
%%stata
eststo clear

qui eststo: logit Violence_dum Violence_count_1 wy_Violence_count_1 c.comm1_log_1 ///
polity2 c.polity2#c.polity2 Nightlight_mean RoadDensity_mean Diamond InfantMortality_mean Mineral Petroleum Population_mean_ipolate area, r cluster(objectid)
qui eststo: logit Violence_dum Violence_count_1 c.comm1_log_1 ///
polity2 c.polity2#c.polity2 Nightlight_mean RoadDensity_mean Diamond InfantMortality_mean Mineral Petroleum Population_mean_ipolate area, r cluster(objectid)


qui eststo: logit Violence_dum Violence_count_1 wy_Violence_count_1 c.cultivated##c.comm1_log_1 ///
polity2 c.polity2#c.polity2 Nightlight_mean RoadDensity_mean Diamond InfantMortality_mean Mineral Petroleum Population_mean_ipolate area, r cluster(objectid)
qui eststo: logit Violence_dum Violence_count_1 c.cultivated##c.comm1_log_1 ///
polity2 c.polity2#c.polity2 Nightlight_mean RoadDensity_mean Diamond InfantMortality_mean Mineral Petroleum Population_mean_ipolate area, r cluster(objectid)


qui eststo: logit Violence_dum Violence_count_1 wy_Violence_count_1 c.comm1_log_1##cultivated_quart ///
polity2 c.polity2#c.polity2 Nightlight_mean RoadDensity_mean Diamond InfantMortality_mean Mineral Petroleum Population_mean_ipolate area, r cluster(objectid)
qui eststo: logit Violence_dum Violence_count_1 c.comm1_log_1##cultivated_quart ///
polity2 c.polity2#c.polity2 Nightlight_mean RoadDensity_mean Diamond InfantMortality_mean Mineral Petroleum Population_mean_ipolate area, r cluster(objectid)


esttab,  s(N aic bic) 
esttab using Table1.csv,  s(N aic bic) replace


**poisson vs nbreg

poisson Violence_count Violence_count_1 wy_Violence_count_1 c.comm1_log_1 ///
polity2 c.polity2#c.polity2 Nightlight_mean RoadDensity_mean Diamond InfantMortality_mean Mineral Petroleum Population_mean_ipolate area

estat gof 
Form STATA:
***The extreme significance of the goodness-of-fit chi-2 indicates that the Poisson regression model is 
*inappropriate, suggesting to us that we should try a negative binomial model:

nbreg Violence_count Violence_count_1 wy_Violence_count_1 c.comm1_log_1 ///
polity2 c.polity2#c.polity2 Nightlight_mean RoadDensity_mean Diamond InfantMortality_mean Mineral Petroleum Population_mean_ipolate area

*\alpha is significantly different from 0, so the process being Poisson is rejected.


eststo clear

qui eststo:  menbreg Violence_count Violence_count_1 c.comm1_log_1 ///
polity2 c.polity2#c.polity2 Nightlight_mean RoadDensity_mean Diamond InfantMortality_mean Mineral Petroleum Population_mean_ipolate area || objectid:, vce(cluster objectid)
qui eststo:  menbreg Violence_count Violence_count_1 wy_Violence_count_1 c.comm1_log_1 ///
polity2 c.polity2#c.polity2 Nightlight_mean RoadDensity_mean Diamond InfantMortality_mean Mineral Petroleum Population_mean_ipolate area || objectid:, vce(cluster objectid)


qui eststo:  menbreg Violence_count Violence_count_1 c.cultivated##c.comm1_log_1  ///
polity2 c.polity2#c.polity2 Nightlight_mean RoadDensity_mean Diamond InfantMortality_mean Mineral Petroleum Population_mean_ipolate area || objectid:, vce(cluster objectid)
qui eststo:  menbreg Violence_count Violence_count_1 wy_Violence_count_1 c.cultivated##c.comm1_log_1 ///
polity2 c.polity2#c.polity2 Nightlight_mean RoadDensity_mean Diamond InfantMortality_mean Mineral Petroleum Population_mean_ipolate area || objectid:, vce(cluster objectid)



qui eststo:  menbreg Violence_count Violence_count_1 c.comm1_log_1##cultivated_quart  ///
polity2 c.polity2#c.polity2 Nightlight_mean RoadDensity_mean Diamond InfantMortality_mean Mineral Petroleum Population_mean_ipolate area || objectid:, vce(cluster objectid)
qui eststo:  menbreg Violence_count Violence_count_1 wy_Violence_count_1 c.comm1_log_1##cultivated_quart ///
polity2 c.polity2#c.polity2 Nightlight_mean RoadDensity_mean Diamond InfantMortality_mean Mineral Petroleum Population_mean_ipolate area || objectid:, vce(cluster objectid)


esttab,  s(N aic bic) 
esttab using Table2.csv,  s(N aic bic) replace
------------------------------------------------------------------------------------------------------------
                      (1)             (2)             (3)             (4)             (5)             (6)   
             Violence_dum    Violence_dum    Violence_dum    Violence_dum    Violence_dum    Violence_dum   
------------------------------------------------------------------------------------------------------------
Violence_dum                                                                                                
Violence_c~1        0.479***        0.515***        0.474***        0.511***        0.474***        0.511***
                   (5.82)          (6.37)          (5.78)          (6.35)          (5.46)          (6.06)   

wy_Violenc~1        0.556***                        0.557***                        0.591***                
                   (3.36)                          (3.34)                          (3.72)                   

comm1_log_1        0.0893          0.0775           0.132           0.126           0.180           0.175   
                   (1.59)          (1.34)          (1.17)          (1.08)          (1.14)          (1.05)   

polity2            0.0587          0.0604          0.0567          0.0584          0.0579          0.0535   
                   (0.87)          (0.85)          (0.82)          (0.79)          (0.91)          (0.80)   

c.polity2#~2     -0.00856        -0.00732        -0.00764        -0.00636        -0.00716        -0.00544   
                  (-0.64)         (-0.53)         (-0.57)         (-0.46)         (-0.58)         (-0.43)   

Nightlight~n      0.00570         0.00366        0.000882        -0.00130        -0.00328        -0.00678   
                   (0.14)          (0.10)          (0.02)         (-0.03)         (-0.09)         (-0.18)   

RoadDensit~n      0.00766*        0.00655         0.00802*        0.00690         0.00651         0.00570   
                   (2.32)          (1.85)          (2.38)          (1.92)          (1.76)          (1.46)   

Diamond           0.00993           0.102         -0.0160          0.0755           0.109           0.213   
                   (0.06)          (0.65)         (-0.09)          (0.46)          (0.52)          (1.03)   

InfantMort~n      0.00361         0.00747         0.00335         0.00722         0.00347         0.00753   
                   (0.59)          (1.23)          (0.54)          (1.18)          (0.50)          (1.15)   

Mineral            0.0188          0.0197          0.0195          0.0205          0.0254*         0.0247*  
                   (1.85)          (1.83)          (1.77)          (1.75)          (2.31)          (2.12)   

Petroleum          -0.156         -0.0813          -0.167         -0.0913         -0.0651         -0.0170   
                  (-0.47)         (-0.25)         (-0.51)         (-0.28)         (-0.19)         (-0.05)   

Population~e     0.000304        0.000319        0.000305        0.000323        0.000310        0.000339   
                   (1.53)          (1.62)          (1.58)          (1.64)          (1.61)          (1.65)   

area           0.00000251      0.00000386      0.00000174      0.00000313      0.00000197      0.00000303   
                   (0.52)          (0.78)          (0.36)          (0.64)          (0.38)          (0.59)   

cultivated                                          0.230           0.331                                   
                                                   (0.17)          (0.23)                                   

c.cultivat~1                                       -0.114          -0.127                                   
                                                  (-0.54)         (-0.59)                                   

1.cultivat~t                                                                            0               0   
                                                                                      (.)             (.)   

2.cultivat~t                                                                        0.751           0.769   
                                                                                   (0.64)          (0.60)   

3.cultivat~t                                                                       -0.134          0.0935   
                                                                                  (-0.11)          (0.07)   

4.cultivat~t                                                                       0.0749           0.133   
                                                                                   (0.06)          (0.11)   

1.cultivat~1                                                                            0               0   
                                                                                      (.)             (.)   

2.cultivat~1                                                                       -0.228          -0.229   
                                                                                  (-1.29)         (-1.19)   

3.cultivat~1                                                                      -0.0933          -0.106   
                                                                                  (-0.48)         (-0.54)   

4.cultivat~1                                                                      -0.0608         -0.0741   
                                                                                  (-0.34)         (-0.41)   

_cons              -3.407***       -3.172***       -3.411**        -3.225**        -3.512**        -3.325** 
                  (-4.05)         (-3.90)         (-3.18)         (-2.92)         (-2.90)         (-2.64)   
------------------------------------------------------------------------------------------------------------
N                     895             895             895             895             895             895   
aic                 820.9           841.5           823.7           844.2           824.8           847.4   
bic                 888.1           903.8           900.4           916.2           920.7           938.6   
------------------------------------------------------------------------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

(note: file Table1.csv not found)
(output written to Table1.csv)

Iteration 0:   log likelihood = -58418.947  (not concave)
Iteration 1:   log likelihood =   -53755.3  (not concave)
Iteration 2:   log likelihood = -50755.518  (not concave)
Iteration 3:   log likelihood = -46348.492  (not concave)
Iteration 4:   log likelihood = -44758.165  
Iteration 5:   log likelihood = -40826.946  (backed up)
Iteration 6:   log likelihood = -33518.188  (backed up)
Iteration 7:   log likelihood = -31790.698  (backed up)
Iteration 8:   log likelihood = -26626.308  
Iteration 9:   log likelihood = -16630.192  
Iteration 10:  log likelihood = -4944.7287  
Iteration 11:  log likelihood = -3499.2684  
Iteration 12:  log likelihood = -3222.2449  
Iteration 13:  log likelihood = -3218.5989  
Iteration 14:  log likelihood = -3218.5925  
Iteration 15:  log likelihood = -3218.5925  

Poisson regression                              Number of obs     =        895
                                                LR chi2(13)       =    5132.67
                                                Prob > chi2       =     0.0000
Log likelihood = -3218.5925                     Pseudo R2         =     0.4436

-----------------------------------------------------------------------------------------
         Violence_count |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
------------------------+----------------------------------------------------------------
       Violence_count_1 |     0.0062     0.0006    10.62   0.000       0.0050      0.0073
    wy_Violence_count_1 |     0.2143     0.0177    12.11   0.000       0.1797      0.2490
            comm1_log_1 |    -0.1964     0.0134   -14.68   0.000      -0.2226     -0.1702
                polity2 |    -0.1877     0.0111   -16.97   0.000      -0.2093     -0.1660
                        |
    c.polity2#c.polity2 |     0.0163     0.0026     6.31   0.000       0.0113      0.0214
                        |
        Nightlight_mean |    -0.0626     0.0049   -12.73   0.000      -0.0722     -0.0529
       RoadDensity_mean |     0.0165     0.0005    33.41   0.000       0.0155      0.0175
                Diamond |    -1.1042     0.1324    -8.34   0.000      -1.3636     -0.8447
   InfantMortality_mean |     0.0052     0.0013     4.08   0.000       0.0027      0.0078
                Mineral |     0.0090     0.0022     4.04   0.000       0.0047      0.0134
              Petroleum |     0.1596     0.0459     3.47   0.001       0.0696      0.2497
Population_mean_ipolate |     0.0007     0.0000    27.68   0.000       0.0006      0.0007
                   area |    -0.0000     0.0000    -5.87   0.000      -0.0000     -0.0000
                  _cons |     0.3619     0.1907     1.90   0.058      -0.0119      0.7357
-----------------------------------------------------------------------------------------

         Deviance goodness-of-fit =  5554.985
         Prob > chi2(881)         =    0.0000

         Pearson goodness-of-fit  =  11429.96
         Prob > chi2(881)         =    0.0000

command Form is unrecognized
r(199);

Fitting Poisson model:

Iteration 0:   log likelihood = -58418.947  (not concave)
Iteration 1:   log likelihood =   -53755.3  (not concave)
Iteration 2:   log likelihood = -50755.518  (not concave)
Iteration 3:   log likelihood = -46348.492  (not concave)
Iteration 4:   log likelihood = -44758.165  
Iteration 5:   log likelihood = -40826.946  (backed up)
Iteration 6:   log likelihood = -33518.188  (backed up)
Iteration 7:   log likelihood = -31790.698  (backed up)
Iteration 8:   log likelihood = -26626.308  
Iteration 9:   log likelihood = -16630.192  
Iteration 10:  log likelihood = -4944.7287  
Iteration 11:  log likelihood = -3499.2684  
Iteration 12:  log likelihood = -3222.2449  
Iteration 13:  log likelihood = -3218.5989  
Iteration 14:  log likelihood = -3218.5925  
Iteration 15:  log likelihood = -3218.5925  

Fitting constant-only model:

Iteration 0:   log likelihood = -1930.6166  
Iteration 1:   log likelihood = -1332.6868  
Iteration 2:   log likelihood = -1332.6288  
Iteration 3:   log likelihood = -1332.6288  

Fitting full model:

Iteration 0:   log likelihood = -1289.6581  (not concave)
Iteration 1:   log likelihood = -1255.5245  
Iteration 2:   log likelihood = -1229.0294  
Iteration 3:   log likelihood = -1184.3985  
Iteration 4:   log likelihood = -1180.9847  
Iteration 5:   log likelihood =  -1180.915  
Iteration 6:   log likelihood = -1180.9148  
Iteration 7:   log likelihood = -1180.9148  

Negative binomial regression                    Number of obs     =        895
                                                LR chi2(13)       =     303.43
Dispersion     = mean                           Prob > chi2       =     0.0000
Log likelihood = -1180.9148                     Pseudo R2         =     0.1138

-----------------------------------------------------------------------------------------
         Violence_count |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
------------------------+----------------------------------------------------------------
       Violence_count_1 |     0.1334     0.0189     7.08   0.000       0.0965      0.1704
    wy_Violence_count_1 |     0.6915     0.1453     4.76   0.000       0.4066      0.9763
            comm1_log_1 |     0.0955     0.0415     2.30   0.021       0.0142      0.1768
                polity2 |     0.0191     0.0433     0.44   0.660      -0.0659      0.1040
                        |
    c.polity2#c.polity2 |     0.0005     0.0082     0.06   0.951      -0.0155      0.0165
                        |
        Nightlight_mean |     0.0036     0.0210     0.17   0.865      -0.0376      0.0448
       RoadDensity_mean |     0.0079     0.0025     3.21   0.001       0.0031      0.0128
                Diamond |    -0.2637     0.2258    -1.17   0.243      -0.7063      0.1789
   InfantMortality_mean |    -0.0023     0.0044    -0.52   0.600      -0.0109      0.0063
                Mineral |     0.0063     0.0099     0.64   0.523      -0.0130      0.0256
              Petroleum |    -0.1116     0.1741    -0.64   0.522      -0.4529      0.2296
Population_mean_ipolate |     0.0005     0.0001     4.11   0.000       0.0002      0.0007
                   area |     0.0000     0.0000     2.89   0.004       0.0000      0.0000
                  _cons |    -2.4000     0.6250    -3.84   0.000      -3.6250     -1.1751
------------------------+----------------------------------------------------------------
               /lnalpha |     1.3481     0.0862                        1.1792      1.5170
------------------------+----------------------------------------------------------------
                  alpha |     3.8502     0.3318                        3.2518      4.5586
-----------------------------------------------------------------------------------------
LR test of alpha=0: chibar2(01) = 4075.36              Prob >= chibar2 = 0.000

------------------------------------------------------------------------------------------------------------
                      (1)             (2)             (3)             (4)             (5)             (6)   
             Violence_c~t    Violence_c~t    Violence_c~t    Violence_c~t    Violence_c~t    Violence_c~t   
------------------------------------------------------------------------------------------------------------
Violence_c~t                                                                                                
Violence_c~1      0.00529         0.00342         0.00545         0.00353         0.00529         0.00339   
                   (1.35)          (0.99)          (1.45)          (1.09)          (1.43)          (1.04)   

comm1_log_1         0.146           0.105          0.0368         0.00607          0.0212         -0.0160   
                   (1.07)          (0.80)          (0.13)          (0.02)          (0.08)         (-0.06)   

polity2            0.0138          0.0109          0.0320          0.0289          0.0336          0.0296   
                   (0.13)          (0.09)          (0.33)          (0.27)          (0.36)          (0.29)   

c.polity2#~2     -0.00115        -0.00188        -0.00340        -0.00405        -0.00296        -0.00326   
                  (-0.07)         (-0.10)         (-0.22)         (-0.23)         (-0.20)         (-0.20)   

Nightlight~n       0.0173          0.0256          0.0133          0.0212         0.00850          0.0159   
                   (0.40)          (0.58)          (0.31)          (0.48)          (0.22)          (0.40)   

RoadDensit~n       0.0151***       0.0155***       0.0151***       0.0157***       0.0116**        0.0125***
                   (4.49)          (4.60)          (4.79)          (5.06)          (3.24)          (3.58)   

Diamond             0.121          0.0686           0.163           0.106           0.371           0.284   
                   (0.41)          (0.24)          (0.50)          (0.35)          (1.03)          (0.83)   

InfantMort~n       0.0183          0.0155          0.0179          0.0150          0.0162          0.0139   
                   (1.86)          (1.60)          (1.79)          (1.52)          (1.55)          (1.34)   

Mineral            0.0271*         0.0261*         0.0242*         0.0232*         0.0370*         0.0344*  
                   (2.33)          (2.25)          (2.22)          (2.13)          (2.43)          (2.45)   

Petroleum          -0.183          -0.218          -0.154          -0.190         -0.0716         -0.0838   
                  (-0.34)         (-0.42)         (-0.28)         (-0.37)         (-0.14)         (-0.17)   

Population~e     0.000726**      0.000668*       0.000712**      0.000653*       0.000717**      0.000659** 
                   (2.90)          (2.54)          (2.85)          (2.48)          (3.18)          (2.76)   

area           0.00000964      0.00000802       0.0000101      0.00000833       0.0000137       0.0000115   
                   (1.12)          (0.97)          (1.21)          (1.04)          (1.51)          (1.32)   

wy_Violenc~1                        0.317**                         0.318**                         0.317** 
                                   (2.77)                          (2.74)                          (2.71)   

cultivated                                         -2.224          -2.144                                   
                                                  (-0.79)         (-0.78)                                   

c.cultivat~1                                        0.273           0.249                                   
                                                   (0.57)          (0.54)                                   

1.cultivat~t                                                                            0               0   
                                                                                      (.)             (.)   

2.cultivat~t                                                                       -1.787          -1.773   
                                                                                  (-0.90)         (-0.93)   

3.cultivat~t                                                                       -2.172          -2.275   
                                                                                  (-1.12)         (-1.23)   

4.cultivat~t                                                                       -3.200          -2.885   
                                                                                  (-1.71)         (-1.59)   

1.cultivat~1                                                                            0               0   
                                                                                      (.)             (.)   

2.cultivat~1                                                                       0.0419          0.0488   
                                                                                   (0.14)          (0.17)   

3.cultivat~1                                                                        0.145           0.161   
                                                                                   (0.46)          (0.54)   

4.cultivat~1                                                                        0.434           0.372   
                                                                                   (1.44)          (1.27)   

_cons              -5.285***       -5.083***       -4.239*         -4.051*         -3.262          -3.130   
                  (-3.87)         (-3.96)         (-2.12)         (-2.16)         (-1.63)         (-1.67)   
------------------------------------------------------------------------------------------------------------
lnalpha                                                                                                     
_cons               0.278*          0.270*          0.281*          0.272*          0.276*          0.269*  
                   (2.51)          (2.49)          (2.53)          (2.50)          (2.46)          (2.43)   
------------------------------------------------------------------------------------------------------------
var(_cons[~)                                                                                                
_cons               3.970***        3.589***        3.791***        3.411***        3.493***        3.125***
                   (4.46)          (4.18)          (4.66)          (4.35)          (4.67)          (4.30)   
------------------------------------------------------------------------------------------------------------
N                     895             895             895             895             895             895   
aic                2224.7          2216.7          2227.3          2219.3          2229.2          2221.2   
bic                2296.7          2293.5          2308.9          2305.6          2330.0          2326.8   
------------------------------------------------------------------------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

(note: file Table2.csv not found)
(output written to Table2.csv)