{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "281e8f65238cd05f",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "# Quatitative Study Replication\n",
    "## Imports and Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c7fa7823e0974f4f",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-07T15:32:01.651786Z",
     "start_time": "2024-08-07T15:32:01.608890100Z"
    }
   },
   "outputs": [],
   "source": [
    "import warnings\n",
    "warnings.filterwarnings(\"ignore\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    },
    "ExecuteTime": {
     "end_time": "2024-08-07T15:32:02.858145600Z",
     "start_time": "2024-08-07T15:32:01.623812300Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "dat = pd.read_csv('StudyDataset.csv', encoding='windows-1252', index_col=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "857c3f3e8cd89ba7",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-07T15:32:02.906717600Z",
     "start_time": "2024-08-07T15:32:02.863693700Z"
    }
   },
   "outputs": [],
   "source": [
    "df = pd.read_csv('Quantitative Study Replication/Non-State Actors Dataset/nsa_v3.4_21November2013.asc', sep='\\t', encoding='windows-1252')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "cb6c6ee91a5fa5fc",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-07T15:32:02.956800100Z",
     "start_time": "2024-08-07T15:32:02.895241200Z"
    }
   },
   "outputs": [],
   "source": [
    "df_3 = pd.read_csv('StudyDataset2.csv', encoding='windows-1252', index_col=0)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "831426af963ce602",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "## Rows with more than one Rebel Group\n",
    "The DCJ dataset contains rows that list more than one rebel group in the 'Side B' column. In order to deal with this, first, sample weights were introduced. These rows were then split into a row for each group, and weighted such that the total weight of the newly created rows for each original rows sums to one. \n",
    "\n",
    "In other words, if a row lists 2 groups, it will be split into 2 rows, each with one of the two groups and otherwise identical, weighted at 0.5 each."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [
    {
     "data": {
      "text/plain": "      acdid  year   gwno              location    sidea  \\\n1         1  1946  145.0               Bolivia  Bolivia   \n2         1  1952  145.0               Bolivia  Bolivia   \n3         1  1967  145.0               Bolivia  Bolivia   \n4         2  1946  811.0  Cambodia (Kampuchea)   France   \n5         2  1947  811.0  Cambodia (Kampuchea)   France   \n...     ...   ...    ...                   ...      ...   \n3406    271  2011  620.0                 Libya    Libya   \n3407    271  2011  620.0                 Libya    Libya   \n3408    271  2011  620.0                 Libya    Libya   \n3409    271  2011  620.0                 Libya    Libya   \n3410    271  2011  620.0                 Libya    Libya   \n\n                               sideb  incomp territory   startdate  \\\n1     Popular Revolutionary Movement       2       NaN  1946-06-30   \n2                                MNR       2       NaN  1946-06-30   \n3                                ELN       2       NaN  1946-06-30   \n4                      Khmer Issarak       1  Cambodia  1946-08-31   \n5                      Khmer Issarak       1  Cambodia  1946-08-31   \n...                              ...     ...       ...         ...   \n3406  NTC, Forces of Muammar Gaddafi       2       NaN  2011-01-28   \n3407  NTC, Forces of Muammar Gaddafi       2       NaN  2011-01-28   \n3408  NTC, Forces of Muammar Gaddafi       2       NaN  2011-01-28   \n3409  NTC, Forces of Muammar Gaddafi       2       NaN  2011-01-28   \n3410  NTC, Forces of Muammar Gaddafi       2       NaN  2011-01-28   \n\n     epstartdate  ... exile_erank  exile_sender  exile_scope exile_scount  \\\n1     1946-06-30  ...         NaN           NaN          NaN          NaN   \n2     1952-04-09  ...         NaN           NaN          NaN          NaN   \n3     1967-03-31  ...         NaN           NaN          NaN          NaN   \n4     1946-08-31  ...         NaN           NaN          NaN          NaN   \n5     1946-08-31  ...         NaN           NaN          NaN          NaN   \n...          ...  ...         ...           ...          ...          ...   \n3406  2011-03-04  ...         NaN           NaN          NaN          NaN   \n3407  2011-03-04  ...         NaN           NaN          NaN          NaN   \n3408  2011-03-04  ...         NaN           NaN          NaN          NaN   \n3409  2011-03-04  ...         NaN           NaN          NaN          NaN   \n3410  2011-03-04  ...         NaN           NaN          NaN          NaN   \n\n      exile_implement  exile_rDCJ  exile_peaceagr  exile_start  exile_end  \\\n1                 NaN         NaN             NaN          NaN        NaN   \n2                 NaN         NaN             NaN          NaN        NaN   \n3                 NaN         NaN             NaN          NaN        NaN   \n4                 NaN         NaN             NaN          NaN        NaN   \n5                 NaN         NaN             NaN          NaN        NaN   \n...               ...         ...             ...          ...        ...   \n3406              NaN         NaN             NaN          NaN        NaN   \n3407              NaN         NaN             NaN          NaN        NaN   \n3408              NaN         NaN             NaN          NaN        NaN   \n3409              NaN         NaN             NaN          NaN        NaN   \n3410              NaN         NaN             NaN          NaN        NaN   \n\n     exile_perm  \n1           NaN  \n2           NaN  \n3           NaN  \n4           NaN  \n5           NaN  \n...         ...  \n3406        NaN  \n3407        NaN  \n3408        NaN  \n3409        NaN  \n3410        NaN  \n\n[3410 rows x 168 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>acdid</th>\n      <th>year</th>\n      <th>gwno</th>\n      <th>location</th>\n      <th>sidea</th>\n      <th>sideb</th>\n      <th>incomp</th>\n      <th>territory</th>\n      <th>startdate</th>\n      <th>epstartdate</th>\n      <th>...</th>\n      <th>exile_erank</th>\n      <th>exile_sender</th>\n      <th>exile_scope</th>\n      <th>exile_scount</th>\n      <th>exile_implement</th>\n      <th>exile_rDCJ</th>\n      <th>exile_peaceagr</th>\n      <th>exile_start</th>\n      <th>exile_end</th>\n      <th>exile_perm</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>1</th>\n      <td>1</td>\n      <td>1946</td>\n      <td>145.0</td>\n      <td>Bolivia</td>\n      <td>Bolivia</td>\n      <td>Popular Revolutionary Movement</td>\n      <td>2</td>\n      <td>NaN</td>\n      <td>1946-06-30</td>\n      <td>1946-06-30</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>1</td>\n      <td>1952</td>\n      <td>145.0</td>\n      <td>Bolivia</td>\n      <td>Bolivia</td>\n      <td>MNR</td>\n      <td>2</td>\n      <td>NaN</td>\n      <td>1946-06-30</td>\n      <td>1952-04-09</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>1</td>\n      <td>1967</td>\n      <td>145.0</td>\n      <td>Bolivia</td>\n      <td>Bolivia</td>\n      <td>ELN</td>\n      <td>2</td>\n      <td>NaN</td>\n      <td>1946-06-30</td>\n      <td>1967-03-31</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>2</td>\n      <td>1946</td>\n      <td>811.0</td>\n      <td>Cambodia (Kampuchea)</td>\n      <td>France</td>\n      <td>Khmer Issarak</td>\n      <td>1</td>\n      <td>Cambodia</td>\n      <td>1946-08-31</td>\n      <td>1946-08-31</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>2</td>\n      <td>1947</td>\n      <td>811.0</td>\n      <td>Cambodia (Kampuchea)</td>\n      <td>France</td>\n      <td>Khmer Issarak</td>\n      <td>1</td>\n      <td>Cambodia</td>\n      <td>1946-08-31</td>\n      <td>1946-08-31</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>3406</th>\n      <td>271</td>\n      <td>2011</td>\n      <td>620.0</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>NTC, Forces of Muammar Gaddafi</td>\n      <td>2</td>\n      <td>NaN</td>\n      <td>2011-01-28</td>\n      <td>2011-03-04</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>3407</th>\n      <td>271</td>\n      <td>2011</td>\n      <td>620.0</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>NTC, Forces of Muammar Gaddafi</td>\n      <td>2</td>\n      <td>NaN</td>\n      <td>2011-01-28</td>\n      <td>2011-03-04</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>3408</th>\n      <td>271</td>\n      <td>2011</td>\n      <td>620.0</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>NTC, Forces of Muammar Gaddafi</td>\n      <td>2</td>\n      <td>NaN</td>\n      <td>2011-01-28</td>\n      <td>2011-03-04</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>3409</th>\n      <td>271</td>\n      <td>2011</td>\n      <td>620.0</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>NTC, Forces of Muammar Gaddafi</td>\n      <td>2</td>\n      <td>NaN</td>\n      <td>2011-01-28</td>\n      <td>2011-03-04</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>3410</th>\n      <td>271</td>\n      <td>2011</td>\n      <td>620.0</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>NTC, Forces of Muammar Gaddafi</td>\n      <td>2</td>\n      <td>NaN</td>\n      <td>2011-01-28</td>\n      <td>2011-03-04</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n  </tbody>\n</table>\n<p>3410 rows × 168 columns</p>\n</div>"
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dat"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-07T15:32:07.364909900Z",
     "start_time": "2024-08-07T15:32:07.294715700Z"
    }
   },
   "id": "dedfc0eb2e7a0fdc"
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "45708832ae89f26f",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-07T15:33:28.227116100Z",
     "start_time": "2024-08-07T15:32:49.222920800Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "      acdid  year   gwno              location    sidea  \\\n1         1  1946  145.0               Bolivia  Bolivia   \n2         1  1952  145.0               Bolivia  Bolivia   \n3         1  1967  145.0               Bolivia  Bolivia   \n4         2  1946  811.0  Cambodia (Kampuchea)   France   \n5         2  1947  811.0  Cambodia (Kampuchea)   France   \n...     ...   ...    ...                   ...      ...   \n5861    271  2011  620.0                 Libya    Libya   \n5862    271  2011  620.0                 Libya    Libya   \n5863    271  2011  620.0                 Libya    Libya   \n5864    271  2011  620.0                 Libya    Libya   \n5865    271  2011  620.0                 Libya    Libya   \n\n                               sideb  incomp territory   startdate  \\\n1     Popular Revolutionary Movement       2       NaN  1946-06-30   \n2                                MNR       2       NaN  1946-06-30   \n3                                ELN       2       NaN  1946-06-30   \n4                      Khmer Issarak       1  Cambodia  1946-08-31   \n5                      Khmer Issarak       1  Cambodia  1946-08-31   \n...                              ...     ...       ...         ...   \n5861       Forces of Muammar Gaddafi       2       NaN  2011-01-28   \n5862                             NTC       2       NaN  2011-01-28   \n5863       Forces of Muammar Gaddafi       2       NaN  2011-01-28   \n5864                             NTC       2       NaN  2011-01-28   \n5865       Forces of Muammar Gaddafi       2       NaN  2011-01-28   \n\n     epstartdate  ... exile_sender  exile_scope  exile_scount exile_implement  \\\n1     1946-06-30  ...          NaN          NaN           NaN             NaN   \n2     1952-04-09  ...          NaN          NaN           NaN             NaN   \n3     1967-03-31  ...          NaN          NaN           NaN             NaN   \n4     1946-08-31  ...          NaN          NaN           NaN             NaN   \n5     1946-08-31  ...          NaN          NaN           NaN             NaN   \n...          ...  ...          ...          ...           ...             ...   \n5861  2011-03-04  ...          NaN          NaN           NaN             NaN   \n5862  2011-03-04  ...          NaN          NaN           NaN             NaN   \n5863  2011-03-04  ...          NaN          NaN           NaN             NaN   \n5864  2011-03-04  ...          NaN          NaN           NaN             NaN   \n5865  2011-03-04  ...          NaN          NaN           NaN             NaN   \n\n      exile_rDCJ  exile_peaceagr  exile_start  exile_end  exile_perm  \\\n1            NaN             NaN          NaN        NaN         NaN   \n2            NaN             NaN          NaN        NaN         NaN   \n3            NaN             NaN          NaN        NaN         NaN   \n4            NaN             NaN          NaN        NaN         NaN   \n5            NaN             NaN          NaN        NaN         NaN   \n...          ...             ...          ...        ...         ...   \n5861         NaN             NaN          NaN        NaN         NaN   \n5862         NaN             NaN          NaN        NaN         NaN   \n5863         NaN             NaN          NaN        NaN         NaN   \n5864         NaN             NaN          NaN        NaN         NaN   \n5865         NaN             NaN          NaN        NaN         NaN   \n\n     model_weight  \n1             1.0  \n2             1.0  \n3             1.0  \n4             1.0  \n5             1.0  \n...           ...  \n5861          0.5  \n5862          0.5  \n5863          0.5  \n5864          0.5  \n5865          0.5  \n\n[5865 rows x 169 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>acdid</th>\n      <th>year</th>\n      <th>gwno</th>\n      <th>location</th>\n      <th>sidea</th>\n      <th>sideb</th>\n      <th>incomp</th>\n      <th>territory</th>\n      <th>startdate</th>\n      <th>epstartdate</th>\n      <th>...</th>\n      <th>exile_sender</th>\n      <th>exile_scope</th>\n      <th>exile_scount</th>\n      <th>exile_implement</th>\n      <th>exile_rDCJ</th>\n      <th>exile_peaceagr</th>\n      <th>exile_start</th>\n      <th>exile_end</th>\n      <th>exile_perm</th>\n      <th>model_weight</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>1</th>\n      <td>1</td>\n      <td>1946</td>\n      <td>145.0</td>\n      <td>Bolivia</td>\n      <td>Bolivia</td>\n      <td>Popular Revolutionary Movement</td>\n      <td>2</td>\n      <td>NaN</td>\n      <td>1946-06-30</td>\n      <td>1946-06-30</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>1.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>1</td>\n      <td>1952</td>\n      <td>145.0</td>\n      <td>Bolivia</td>\n      <td>Bolivia</td>\n      <td>MNR</td>\n      <td>2</td>\n      <td>NaN</td>\n      <td>1946-06-30</td>\n      <td>1952-04-09</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>1.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>1</td>\n      <td>1967</td>\n      <td>145.0</td>\n      <td>Bolivia</td>\n      <td>Bolivia</td>\n      <td>ELN</td>\n      <td>2</td>\n      <td>NaN</td>\n      <td>1946-06-30</td>\n      <td>1967-03-31</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>1.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>2</td>\n      <td>1946</td>\n      <td>811.0</td>\n      <td>Cambodia (Kampuchea)</td>\n      <td>France</td>\n      <td>Khmer Issarak</td>\n      <td>1</td>\n      <td>Cambodia</td>\n      <td>1946-08-31</td>\n      <td>1946-08-31</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>1.0</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>2</td>\n      <td>1947</td>\n      <td>811.0</td>\n      <td>Cambodia (Kampuchea)</td>\n      <td>France</td>\n      <td>Khmer Issarak</td>\n      <td>1</td>\n      <td>Cambodia</td>\n      <td>1946-08-31</td>\n      <td>1946-08-31</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>1.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>5861</th>\n      <td>271</td>\n      <td>2011</td>\n      <td>620.0</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>Forces of Muammar Gaddafi</td>\n      <td>2</td>\n      <td>NaN</td>\n      <td>2011-01-28</td>\n      <td>2011-03-04</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>0.5</td>\n    </tr>\n    <tr>\n      <th>5862</th>\n      <td>271</td>\n      <td>2011</td>\n      <td>620.0</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>NTC</td>\n      <td>2</td>\n      <td>NaN</td>\n      <td>2011-01-28</td>\n      <td>2011-03-04</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>0.5</td>\n    </tr>\n    <tr>\n      <th>5863</th>\n      <td>271</td>\n      <td>2011</td>\n      <td>620.0</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>Forces of Muammar Gaddafi</td>\n      <td>2</td>\n      <td>NaN</td>\n      <td>2011-01-28</td>\n      <td>2011-03-04</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>0.5</td>\n    </tr>\n    <tr>\n      <th>5864</th>\n      <td>271</td>\n      <td>2011</td>\n      <td>620.0</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>NTC</td>\n      <td>2</td>\n      <td>NaN</td>\n      <td>2011-01-28</td>\n      <td>2011-03-04</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>0.5</td>\n    </tr>\n    <tr>\n      <th>5865</th>\n      <td>271</td>\n      <td>2011</td>\n      <td>620.0</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>Forces of Muammar Gaddafi</td>\n      <td>2</td>\n      <td>NaN</td>\n      <td>2011-01-28</td>\n      <td>2011-03-04</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>0.5</td>\n    </tr>\n  </tbody>\n</table>\n<p>5865 rows × 169 columns</p>\n</div>"
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dat['model_weight'] = 1\n",
    "indexes_to_delete = []\n",
    "for i in dat.index:\n",
    "    if len(dat.loc[i]['sideb'].split(',')) > 1:\n",
    "        for actor in dat.loc[i]['sideb'].split(','):\n",
    "            new_row = dat.loc[i]\n",
    "            new_row['model_weight'] /= len(dat.loc[i]['sideb'].split(','))\n",
    "            new_row['sideb'] = actor.strip()\n",
    "            dat.loc[len(dat) + 1] = new_row\n",
    "            indexes_to_delete.append(i)\n",
    "dat\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "e776b79508c3a43a",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-07T15:33:28.248937700Z",
     "start_time": "2024-08-07T15:33:28.229624500Z"
    }
   },
   "outputs": [],
   "source": [
    "dat.drop(index=indexes_to_delete, inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ea8bcabd1bf4e769",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "## Different Spellings and Acronyms\n",
    "Some of the spellings and acronyms used differ between the DCJ and NSA datasets. This step matches up the spellings so the datasets can be joined."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "c1e42d759d27dbca",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-07T15:33:46.310790700Z",
     "start_time": "2024-08-07T15:33:46.272174200Z"
    }
   },
   "outputs": [],
   "source": [
    "dict = {\n",
    "'Peoples Liberation Army': 'PLA',\n",
    "'Republic of Kurdistan/KDPI': 'KDPI',\n",
    "'Indonesian Peoples Army': \"Indonesian People's Army\",\n",
    "'Communist Party of the Philippines': 'CPP',\n",
    "'Military Faction (forces of Honasan, Abenina & Zumel)': 'CPP, Military Faction (forces of Honasan, Abenina & Zumel)',\n",
    "'LTS[p]A': 'LTS(p)A',\n",
    "'Viet Nam Doc Dong Min Hoi': 'Viet minh',\n",
    "'Opposition coalition [Febreristas, Liberals and Communists]': 'Opposition coalition (Febreristas, Liberals and Communists)',\n",
    "'Military Faction (forces of General Rodriguez)': 'Military faction (forces of Andres Rodriguez)',\n",
    "'Military faction (forces of General Alfredo Stroessner)': 'Military faction (forces of Alfredo Stroessner)',\n",
    "'PVO - White Band faction': 'PVO - \"White Band\" faction',\n",
    "\"Arakan People's Liberation Party\": 'APLP',\n",
    "'Communist Party of Arakan': 'CPA',\n",
    "'Rohingya Solidarity Organisation': 'RSO',\n",
    "'Arakan Rohingya Islamic Front': 'ARIF',\n",
    "'Naxalites/PWG': 'PWG',\n",
    "'Naxalites/CPI [-Marxist]': 'CPI-ML',\n",
    "'CPI–Maoist': 'CPI-Maoist',\n",
    "'Military Faction [Navy]': 'Military faction (Navy)',\n",
    "'Military Faction - 26th of July Movement': 'M-26-7',\n",
    "'National Revolutionary Council': 'Cuban Revolutionary Council',\n",
    "'Darul Islam Movement': 'Darul Islam',\n",
    "'Military faction (forces of Eduardo A. Lonardi Doucet)': 'Military faction (forces of Samuel Toranzo Calderón), Military faction (forces of Eduardo A. Lonardi Doucet)',\n",
    "'Supreme Council for the Islamic Revolution in Iraq (SCIRI)': 'SCIRI',\n",
    "'ISI/Jama\\'at Al-Tawhid wa Al-Jihad': 'ISI',\n",
    "'RJF/Al-Jaysh al-Islami fi Iraq': 'RJF',\n",
    "'Independent Nasserite Movement /Mourabitoun militia': 'Independent Nasserite Movement /Mourabitoun militia',\n",
    "'Lebanese National Movement': 'LNM',\n",
    "'Shan State Army - South (SSA-S)': 'SSA',\n",
    "'Independent Mining State of South Kasai': 'Independent Mining State of South Kasai',\n",
    "'Military faction (forces of Amsha Desta and Merid Negusie)': 'EPRDF, Military faction (forces of Amsha Desta and Merid Negusie)',\n",
    "'CPN-M/UPF': 'CPN-M',\n",
    "'KDP/DPK': 'KDP',\n",
    "'North Kalimantan Liberation Army': 'North Kalimantan Liberation Army',\n",
    "'Military faction (forces of Hugo Chávez)': 'Military faction (forces of Hugo Chávez)',\n",
    "\"Military faction (forces loyal to Léon M'Ba)\": \"Military faction (forces loyal to Léon M'Ba)\",\n",
    "'Military faction (forces loyal to Gervais Nyangoma)': 'Military faction (forces loyal to Gervais Nyangoma)',\n",
    "'First Liberation Army': 'First Liberation Army',\n",
    "'Second Liberation Army (Frolinat)': 'Second Liberation Army',\n",
    "'Military faction (forces of Maldoum Bada Abbas)': 'MDD, Military faction (forces of Maldoum Bada Abbas)',\n",
    "'Military faction (Constitutionalists)': 'Military faction (Constitutionalists)',\n",
    "'Military faction (forces of Jerry John Rawlings)': 'Military faction (forces of Jerry John Rawlings)',\n",
    "'Military faction (forces of Ekow Dennis and Edward Adjei-Ampofo) ': 'Military faction (forces of Ekow Dennis and Edward Adjei-Ampofo)',\n",
    "'Military faction (forces of Patrick Nzeogwu)': 'Military faction (forces of Patrick Nzeogwu)',\n",
    "'Boko Haram': \"Jama'atu Ahlis Sunna Lidda'awati wal-Jihad\",\n",
    "'Military faction (forces loyal to Nureddin Atassi and Youssef Zeayen)': 'Military faction (forces loyal to Nureddin Atassi and Youssef Zeayen)',\n",
    "'Khmer Rouge/PDK': 'KR',\n",
    "'FUNCINPEC/ANS': 'FUNCINPEC',\n",
    "'MIM/Mindanao Independence Movement': 'MIM',\n",
    "'MNLF – NM': 'MNLF - NM',\n",
    "'MNLF – HM': 'MNLF - HM',\n",
    "'SLM/A': 'SLM/A',\n",
    "'SLM/A – MM': 'SLM/A - MM',\n",
    "'SPLM/A-North': 'SPLM/A-North',\n",
    "'Military faction (forces of Mohamed Madbouh)': 'Military faction (forces of Mohamed Madbouh)',\n",
    "'Mukti Bahini: Liberation Force': 'Mukti Bahini',\n",
    "'Military faction (forces of Idi Amin)': 'Military faction (forces of Idi Amin)',\n",
    "'Military faction (forces of Charles Arube)': 'Military faction (forces of Charles Arube)',\n",
    "\"Lord's Army\": \"Lord's Army\",\n",
    "'PIRA/IRA': 'PIRA',\n",
    "'Military faction (forces of Benjamin Mejia)': 'Military faction (forces of Benjamin Mejia)',\n",
    "'MLN  or Tupamaros': 'MLN/Tupamaros',\n",
    "'Military faction (forces of Augusto Pinochet, Toribio Merino and Leigh Guzman)': 'Military faction (forces of Augusto Pinochet, Toribio Merino and Leigh Guzman)',\n",
    "'JSS/SB/Shanti Bahini': 'JSS/SB',\n",
    "'BLA/Baluchistan Liberation Army': 'BLA',\n",
    "'BRA/Baluchistan Republican Army': 'BRA',\n",
    "'Hezb-i-Islami': 'Hizb-i Islami-yi Afghanistan',\n",
    "'Hezb-i-Wahdat': 'Hizb-i Wahdat',\n",
    "'Jamiat-i-Islami': \"Jam'iyyat-i Islami-yi Afghanistan\",\n",
    "'Junbish-i Milli-yi Islami': 'Junbish-i Milli-yi Islami',\n",
    "'Hizb-i Demokratik-i Khalq-i Afghanistan': 'PDPA',\n",
    "'Harakat-i Inqilab-i Islami-yi Afghanistan': 'Harakat-i Inqilab-i Islami-yi Afghanistan',\n",
    "'Mahaz-i Milli-yi Islami-yi Afghanistan': 'Mahaz-i Milli-yi Afghanistan',\n",
    "'Jabha-yi Nijat-i Milli-yi Afghanistan': 'Jabha-yi Nijat-i Milli-yi Afghanistan',\n",
    "'Ittihad-i Islami Bara-yi Azadi-yi Afghanistan': 'Ittihad-i Is',\n",
    "'Harakat-i Islami-yi Afghanistan': 'Harakat-i Islami-yi Afghanistan',\n",
    "'Hizb-i Islami-yi Afghanistan - Khalis faction': 'Hizb-i Islami-yi Afghanistan - Khalis faction',\n",
    "'FDN/Contras': 'Contras/FDN',\n",
    "'USC Faction': 'USC/SNA',\n",
    "'ARS/UIC': 'ARS/UIC',\n",
    "'Mujahideen e Khalq': 'MEK',\n",
    "'Military faction (forces of Samuel Doe)': 'Military faction (forces of Samuel Doe)',\n",
    "'Resistance Armee Tunisienne': 'Résistance Armée Tunisienne',\n",
    "'Military faction (forces of Hezekiah Ochuka)': 'Military faction (forces of Hezekiah Ochuka)',\n",
    "'PKK/Kadek': 'PKK',\n",
    "'Yemenite Socialist Party - Abdul Fattah Ismail faction': 'Yemenite Socialist Party - Abdul Fattah Ismail faction',\n",
    "'Military faction (forces of Moisés Giroldi)': 'Military faction (forces of Moisés Giroldi)',\n",
    "'Military faction (forces of Himmler Rebu and Guy Francois)': 'Military faction (forces of Himmler Rebu and Guy Francois)',\n",
    "'Military faction (forces of Raol Cédras)': 'Military faction (forces of Raol Cédras)',\n",
    "'OP Lavalas (Chimères)': 'OP Lavalas (Chimères)',\n",
    "'Government of Armenia and ANM': 'Republic of Armenia',\n",
    "'Azerbaijani Popular Front': 'APF',\n",
    "'FRUD – AD': 'FRUD - AD',\n",
    "'Croatian irregulars': 'Croatian irregulars',\n",
    "'Exile and Redemption': \"Takfir wa'l Hijra\",\n",
    "'FLEC–FAC': 'FLEC-FAC',\n",
    "'Republic of Nagorno-Karabakh': 'Republic of Nagorno-Karabakh',\n",
    "'Serbian Republic of Bosnia and Herzegovina': 'Serbian Republic of Bosnia-Herzegovina',\n",
    "'Serbian Republic of Krajina': 'Serbian Republic of Krajina',\n",
    "'al-Gamaa al-Islamiyya': \"al-Gama'a al-Islamiyya\",\n",
    "'Republic of Abkhazia': 'Republic of Abkhazia',\n",
    "'Republic of South Ossetia': 'Republic of South Ossetia',\n",
    "'Dniestr Republic': 'PMR',\n",
    "'Movement for Peace in Tajikistan': 'Movement for Peace in Tajikistan',\n",
    "'Husseinov Military Faction': 'Military faction (forces of Suret Husseinov)',\n",
    "'OPON forces': 'OPON forces',\n",
    "'Autonomous Province of Western Bosnia': 'Autonomous Province of Western Bosnia',\n",
    "'Croatian Republic of Bosnia and Herzegovina': 'Croatian Republic of Bosnia-Herzegovina',\n",
    "'Republic of Chechnya': 'Chechen Republic of Ichkeria',\n",
    "'Military Junta for the Consolidation of Democracy, Peace and Justice': 'Military Junta for the Consolidation of Democracy, Peace and Justice',\n",
    "'National Liberation Army (UCK)': 'UCK',\n",
    "'al-Qaida [The Base]': 'al-Qaida',\n",
    "'Forces of the Caucasus Emirate': 'Forces of the Caucasus Emirate',\n",
    "'NDFB – RD': 'NDFB - RD',\n",
    "'Republic of South Sudan': 'Republic of South Sudan',\n",
    "'Forces of Muammar Gaddafi': 'Forces of Muammar Gaddafi'\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "5450adfbf40b0aa8",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-07T15:33:48.850315500Z",
     "start_time": "2024-08-07T15:33:48.798368400Z"
    }
   },
   "outputs": [],
   "source": [
    "df = df.groupby(['ucdpid', 'side_b']).first().reset_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "9e0c952d59e7e20f",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-07T15:34:07.051133300Z",
     "start_time": "2024-08-07T15:34:06.986475300Z"
    }
   },
   "outputs": [],
   "source": [
    "df.replace(dict, inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3f68fbd2a36ea7ac",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "## Joining the Data\n",
    "This cell merges the three datasets into one complete dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "7f5e802deef62ae0",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-07T15:35:26.803327800Z",
     "start_time": "2024-08-07T15:35:26.735106700Z"
    }
   },
   "outputs": [],
   "source": [
    "data = pd.merge(left=dat, right=df, left_on=['acdid','sideb'], right_on=['ucdpid', 'side_b'], suffixes=('_DCJ', '_NSA'), how='inner')\n",
    "data = data.join(df_3.set_index(['acdid', 'styear', 'endyear', 'year']), on=['acdid', 'styear', 'endyear', 'year'], rsuffix='_DCJ2', how='left')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1bc06941b0334c51",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "## Data Cleaning\n",
    "There are a couple of data cleaning steps to get the data in the form that's described in the study:"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "15c93a8120022e04",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### is_leftist_group\n",
    "The original paper mentions 36 leftist groups. The full list of involved groups was given to Claude Sonnet 3.5, and it was asked to identify leftist groups. The list was then confirmed using basic google searches. Data was labeled 1/True if a group is a leftist group, or 0 if not."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "7b7e7bc92cad0a19",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-07T15:36:00.998850800Z",
     "start_time": "2024-08-07T15:35:58.287693700Z"
    }
   },
   "outputs": [],
   "source": [
    "data['is_leftist_group'] = pd.Series()\n",
    "for i in data.index:\n",
    "    if data.loc[i]['sideb'] in ['CPP', 'CPI', 'CPI-ML', 'PWG', 'CPI-Maoist', 'CPT', 'CPM', 'CPN-M', 'FARC', 'Sendero Luminoso', 'JVP', 'MEK', 'MCC', 'Viet minh', 'Pathet Lao', 'TPLF', 'EPRDF', 'Frelimo', 'MPLA', 'SWAPO', 'ZAPU', 'ZANU', 'MLN/Tupamaros', 'FSLN', 'PDPA', 'UNLF', 'PFLP', 'PFLP-GC', 'ELN', 'PLA', 'DSE', 'Huk', 'M-26-7', 'EPL', 'MIR', 'EPRP']:\n",
    "        data['is_leftist_group'][i] = 1\n",
    "    else:\n",
    "        data['is_leftist_group'][i] = 0"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1fa8a7a7eddf76ba",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### Trimming the Fat\n",
    "'Dataset' contains just the necessary elements from 'data', and includes all the information needed for this analysis."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "ba2017724d99258b",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-07T15:36:05.740770900Z",
     "start_time": "2024-08-07T15:36:05.695608300Z"
    }
   },
   "outputs": [],
   "source": [
    "dataset = data[['acdid', 'location', 'sidea', 'sideb', 'model_weight', 'mobcap', 'fightcap', 'intens', 'polity', 'is_leftist_group', 'trial', 'truth', 'rep', 'amnesty', 'purge', 'exile', 'incomp', 'terrcont', 'year']] "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "848b3dd8a10b4b45",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### year_of_conflict\n",
    "This variable represents how many years a conflict has been ongoing, as described in the original study. It is increased by 1 for every consecutive year that the same conflict appears in the dataset."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "84aa3e3ffc1b73f9",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-07T15:37:04.119663600Z",
     "start_time": "2024-08-07T15:36:58.034743100Z"
    }
   },
   "outputs": [],
   "source": [
    "dataset['year_of_conflict'] = pd.Series()\n",
    "dataset['year_of_conflict'][0] = 1\n",
    "i = 1\n",
    "for idx in dataset.index[1:]:\n",
    "    if list(dataset.loc[idx][['acdid', 'location', 'sidea', 'sideb']]) == list(dataset.loc[idx-1][['acdid', 'location', 'sidea', 'sideb']]) and dataset.loc[idx, 'year'] == dataset.loc[idx-1]['year'] + 1:\n",
    "        i+=1\n",
    "    elif list(dataset.loc[idx][['acdid', 'location', 'sidea', 'sideb']]) == list(dataset.loc[idx-1][['acdid', 'location', 'sidea', 'sideb']]) and dataset.loc[idx, 'year'] == dataset.loc[idx-1]['year']:\n",
    "        pass\n",
    "    else: \n",
    "        i = 1\n",
    "    dataset['year_of_conflict'][idx] = i "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "outputs": [
    {
     "data": {
      "text/plain": "      acdid              location    sidea                           sideb  \\\n0         1               Bolivia  Bolivia  Popular Revolutionary Movement   \n1         1               Bolivia  Bolivia                             MNR   \n2         1               Bolivia  Bolivia                             ELN   \n3         2  Cambodia (Kampuchea)   France                   Khmer Issarak   \n4         2  Cambodia (Kampuchea)   France                   Khmer Issarak   \n...     ...                   ...      ...                             ...   \n4302    271                 Libya    Libya       Forces of Muammar Gaddafi   \n4303    271                 Libya    Libya       Forces of Muammar Gaddafi   \n4304    271                 Libya    Libya       Forces of Muammar Gaddafi   \n4305    271                 Libya    Libya       Forces of Muammar Gaddafi   \n4306    271                 Libya    Libya       Forces of Muammar Gaddafi   \n\n      model_weight    mobcap  fightcap  intens  polity is_leftist_group  ...  \\\n0              1.0  moderate  moderate       2       0                0  ...   \n1              1.0  moderate  moderate       1       0                0  ...   \n2              1.0       low       low       1       0                1  ...   \n3              1.0       low       low       1       0                0  ...   \n4              1.0       low       low       1       0                0  ...   \n...            ...       ...       ...     ...     ...              ...  ...   \n4302           0.5       low  moderate       2       0                0  ...   \n4303           0.5       low  moderate       2       0                0  ...   \n4304           0.5       low  moderate       2       0                0  ...   \n4305           0.5       low  moderate       2       0                0  ...   \n4306           0.5       low  moderate       2       0                0  ...   \n\n      amnesty  purge  exile  incomp  terrcont  year  year_of_conflict  \\\n0           0      0      0       2        no  1946                 1   \n1           0      0      0       2        no  1952                 1   \n2           0      0      0       2        no  1967                 1   \n3           0      0      0       1       yes  1946                 1   \n4           0      0      0       1       yes  1947                 2   \n...       ...    ...    ...     ...       ...   ...               ...   \n4302        0      0      0       2       yes  2011                 1   \n4303        0      0      0       2       yes  2011                 1   \n4304        0      0      0       2       yes  2011                 1   \n4305        1      0      0       2       yes  2011                 1   \n4306        0      0      0       2       yes  2011                 1   \n\n     conciliatory  coercive DCJ_used  \n0               0         0        0  \n1               0         0        0  \n2               0         0        0  \n3               0         0        0  \n4               0         0        0  \n...           ...       ...      ...  \n4302            1         0        1  \n4303            0         1        1  \n4304            0         1        1  \n4305            1         0        1  \n4306            0         1        1  \n\n[4307 rows x 23 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>acdid</th>\n      <th>location</th>\n      <th>sidea</th>\n      <th>sideb</th>\n      <th>model_weight</th>\n      <th>mobcap</th>\n      <th>fightcap</th>\n      <th>intens</th>\n      <th>polity</th>\n      <th>is_leftist_group</th>\n      <th>...</th>\n      <th>amnesty</th>\n      <th>purge</th>\n      <th>exile</th>\n      <th>incomp</th>\n      <th>terrcont</th>\n      <th>year</th>\n      <th>year_of_conflict</th>\n      <th>conciliatory</th>\n      <th>coercive</th>\n      <th>DCJ_used</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>1</td>\n      <td>Bolivia</td>\n      <td>Bolivia</td>\n      <td>Popular Revolutionary Movement</td>\n      <td>1.0</td>\n      <td>moderate</td>\n      <td>moderate</td>\n      <td>2</td>\n      <td>0</td>\n      <td>0</td>\n      <td>...</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>2</td>\n      <td>no</td>\n      <td>1946</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>1</td>\n      <td>Bolivia</td>\n      <td>Bolivia</td>\n      <td>MNR</td>\n      <td>1.0</td>\n      <td>moderate</td>\n      <td>moderate</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>...</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>2</td>\n      <td>no</td>\n      <td>1952</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>1</td>\n      <td>Bolivia</td>\n      <td>Bolivia</td>\n      <td>ELN</td>\n      <td>1.0</td>\n      <td>low</td>\n      <td>low</td>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>...</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>2</td>\n      <td>no</td>\n      <td>1967</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>2</td>\n      <td>Cambodia (Kampuchea)</td>\n      <td>France</td>\n      <td>Khmer Issarak</td>\n      <td>1.0</td>\n      <td>low</td>\n      <td>low</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>...</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1</td>\n      <td>yes</td>\n      <td>1946</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>2</td>\n      <td>Cambodia (Kampuchea)</td>\n      <td>France</td>\n      <td>Khmer Issarak</td>\n      <td>1.0</td>\n      <td>low</td>\n      <td>low</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>...</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1</td>\n      <td>yes</td>\n      <td>1947</td>\n      <td>2</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>4302</th>\n      <td>271</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>Forces of Muammar Gaddafi</td>\n      <td>0.5</td>\n      <td>low</td>\n      <td>moderate</td>\n      <td>2</td>\n      <td>0</td>\n      <td>0</td>\n      <td>...</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>2</td>\n      <td>yes</td>\n      <td>2011</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>4303</th>\n      <td>271</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>Forces of Muammar Gaddafi</td>\n      <td>0.5</td>\n      <td>low</td>\n      <td>moderate</td>\n      <td>2</td>\n      <td>0</td>\n      <td>0</td>\n      <td>...</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>2</td>\n      <td>yes</td>\n      <td>2011</td>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>4304</th>\n      <td>271</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>Forces of Muammar Gaddafi</td>\n      <td>0.5</td>\n      <td>low</td>\n      <td>moderate</td>\n      <td>2</td>\n      <td>0</td>\n      <td>0</td>\n      <td>...</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>2</td>\n      <td>yes</td>\n      <td>2011</td>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>4305</th>\n      <td>271</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>Forces of Muammar Gaddafi</td>\n      <td>0.5</td>\n      <td>low</td>\n      <td>moderate</td>\n      <td>2</td>\n      <td>0</td>\n      <td>0</td>\n      <td>...</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>2</td>\n      <td>yes</td>\n      <td>2011</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>4306</th>\n      <td>271</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>Forces of Muammar Gaddafi</td>\n      <td>0.5</td>\n      <td>low</td>\n      <td>moderate</td>\n      <td>2</td>\n      <td>0</td>\n      <td>0</td>\n      <td>...</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>2</td>\n      <td>yes</td>\n      <td>2011</td>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>1</td>\n    </tr>\n  </tbody>\n</table>\n<p>4307 rows × 23 columns</p>\n</div>"
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataset"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-07T15:38:43.692956600Z",
     "start_time": "2024-08-07T15:38:43.638831200Z"
    }
   },
   "id": "8b0a6b80b62fee37"
  },
  {
   "cell_type": "markdown",
   "id": "4427a736a704d1e9",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### Democratic Regime\n",
    "The authors code their 'democratic regime' variable based on the polity2 scores found in the data, with 6 and up being considered a democratic regime. This process is repeated in the cell below, returning the results as a binary variable in place in the polity column."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "a877eb395306e936",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-07T15:37:19.088952100Z",
     "start_time": "2024-08-07T15:37:19.047765600Z"
    }
   },
   "outputs": [],
   "source": [
    "dataset['polity'] = dataset['polity'].apply(lambda x : 1 if x >= 6 else 0)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "999f735aa2901c3f",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### Target Variables\n",
    "Creates columns for coercive judicial processes (1/True if trial, exile, or purge was used), conciliatory (1/True if truth, rep, or amnesty was used), and DCJ_used (1/True if coercive or conciliatory is true)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "166eadae534fb213",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-07T15:37:42.427963100Z",
     "start_time": "2024-08-07T15:37:38.749579700Z"
    }
   },
   "outputs": [],
   "source": [
    "dataset['conciliatory'], dataset['coercive'] = pd.Series(), pd.Series()\n",
    "dataset['DCJ_used'] = pd.Series()\n",
    "for idx in dataset.index:\n",
    "    if dataset.loc[idx, 'truth'] == 1\\\n",
    "    or dataset.loc[idx, 'rep'] == 1\\\n",
    "    or dataset.loc[idx, 'amnesty'] == 1:\n",
    "        dataset['conciliatory'][idx] = 1\n",
    "        dataset['coercive'][idx] = 0\n",
    "        dataset['DCJ_used'][idx] = 1\n",
    "    elif dataset.loc[idx, 'trial'] == 1\\\n",
    "    or dataset.loc[idx, 'exile'] == 1\\\n",
    "    or dataset.loc[idx, 'purge'] == 1:\n",
    "        dataset['coercive'][idx] = 1\n",
    "        dataset['conciliatory'][idx] = 0\n",
    "        dataset['DCJ_used'][idx] = 1\n",
    "    else:\n",
    "        dataset['coercive'][idx] = 0\n",
    "        dataset['conciliatory'][idx] = 0\n",
    "        dataset['DCJ_used'][idx] = 0"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "13ae523a4a149e56",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### mobcap\n",
    "Mobility Capacity is coded, per the authors, as a binary variable with moderate and above being 1/True."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "dde162498210fbef",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:32.258608900Z",
     "start_time": "2024-08-06T12:27:32.242778900Z"
    }
   },
   "outputs": [],
   "source": [
    "mobcap_dict = {\n",
    "    'low': 0,\n",
    "    'no': 0,\n",
    "    'moderate': 1,\n",
    "    'high': 1\n",
    "}\n",
    "dataset['mobcap'].replace(mobcap_dict, inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "305bf58693437461",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### Incompatability\n",
    "Incomp is rated 1 in the original data if the incompatability is territory, and 2 if it is government. Because we're only interested in territory as the 'True' category, we'll just change the 2s to 0s."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "917d16342cbac5d5",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:32.304297800Z",
     "start_time": "2024-08-06T12:27:32.260847400Z"
    }
   },
   "outputs": [],
   "source": [
    "dataset['incomp'].replace({2:0}, inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2c6486d58a256a7c",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### Territorial Control\n",
    "This variable just needs to be converted from 'yes'/'no' to 1/0 notation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "8cd1a6dd8dae140b",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:32.306497200Z",
     "start_time": "2024-08-06T12:27:32.281622Z"
    }
   },
   "outputs": [],
   "source": [
    "dataset['terrcont'].replace({'yes': 1, 'no': 0}, inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "20c9ee1454144782",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### Cold War\n",
    "Adds a cold_war column based on whether the year is before or after 1989, as per the study"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "1aecee4f48bc5da",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:33.257081200Z",
     "start_time": "2024-08-06T12:27:32.293071800Z"
    }
   },
   "outputs": [],
   "source": [
    "dataset['cold_war'] = pd.Series()\n",
    "for idx in dataset.index:\n",
    "    if dataset['year'][idx] >= 1989: dataset['cold_war'][idx] = 0\n",
    "    else: dataset['cold_war'][idx] = 1\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a65ed0af83b5d317",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### Intensity\n",
    "The authors use a binary variable for intensity, which is coded as 1- not intense and 2- intense in the original data. We can just subtract 1 from each row to get to the binary notation we need."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "7427aa502e3f19db",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:33.268916600Z",
     "start_time": "2024-08-06T12:27:33.259382700Z"
    }
   },
   "outputs": [],
   "source": [
    "dataset['intens'] -= 1"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3879c47321fe5d50",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### Making everything True/False\n",
    "This cell codes all binary variables as boolean true/false variables to prepare the data for regression."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "85e17c7477cf8b09",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:33.599542400Z",
     "start_time": "2024-08-06T12:27:33.274478100Z"
    }
   },
   "outputs": [],
   "source": [
    "for i in ['mobcap', 'intens', 'polity', 'is_leftist_group', 'trial', 'truth', 'rep', 'amnesty', 'exile', 'purge', 'conciliatory', 'coercive', 'cold_war', 'incomp', 'terrcont', 'DCJ_used']:\n",
    "    dataset[i].replace({1: True, 0: False}, inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b0f0d7c99366dad1",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### Getting dummy columns for fightcap\n",
    "Fighting capacity remains as a 4 category column in the data, so we'll get dummies to one-hot encode the data. Each category will end up in it's own column."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "ba39db8c27722360",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:33.809379800Z",
     "start_time": "2024-08-06T12:27:33.602927400Z"
    }
   },
   "outputs": [],
   "source": [
    "dataset = pd.get_dummies(dataset, columns=['fightcap'])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ca9a86f732310265",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### Saving the clean dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "8f4e1eb751d9af7e",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:43.867250900Z",
     "start_time": "2024-08-06T12:27:43.831227800Z"
    }
   },
   "outputs": [],
   "source": [
    "dataset.to_csv('CleanData.csv')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a1d8e28ba2eaef98",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "## Modeling"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "ee7873a5f890c861",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:36.173272700Z",
     "start_time": "2024-08-06T12:27:33.929615700Z"
    }
   },
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LogisticRegression\n",
    "logreg = LogisticRegression(penalty=None)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a926c22ca21b2b5b",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### Filling NAs\n",
    "There are just a couple of NA rows in the data, we'll fill them with False."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "d705837c4f2d38f7",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:36.192775600Z",
     "start_time": "2024-08-06T12:27:36.176238400Z"
    }
   },
   "outputs": [],
   "source": [
    "dataset['terrcont'].fillna(False, inplace=True)\n",
    "dataset['mobcap'].fillna(False, inplace=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1257f1fbf2717137",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### Model 1: All DCJ Processes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "78151264e23b60d8",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:54.796279600Z",
     "start_time": "2024-08-06T12:27:54.678904800Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "LogisticRegression(penalty=None)",
      "text/html": "<style>#sk-container-id-1 {\n  /* Definition of color scheme common for light and dark mode */\n  --sklearn-color-text: black;\n  --sklearn-color-line: gray;\n  /* Definition of color scheme for unfitted estimators */\n  --sklearn-color-unfitted-level-0: #fff5e6;\n  --sklearn-color-unfitted-level-1: #f6e4d2;\n  --sklearn-color-unfitted-level-2: #ffe0b3;\n  --sklearn-color-unfitted-level-3: chocolate;\n  /* Definition of color scheme for fitted estimators */\n  --sklearn-color-fitted-level-0: #f0f8ff;\n  --sklearn-color-fitted-level-1: #d4ebff;\n  --sklearn-color-fitted-level-2: #b3dbfd;\n  --sklearn-color-fitted-level-3: cornflowerblue;\n\n  /* Specific color for light theme */\n  --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n  --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, white)));\n  --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n  --sklearn-color-icon: #696969;\n\n  @media (prefers-color-scheme: dark) {\n    /* Redefinition of color scheme for dark theme */\n    --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n    --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, #111)));\n    --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n    --sklearn-color-icon: #878787;\n  }\n}\n\n#sk-container-id-1 {\n  color: var(--sklearn-color-text);\n}\n\n#sk-container-id-1 pre {\n  padding: 0;\n}\n\n#sk-container-id-1 input.sk-hidden--visually {\n  border: 0;\n  clip: rect(1px 1px 1px 1px);\n  clip: rect(1px, 1px, 1px, 1px);\n  height: 1px;\n  margin: -1px;\n  overflow: hidden;\n  padding: 0;\n  position: absolute;\n  width: 1px;\n}\n\n#sk-container-id-1 div.sk-dashed-wrapped {\n  border: 1px dashed var(--sklearn-color-line);\n  margin: 0 0.4em 0.5em 0.4em;\n  box-sizing: border-box;\n  padding-bottom: 0.4em;\n  background-color: var(--sklearn-color-background);\n}\n\n#sk-container-id-1 div.sk-container {\n  /* jupyter's `normalize.less` sets `[hidden] { display: none; }`\n     but bootstrap.min.css set `[hidden] { display: none !important; }`\n     so we also need the `!important` here to be able to override the\n     default hidden behavior on the sphinx rendered scikit-learn.org.\n     See: https://github.com/scikit-learn/scikit-learn/issues/21755 */\n  display: inline-block !important;\n  position: relative;\n}\n\n#sk-container-id-1 div.sk-text-repr-fallback {\n  display: none;\n}\n\ndiv.sk-parallel-item,\ndiv.sk-serial,\ndiv.sk-item {\n  /* draw centered vertical line to link estimators */\n  background-image: linear-gradient(var(--sklearn-color-text-on-default-background), var(--sklearn-color-text-on-default-background));\n  background-size: 2px 100%;\n  background-repeat: no-repeat;\n  background-position: center center;\n}\n\n/* Parallel-specific style estimator block */\n\n#sk-container-id-1 div.sk-parallel-item::after {\n  content: \"\";\n  width: 100%;\n  border-bottom: 2px solid var(--sklearn-color-text-on-default-background);\n  flex-grow: 1;\n}\n\n#sk-container-id-1 div.sk-parallel {\n  display: flex;\n  align-items: stretch;\n  justify-content: center;\n  background-color: var(--sklearn-color-background);\n  position: relative;\n}\n\n#sk-container-id-1 div.sk-parallel-item {\n  display: flex;\n  flex-direction: column;\n}\n\n#sk-container-id-1 div.sk-parallel-item:first-child::after {\n  align-self: flex-end;\n  width: 50%;\n}\n\n#sk-container-id-1 div.sk-parallel-item:last-child::after {\n  align-self: flex-start;\n  width: 50%;\n}\n\n#sk-container-id-1 div.sk-parallel-item:only-child::after {\n  width: 0;\n}\n\n/* Serial-specific style estimator block */\n\n#sk-container-id-1 div.sk-serial {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  background-color: var(--sklearn-color-background);\n  padding-right: 1em;\n  padding-left: 1em;\n}\n\n\n/* Toggleable style: style used for estimator/Pipeline/ColumnTransformer box that is\nclickable and can be expanded/collapsed.\n- Pipeline and ColumnTransformer use this feature and define the default style\n- Estimators will overwrite some part of the style using the `sk-estimator` class\n*/\n\n/* Pipeline and ColumnTransformer style (default) */\n\n#sk-container-id-1 div.sk-toggleable {\n  /* Default theme specific background. It is overwritten whether we have a\n  specific estimator or a Pipeline/ColumnTransformer */\n  background-color: var(--sklearn-color-background);\n}\n\n/* Toggleable label */\n#sk-container-id-1 label.sk-toggleable__label {\n  cursor: pointer;\n  display: block;\n  width: 100%;\n  margin-bottom: 0;\n  padding: 0.5em;\n  box-sizing: border-box;\n  text-align: center;\n}\n\n#sk-container-id-1 label.sk-toggleable__label-arrow:before {\n  /* Arrow on the left of the label */\n  content: \"▸\";\n  float: left;\n  margin-right: 0.25em;\n  color: var(--sklearn-color-icon);\n}\n\n#sk-container-id-1 label.sk-toggleable__label-arrow:hover:before {\n  color: var(--sklearn-color-text);\n}\n\n/* Toggleable content - dropdown */\n\n#sk-container-id-1 div.sk-toggleable__content {\n  max-height: 0;\n  max-width: 0;\n  overflow: hidden;\n  text-align: left;\n  /* unfitted */\n  background-color: var(--sklearn-color-unfitted-level-0);\n}\n\n#sk-container-id-1 div.sk-toggleable__content.fitted {\n  /* fitted */\n  background-color: var(--sklearn-color-fitted-level-0);\n}\n\n#sk-container-id-1 div.sk-toggleable__content pre {\n  margin: 0.2em;\n  border-radius: 0.25em;\n  color: var(--sklearn-color-text);\n  /* unfitted */\n  background-color: var(--sklearn-color-unfitted-level-0);\n}\n\n#sk-container-id-1 div.sk-toggleable__content.fitted pre {\n  /* unfitted */\n  background-color: var(--sklearn-color-fitted-level-0);\n}\n\n#sk-container-id-1 input.sk-toggleable__control:checked~div.sk-toggleable__content {\n  /* Expand drop-down */\n  max-height: 200px;\n  max-width: 100%;\n  overflow: auto;\n}\n\n#sk-container-id-1 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {\n  content: \"▾\";\n}\n\n/* Pipeline/ColumnTransformer-specific style */\n\n#sk-container-id-1 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {\n  color: var(--sklearn-color-text);\n  background-color: var(--sklearn-color-unfitted-level-2);\n}\n\n#sk-container-id-1 div.sk-label.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n  background-color: var(--sklearn-color-fitted-level-2);\n}\n\n/* Estimator-specific style */\n\n/* Colorize estimator box */\n#sk-container-id-1 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {\n  /* unfitted */\n  background-color: var(--sklearn-color-unfitted-level-2);\n}\n\n#sk-container-id-1 div.sk-estimator.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n  /* fitted */\n  background-color: var(--sklearn-color-fitted-level-2);\n}\n\n#sk-container-id-1 div.sk-label label.sk-toggleable__label,\n#sk-container-id-1 div.sk-label label {\n  /* The background is the default theme color */\n  color: var(--sklearn-color-text-on-default-background);\n}\n\n/* On hover, darken the color of the background */\n#sk-container-id-1 div.sk-label:hover label.sk-toggleable__label {\n  color: var(--sklearn-color-text);\n  background-color: var(--sklearn-color-unfitted-level-2);\n}\n\n/* Label box, darken color on hover, fitted */\n#sk-container-id-1 div.sk-label.fitted:hover label.sk-toggleable__label.fitted {\n  color: var(--sklearn-color-text);\n  background-color: var(--sklearn-color-fitted-level-2);\n}\n\n/* Estimator label */\n\n#sk-container-id-1 div.sk-label label {\n  font-family: monospace;\n  font-weight: bold;\n  display: inline-block;\n  line-height: 1.2em;\n}\n\n#sk-container-id-1 div.sk-label-container {\n  text-align: center;\n}\n\n/* Estimator-specific */\n#sk-container-id-1 div.sk-estimator {\n  font-family: monospace;\n  border: 1px dotted var(--sklearn-color-border-box);\n  border-radius: 0.25em;\n  box-sizing: border-box;\n  margin-bottom: 0.5em;\n  /* unfitted */\n  background-color: var(--sklearn-color-unfitted-level-0);\n}\n\n#sk-container-id-1 div.sk-estimator.fitted {\n  /* fitted */\n  background-color: var(--sklearn-color-fitted-level-0);\n}\n\n/* on hover */\n#sk-container-id-1 div.sk-estimator:hover {\n  /* unfitted */\n  background-color: var(--sklearn-color-unfitted-level-2);\n}\n\n#sk-container-id-1 div.sk-estimator.fitted:hover {\n  /* fitted */\n  background-color: var(--sklearn-color-fitted-level-2);\n}\n\n/* Specification for estimator info (e.g. \"i\" and \"?\") */\n\n/* Common style for \"i\" and \"?\" */\n\n.sk-estimator-doc-link,\na:link.sk-estimator-doc-link,\na:visited.sk-estimator-doc-link {\n  float: right;\n  font-size: smaller;\n  line-height: 1em;\n  font-family: monospace;\n  background-color: var(--sklearn-color-background);\n  border-radius: 1em;\n  height: 1em;\n  width: 1em;\n  text-decoration: none !important;\n  margin-left: 1ex;\n  /* unfitted */\n  border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n  color: var(--sklearn-color-unfitted-level-1);\n}\n\n.sk-estimator-doc-link.fitted,\na:link.sk-estimator-doc-link.fitted,\na:visited.sk-estimator-doc-link.fitted {\n  /* fitted */\n  border: var(--sklearn-color-fitted-level-1) 1pt solid;\n  color: var(--sklearn-color-fitted-level-1);\n}\n\n/* On hover */\ndiv.sk-estimator:hover .sk-estimator-doc-link:hover,\n.sk-estimator-doc-link:hover,\ndiv.sk-label-container:hover .sk-estimator-doc-link:hover,\n.sk-estimator-doc-link:hover {\n  /* unfitted */\n  background-color: var(--sklearn-color-unfitted-level-3);\n  color: var(--sklearn-color-background);\n  text-decoration: none;\n}\n\ndiv.sk-estimator.fitted:hover .sk-estimator-doc-link.fitted:hover,\n.sk-estimator-doc-link.fitted:hover,\ndiv.sk-label-container:hover .sk-estimator-doc-link.fitted:hover,\n.sk-estimator-doc-link.fitted:hover {\n  /* fitted */\n  background-color: var(--sklearn-color-fitted-level-3);\n  color: var(--sklearn-color-background);\n  text-decoration: none;\n}\n\n/* Span, style for the box shown on hovering the info icon */\n.sk-estimator-doc-link span {\n  display: none;\n  z-index: 9999;\n  position: relative;\n  font-weight: normal;\n  right: .2ex;\n  padding: .5ex;\n  margin: .5ex;\n  width: min-content;\n  min-width: 20ex;\n  max-width: 50ex;\n  color: var(--sklearn-color-text);\n  box-shadow: 2pt 2pt 4pt #999;\n  /* unfitted */\n  background: var(--sklearn-color-unfitted-level-0);\n  border: .5pt solid var(--sklearn-color-unfitted-level-3);\n}\n\n.sk-estimator-doc-link.fitted span {\n  /* fitted */\n  background: var(--sklearn-color-fitted-level-0);\n  border: var(--sklearn-color-fitted-level-3);\n}\n\n.sk-estimator-doc-link:hover span {\n  display: block;\n}\n\n/* \"?\"-specific style due to the `<a>` HTML tag */\n\n#sk-container-id-1 a.estimator_doc_link {\n  float: right;\n  font-size: 1rem;\n  line-height: 1em;\n  font-family: monospace;\n  background-color: var(--sklearn-color-background);\n  border-radius: 1rem;\n  height: 1rem;\n  width: 1rem;\n  text-decoration: none;\n  /* unfitted */\n  color: var(--sklearn-color-unfitted-level-1);\n  border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n}\n\n#sk-container-id-1 a.estimator_doc_link.fitted {\n  /* fitted */\n  border: var(--sklearn-color-fitted-level-1) 1pt solid;\n  color: var(--sklearn-color-fitted-level-1);\n}\n\n/* On hover */\n#sk-container-id-1 a.estimator_doc_link:hover {\n  /* unfitted */\n  background-color: var(--sklearn-color-unfitted-level-3);\n  color: var(--sklearn-color-background);\n  text-decoration: none;\n}\n\n#sk-container-id-1 a.estimator_doc_link.fitted:hover {\n  /* fitted */\n  background-color: var(--sklearn-color-fitted-level-3);\n}\n</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>LogisticRegression(penalty=None)</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator fitted sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-1\" type=\"checkbox\" checked><label for=\"sk-estimator-id-1\" class=\"sk-toggleable__label fitted sk-toggleable__label-arrow fitted\">&nbsp;&nbsp;LogisticRegression<a class=\"sk-estimator-doc-link fitted\" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.5/modules/generated/sklearn.linear_model.LogisticRegression.html\">?<span>Documentation for LogisticRegression</span></a><span class=\"sk-estimator-doc-link fitted\">i<span>Fitted</span></span></label><div class=\"sk-toggleable__content fitted\"><pre>LogisticRegression(penalty=None)</pre></div> </div></div></div></div>"
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "logreg.fit(dataset[['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']], dataset['DCJ_used'], sample_weight=dataset['model_weight'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "8b70f303fbf9451c",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:54.976560300Z",
     "start_time": "2024-08-06T12:27:54.954159600Z"
    }
   },
   "outputs": [],
   "source": [
    "coefs = pd.DataFrame(logreg.coef_)\n",
    "for i in range(11):\n",
    "    coefs.rename({i: ['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war'][i]}, axis=1, inplace=True)\n",
    "coefs.index = ['All DCJ Processes']"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "84f123c126099fbc",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### Model 2: Conciliatory Process Use"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "97fe74e0f6453079",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:55.478557800Z",
     "start_time": "2024-08-06T12:27:55.432200500Z"
    }
   },
   "outputs": [],
   "source": [
    "logreg2 = LogisticRegression(penalty=None)\n",
    "logreg2.fit(dataset[['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']], dataset['conciliatory'], sample_weight=dataset['model_weight'])\n",
    "coefs2 = pd.DataFrame(logreg2.coef_)\n",
    "for i in range(11):\n",
    "    coefs2.rename({i: ['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war'][i]}, axis=1, inplace=True)\n",
    "coefs2.index = ['Conciliatory Processes']"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6a09b2ec23b84199",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### Model 3: Coercive Process Use"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "de770af16ab8e3a",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:55.840764800Z",
     "start_time": "2024-08-06T12:27:55.791184500Z"
    }
   },
   "outputs": [],
   "source": [
    "logreg3 = LogisticRegression(penalty=None)\n",
    "logreg3.fit(dataset[['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']], dataset['coercive'], sample_weight=dataset['model_weight'])\n",
    "coefs3 = pd.DataFrame(logreg3.coef_)\n",
    "for i in range(11):\n",
    "    coefs3.rename({i: ['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war'][i]}, axis=1, inplace=True)\n",
    "coefs3.index = ['Coercive Processes']"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "52735e49b7d89bde",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### Model 4: Conciliatory Processes vs. Coercive Processes\n",
    "These next two analyses only includes rows where a DCJ was used, and in order to compare conciliatory process use directly to coercive process use among conflict years where a DCJ was used."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "b9ae824a7610a445",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:56.163794900Z",
     "start_time": "2024-08-06T12:27:56.081042300Z"
    }
   },
   "outputs": [],
   "source": [
    "dataset2 = dataset[dataset['DCJ_used'] == True]\n",
    "logreg4 = LogisticRegression(penalty=None)\n",
    "logreg4.fit(dataset2[['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']], dataset2['conciliatory'], sample_weight=dataset2['model_weight'])\n",
    "coefs4 = pd.DataFrame(logreg4.coef_)\n",
    "for i in range(11):\n",
    "    coefs4.rename({i: ['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war'][i]}, axis=1, inplace=True)\n",
    "coefs4.index = ['Conciliatory Processes vs. Coercive']"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cfac3c94ffbadaa0",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "### Model 5: Coercive processes vs. Conciliatory processes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "4f82bb422f643d5d",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:56.470157800Z",
     "start_time": "2024-08-06T12:27:56.396326900Z"
    }
   },
   "outputs": [],
   "source": [
    "logreg5 = LogisticRegression(penalty=None)\n",
    "logreg5.fit(dataset2[['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']], dataset2['coercive'], sample_weight=dataset2['model_weight'])\n",
    "coefs5 = pd.DataFrame(logreg5.coef_)\n",
    "for i in range(11):\n",
    "    coefs5.rename({i: ['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war'][i]}, axis=1, inplace=True)\n",
    "coefs5.index = ['Coercive Processes vs. Conciliatory']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "258d9352cadfba76",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:56.570906100Z",
     "start_time": "2024-08-06T12:27:56.559680200Z"
    }
   },
   "outputs": [],
   "source": [
    "coefs['constant'] = logreg.intercept_\n",
    "coefs2['constant'] = logreg2.intercept_\n",
    "coefs3['constant'] = logreg3.intercept_\n",
    "coefs4['constant'] = logreg4.intercept_\n",
    "coefs5['constant'] = logreg5.intercept_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "c2da3e658a014245",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:56.752230800Z",
     "start_time": "2024-08-06T12:27:56.720077200Z"
    }
   },
   "outputs": [],
   "source": [
    "from sklearn.metrics import log_loss\n",
    "coefs['log_likelihood'] = -log_loss(logreg.predict(dataset[['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']]), dataset['DCJ_used'])\n",
    "coefs2['log_likelihood'] = -log_loss(logreg2.predict(dataset[['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']]), dataset['conciliatory'])\n",
    "coefs3['log_likelihood'] = -log_loss(logreg3.predict(dataset[['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']]), dataset['coercive'])\n",
    "coefs4['log_likelihood'] = -log_loss(logreg4.predict(dataset2[['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']]), dataset2['conciliatory'])\n",
    "coefs5['log_likelihood'] = -log_loss(logreg5.predict(dataset2[['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']]), dataset2['coercive'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "310ca1c3a0879f4f",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:56.941387200Z",
     "start_time": "2024-08-06T12:27:56.923974900Z"
    }
   },
   "outputs": [],
   "source": [
    "results = pd.concat([coefs, coefs2, coefs3, coefs4, coefs5]).T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "b1c38ff3eb412c4a",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:27:57.492291200Z",
     "start_time": "2024-08-06T12:27:57.460786600Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "                          1         2          3          4          5\nmobcap             0.661976  0.388605   0.241040   0.240883  -0.240883\nfightcap_high     -0.449099  0.457280  -0.829236   0.958880  -0.958879\nfightcap_moderate  0.103389 -0.053578   0.222631  -0.200837   0.200837\nfightcap_low       0.167188 -0.516068   0.515424  -0.650171   0.650172\nintens             0.634839  0.191754   0.336639  -0.070971   0.070971\npolity             1.551596 -0.125052   1.304639  -0.743485   0.743485\nis_leftist_group  -0.472057 -0.310735  -0.119309  -0.307852   0.307852\nincomp            -0.976216 -0.347354  -0.527997  -0.059748   0.059748\nterrcont          -0.769757  0.134406  -0.792893   0.599034  -0.599034\nyear_of_conflict   0.079885  0.024635   0.030991   0.014480  -0.014480\ncold_war          -1.734773 -0.812434  -0.942777   0.049247  -0.049247\nconstant           0.788109 -0.868502  -0.627620  -0.231353   0.231352\nlog_likelihood    -7.054748 -7.121697 -10.276667 -10.238452 -10.238452",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>1</th>\n      <th>2</th>\n      <th>3</th>\n      <th>4</th>\n      <th>5</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>mobcap</th>\n      <td>0.661976</td>\n      <td>0.388605</td>\n      <td>0.241040</td>\n      <td>0.240883</td>\n      <td>-0.240883</td>\n    </tr>\n    <tr>\n      <th>fightcap_high</th>\n      <td>-0.449099</td>\n      <td>0.457280</td>\n      <td>-0.829236</td>\n      <td>0.958880</td>\n      <td>-0.958879</td>\n    </tr>\n    <tr>\n      <th>fightcap_moderate</th>\n      <td>0.103389</td>\n      <td>-0.053578</td>\n      <td>0.222631</td>\n      <td>-0.200837</td>\n      <td>0.200837</td>\n    </tr>\n    <tr>\n      <th>fightcap_low</th>\n      <td>0.167188</td>\n      <td>-0.516068</td>\n      <td>0.515424</td>\n      <td>-0.650171</td>\n      <td>0.650172</td>\n    </tr>\n    <tr>\n      <th>intens</th>\n      <td>0.634839</td>\n      <td>0.191754</td>\n      <td>0.336639</td>\n      <td>-0.070971</td>\n      <td>0.070971</td>\n    </tr>\n    <tr>\n      <th>polity</th>\n      <td>1.551596</td>\n      <td>-0.125052</td>\n      <td>1.304639</td>\n      <td>-0.743485</td>\n      <td>0.743485</td>\n    </tr>\n    <tr>\n      <th>is_leftist_group</th>\n      <td>-0.472057</td>\n      <td>-0.310735</td>\n      <td>-0.119309</td>\n      <td>-0.307852</td>\n      <td>0.307852</td>\n    </tr>\n    <tr>\n      <th>incomp</th>\n      <td>-0.976216</td>\n      <td>-0.347354</td>\n      <td>-0.527997</td>\n      <td>-0.059748</td>\n      <td>0.059748</td>\n    </tr>\n    <tr>\n      <th>terrcont</th>\n      <td>-0.769757</td>\n      <td>0.134406</td>\n      <td>-0.792893</td>\n      <td>0.599034</td>\n      <td>-0.599034</td>\n    </tr>\n    <tr>\n      <th>year_of_conflict</th>\n      <td>0.079885</td>\n      <td>0.024635</td>\n      <td>0.030991</td>\n      <td>0.014480</td>\n      <td>-0.014480</td>\n    </tr>\n    <tr>\n      <th>cold_war</th>\n      <td>-1.734773</td>\n      <td>-0.812434</td>\n      <td>-0.942777</td>\n      <td>0.049247</td>\n      <td>-0.049247</td>\n    </tr>\n    <tr>\n      <th>constant</th>\n      <td>0.788109</td>\n      <td>-0.868502</td>\n      <td>-0.627620</td>\n      <td>-0.231353</td>\n      <td>0.231352</td>\n    </tr>\n    <tr>\n      <th>log_likelihood</th>\n      <td>-7.054748</td>\n      <td>-7.121697</td>\n      <td>-10.276667</td>\n      <td>-10.238452</td>\n      <td>-10.238452</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "outputs": [],
   "source": [
    "dataset3 = dataset[dataset['conciliatory'] == True]\n",
    "logreg6 = LogisticRegression(penalty=None)\n",
    "logreg6.fit(dataset3[\n",
    "                ['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group',\n",
    "                 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']], dataset3['truth'],\n",
    "            sample_weight=dataset3['model_weight'])\n",
    "coefs6 = pd.DataFrame(logreg6.coef_)\n",
    "for i in range(11):\n",
    "    coefs6.rename({i: ['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity',\n",
    "                       'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war'][i]}, axis=1,\n",
    "                  inplace=True)\n",
    "coefs6.index = ['Truth Commissions']"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:39:09.528207200Z",
     "start_time": "2024-08-06T12:39:09.467856400Z"
    }
   },
   "id": "456b2a60df1ffaa7"
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "outputs": [],
   "source": [
    "logreg7 = LogisticRegression(penalty=None)\n",
    "logreg7.fit(dataset3[\n",
    "                ['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group',\n",
    "                 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']], dataset3['rep'],\n",
    "            sample_weight=dataset3['model_weight'])\n",
    "coefs7 = pd.DataFrame(logreg7.coef_)\n",
    "for i in range(11):\n",
    "    coefs7.rename({i: ['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity',\n",
    "                       'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war'][i]}, axis=1,\n",
    "                  inplace=True)\n",
    "coefs7.index = ['Reparations']"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:39:10.244148700Z",
     "start_time": "2024-08-06T12:39:10.196017900Z"
    }
   },
   "id": "5c4e4b2e5d1737cf"
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "outputs": [],
   "source": [
    "logreg8 = LogisticRegression(penalty=None)\n",
    "logreg8.fit(dataset3[\n",
    "                ['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group',\n",
    "                 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']], dataset3['amnesty'],\n",
    "            sample_weight=dataset3['model_weight'])\n",
    "coefs8 = pd.DataFrame(logreg8.coef_)\n",
    "for i in range(11):\n",
    "    coefs8.rename({i: ['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity',\n",
    "                       'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war'][i]}, axis=1,\n",
    "                  inplace=True)\n",
    "coefs8.index = ['Amnesty']"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:39:10.374730400Z",
     "start_time": "2024-08-06T12:39:10.330745300Z"
    }
   },
   "id": "3dd316ba17d721ec"
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "outputs": [],
   "source": [
    "dataset4 = dataset[dataset['coercive'] == True]\n",
    "logreg9 = LogisticRegression(penalty=None)\n",
    "logreg9.fit(dataset4[\n",
    "                ['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group',\n",
    "                 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']], dataset4['trial'],\n",
    "            sample_weight=dataset4['model_weight'])\n",
    "coefs9 = pd.DataFrame(logreg9.coef_)\n",
    "for i in range(11):\n",
    "    coefs9.rename({i: ['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity',\n",
    "                       'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war'][i]}, axis=1,\n",
    "                  inplace=True)\n",
    "coefs9.index = ['Trials']"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:39:10.549633100Z",
     "start_time": "2024-08-06T12:39:10.480849700Z"
    }
   },
   "id": "9a91509167d64ef9"
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "outputs": [],
   "source": [
    "logreg10 = LogisticRegression(penalty=None)\n",
    "logreg10.fit(dataset4[\n",
    "                ['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group',\n",
    "                 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']], dataset4['exile'],\n",
    "            sample_weight=dataset4['model_weight'])\n",
    "coefs10 = pd.DataFrame(logreg10.coef_)\n",
    "for i in range(11):\n",
    "    coefs10.rename({i: ['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity',\n",
    "                       'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war'][i]}, axis=1,\n",
    "                  inplace=True)\n",
    "coefs10.index = ['Exiles']"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:39:10.736878300Z",
     "start_time": "2024-08-06T12:39:10.655150900Z"
    }
   },
   "id": "d64e1c3ac05946e8"
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "outputs": [],
   "source": [
    "logreg11 = LogisticRegression(penalty=None)\n",
    "logreg11.fit(dataset4[\n",
    "                ['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group',\n",
    "                 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']], dataset4['purge'],\n",
    "            sample_weight=dataset4['model_weight'])\n",
    "coefs11 = pd.DataFrame(logreg11.coef_)\n",
    "for i in range(11):\n",
    "    coefs11.rename({i: ['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity',\n",
    "                       'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war'][i]}, axis=1,\n",
    "                  inplace=True)\n",
    "coefs11.index = ['Purges']"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:39:10.878848700Z",
     "start_time": "2024-08-06T12:39:10.836761900Z"
    }
   },
   "id": "abfcba61a50926d1"
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "outputs": [],
   "source": [
    "coefs6['constant'] = logreg6.intercept_\n",
    "coefs7['constant'] = logreg7.intercept_\n",
    "coefs8['constant'] = logreg8.intercept_\n",
    "coefs9['constant'] = logreg9.intercept_\n",
    "coefs10['constant'] = logreg10.intercept_\n",
    "coefs11['constant'] = logreg11.intercept_"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:39:10.999932100Z",
     "start_time": "2024-08-06T12:39:10.978360800Z"
    }
   },
   "id": "b963b63141b61d41"
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "outputs": [
    {
     "data": {
      "text/plain": "      acdid location  sidea                      sideb  model_weight  mobcap  \\\n31        6     Iran   Iran                       KDPI           1.0   False   \n32        6     Iran   Iran                       KDPI           1.0   False   \n33        6     Iran   Iran                       KDPI           1.0   False   \n34        6     Iran   Iran                       KDPI           1.0   False   \n43        6     Iran   Iran                       KDPI           1.0   False   \n...     ...      ...    ...                        ...           ...     ...   \n4295    271    Libya  Libya                        NTC           0.5    True   \n4298    271    Libya  Libya                        NTC           0.5    True   \n4301    271    Libya  Libya  Forces of Muammar Gaddafi           0.5   False   \n4302    271    Libya  Libya  Forces of Muammar Gaddafi           0.5   False   \n4305    271    Libya  Libya  Forces of Muammar Gaddafi           0.5   False   \n\n      intens  polity  is_leftist_group  trial  ...  terrcont  year  \\\n31      True   False             False  False  ...     False  1979   \n32      True   False             False  False  ...      True  1979   \n33      True   False             False  False  ...     False  1979   \n34      True   False             False  False  ...      True  1979   \n43     False   False             False  False  ...     False  1984   \n...      ...     ...               ...    ...  ...       ...   ...   \n4295    True   False             False  False  ...      True  2011   \n4298    True   False             False  False  ...      True  2011   \n4301    True   False             False  False  ...      True  2011   \n4302    True   False             False  False  ...      True  2011   \n4305    True   False             False  False  ...      True  2011   \n\n      year_of_conflict  conciliatory  coercive  DCJ_used  cold_war  \\\n31                   1          True     False      True      True   \n32                   1          True     False      True      True   \n33                   1          True     False      True      True   \n34                   1          True     False      True      True   \n43                   6          True     False      True      True   \n...                ...           ...       ...       ...       ...   \n4295                 1          True     False      True     False   \n4298                 1          True     False      True     False   \n4301                 1          True     False      True     False   \n4302                 1          True     False      True     False   \n4305                 1          True     False      True     False   \n\n      fightcap_high fightcap_low  fightcap_moderate  \n31            False         True              False  \n32            False         True              False  \n33            False         True              False  \n34            False         True              False  \n43            False         True              False  \n...             ...          ...                ...  \n4295          False        False               True  \n4298          False        False               True  \n4301          False        False               True  \n4302          False        False               True  \n4305          False        False               True  \n\n[848 rows x 26 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>acdid</th>\n      <th>location</th>\n      <th>sidea</th>\n      <th>sideb</th>\n      <th>model_weight</th>\n      <th>mobcap</th>\n      <th>intens</th>\n      <th>polity</th>\n      <th>is_leftist_group</th>\n      <th>trial</th>\n      <th>...</th>\n      <th>terrcont</th>\n      <th>year</th>\n      <th>year_of_conflict</th>\n      <th>conciliatory</th>\n      <th>coercive</th>\n      <th>DCJ_used</th>\n      <th>cold_war</th>\n      <th>fightcap_high</th>\n      <th>fightcap_low</th>\n      <th>fightcap_moderate</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>31</th>\n      <td>6</td>\n      <td>Iran</td>\n      <td>Iran</td>\n      <td>KDPI</td>\n      <td>1.0</td>\n      <td>False</td>\n      <td>True</td>\n      <td>False</td>\n      <td>False</td>\n      <td>False</td>\n      <td>...</td>\n      <td>False</td>\n      <td>1979</td>\n      <td>1</td>\n      <td>True</td>\n      <td>False</td>\n      <td>True</td>\n      <td>True</td>\n      <td>False</td>\n      <td>True</td>\n      <td>False</td>\n    </tr>\n    <tr>\n      <th>32</th>\n      <td>6</td>\n      <td>Iran</td>\n      <td>Iran</td>\n      <td>KDPI</td>\n      <td>1.0</td>\n      <td>False</td>\n      <td>True</td>\n      <td>False</td>\n      <td>False</td>\n      <td>False</td>\n      <td>...</td>\n      <td>True</td>\n      <td>1979</td>\n      <td>1</td>\n      <td>True</td>\n      <td>False</td>\n      <td>True</td>\n      <td>True</td>\n      <td>False</td>\n      <td>True</td>\n      <td>False</td>\n    </tr>\n    <tr>\n      <th>33</th>\n      <td>6</td>\n      <td>Iran</td>\n      <td>Iran</td>\n      <td>KDPI</td>\n      <td>1.0</td>\n      <td>False</td>\n      <td>True</td>\n      <td>False</td>\n      <td>False</td>\n      <td>False</td>\n      <td>...</td>\n      <td>False</td>\n      <td>1979</td>\n      <td>1</td>\n      <td>True</td>\n      <td>False</td>\n      <td>True</td>\n      <td>True</td>\n      <td>False</td>\n      <td>True</td>\n      <td>False</td>\n    </tr>\n    <tr>\n      <th>34</th>\n      <td>6</td>\n      <td>Iran</td>\n      <td>Iran</td>\n      <td>KDPI</td>\n      <td>1.0</td>\n      <td>False</td>\n      <td>True</td>\n      <td>False</td>\n      <td>False</td>\n      <td>False</td>\n      <td>...</td>\n      <td>True</td>\n      <td>1979</td>\n      <td>1</td>\n      <td>True</td>\n      <td>False</td>\n      <td>True</td>\n      <td>True</td>\n      <td>False</td>\n      <td>True</td>\n      <td>False</td>\n    </tr>\n    <tr>\n      <th>43</th>\n      <td>6</td>\n      <td>Iran</td>\n      <td>Iran</td>\n      <td>KDPI</td>\n      <td>1.0</td>\n      <td>False</td>\n      <td>False</td>\n      <td>False</td>\n      <td>False</td>\n      <td>False</td>\n      <td>...</td>\n      <td>False</td>\n      <td>1984</td>\n      <td>6</td>\n      <td>True</td>\n      <td>False</td>\n      <td>True</td>\n      <td>True</td>\n      <td>False</td>\n      <td>True</td>\n      <td>False</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>4295</th>\n      <td>271</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>NTC</td>\n      <td>0.5</td>\n      <td>True</td>\n      <td>True</td>\n      <td>False</td>\n      <td>False</td>\n      <td>False</td>\n      <td>...</td>\n      <td>True</td>\n      <td>2011</td>\n      <td>1</td>\n      <td>True</td>\n      <td>False</td>\n      <td>True</td>\n      <td>False</td>\n      <td>False</td>\n      <td>False</td>\n      <td>True</td>\n    </tr>\n    <tr>\n      <th>4298</th>\n      <td>271</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>NTC</td>\n      <td>0.5</td>\n      <td>True</td>\n      <td>True</td>\n      <td>False</td>\n      <td>False</td>\n      <td>False</td>\n      <td>...</td>\n      <td>True</td>\n      <td>2011</td>\n      <td>1</td>\n      <td>True</td>\n      <td>False</td>\n      <td>True</td>\n      <td>False</td>\n      <td>False</td>\n      <td>False</td>\n      <td>True</td>\n    </tr>\n    <tr>\n      <th>4301</th>\n      <td>271</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>Forces of Muammar Gaddafi</td>\n      <td>0.5</td>\n      <td>False</td>\n      <td>True</td>\n      <td>False</td>\n      <td>False</td>\n      <td>False</td>\n      <td>...</td>\n      <td>True</td>\n      <td>2011</td>\n      <td>1</td>\n      <td>True</td>\n      <td>False</td>\n      <td>True</td>\n      <td>False</td>\n      <td>False</td>\n      <td>False</td>\n      <td>True</td>\n    </tr>\n    <tr>\n      <th>4302</th>\n      <td>271</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>Forces of Muammar Gaddafi</td>\n      <td>0.5</td>\n      <td>False</td>\n      <td>True</td>\n      <td>False</td>\n      <td>False</td>\n      <td>False</td>\n      <td>...</td>\n      <td>True</td>\n      <td>2011</td>\n      <td>1</td>\n      <td>True</td>\n      <td>False</td>\n      <td>True</td>\n      <td>False</td>\n      <td>False</td>\n      <td>False</td>\n      <td>True</td>\n    </tr>\n    <tr>\n      <th>4305</th>\n      <td>271</td>\n      <td>Libya</td>\n      <td>Libya</td>\n      <td>Forces of Muammar Gaddafi</td>\n      <td>0.5</td>\n      <td>False</td>\n      <td>True</td>\n      <td>False</td>\n      <td>False</td>\n      <td>False</td>\n      <td>...</td>\n      <td>True</td>\n      <td>2011</td>\n      <td>1</td>\n      <td>True</td>\n      <td>False</td>\n      <td>True</td>\n      <td>False</td>\n      <td>False</td>\n      <td>False</td>\n      <td>True</td>\n    </tr>\n  </tbody>\n</table>\n<p>848 rows × 26 columns</p>\n</div>"
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataset3"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:40:04.065696900Z",
     "start_time": "2024-08-06T12:40:03.969752500Z"
    }
   },
   "id": "baba14b6bc7a6f41"
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "outputs": [],
   "source": [
    "coefs6['log_likelihood'] = -log_loss(y_pred=logreg6.predict(dataset3[['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']]), y_true=dataset3['truth'], labels=[True, False])\n",
    "coefs7['log_likelihood'] = -log_loss(logreg7.predict(dataset3[['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']]), dataset3['rep'])\n",
    "coefs8['log_likelihood'] = -log_loss(logreg8.predict(dataset3[['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']]), dataset3['amnesty'])\n",
    "coefs9['log_likelihood'] = -log_loss(logreg9.predict(dataset4[['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']]), dataset4['trial'], labels=[True, False])\n",
    "coefs10['log_likelihood'] = -log_loss(logreg10.predict(dataset4[['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']]), dataset4['exile'], labels=[True, False])\n",
    "coefs11['log_likelihood'] = -log_loss(logreg11.predict(dataset4[['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']]), dataset4['purge'], labels=[True, False])"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:48:20.663890200Z",
     "start_time": "2024-08-06T12:48:20.623128200Z"
    }
   },
   "id": "9a01cbd01b32fc4b"
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "outputs": [],
   "source": [
    "results = pd.concat([coefs, coefs2, coefs3, coefs4, coefs5, coefs6, coefs7, coefs8, coefs9, coefs10, coefs11]).T"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:48:23.897784500Z",
     "start_time": "2024-08-06T12:48:23.874977Z"
    }
   },
   "id": "19ab6857807e8d6f"
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "outputs": [
    {
     "data": {
      "text/plain": "                          1         2          3          4          5  \\\nmobcap             0.661976  0.388605   0.241040   0.240883  -0.240883   \nfightcap_high     -0.449099  0.457280  -0.829236   0.958880  -0.958879   \nfightcap_moderate  0.103389 -0.053578   0.222631  -0.200837   0.200837   \nfightcap_low       0.167188 -0.516068   0.515424  -0.650171   0.650172   \nintens             0.634839  0.191754   0.336639  -0.070971   0.070971   \npolity             1.551596 -0.125052   1.304639  -0.743485   0.743485   \nis_leftist_group  -0.472057 -0.310735  -0.119309  -0.307852   0.307852   \nincomp            -0.976216 -0.347354  -0.527997  -0.059748   0.059748   \nterrcont          -0.769757  0.134406  -0.792893   0.599034  -0.599034   \nyear_of_conflict   0.079885  0.024635   0.030991   0.014480  -0.014480   \ncold_war          -1.734773 -0.812434  -0.942777   0.049247  -0.049247   \nconstant           0.788109 -0.868502  -0.627620  -0.231353   0.231352   \nlog_likelihood    -7.054748 -7.121697 -10.276667 -10.238452 -10.238452   \n\n                   Truth Commissions  Reparations    Amnesty    Trials  \\\nmobcap                      0.388710     0.115131  -0.258683  0.490600   \nfightcap_high               9.692238    -1.852436   0.296176 -1.269715   \nfightcap_moderate           8.170877    -0.838711   0.501842 -0.671203   \nfightcap_low                8.116678    -1.293090   0.898837 -0.252559   \nintens                      0.289315     0.222522  -0.324709 -0.351910   \npolity                      0.703958     0.497264  -0.732421  0.362496   \nis_leftist_group           -1.536770     0.749356  -0.194584  0.710211   \nincomp                      0.043450     0.155515  -0.156774 -0.032337   \nterrcont                   -0.333139    -0.730111   0.747777 -0.112496   \nyear_of_conflict            0.018288     0.026035  -0.029845 -0.003418   \ncold_war                   -0.255991    -0.913336   0.816814 -0.473723   \nconstant                  -10.741586    -0.221894   0.217306  2.356162   \nlog_likelihood             -3.910396    -8.500862 -11.986215 -3.190586   \n\n                     Exiles    Purges  \nmobcap            -0.475132 -0.460048  \nfightcap_high     -4.782811  7.576780  \nfightcap_moderate -0.996337  6.767420  \nfightcap_low      -0.554519  5.739381  \nintens             0.299519  0.431241  \npolity            -0.065839 -0.673826  \nis_leftist_group  -1.167977 -0.176958  \nincomp             0.021043 -0.007348  \nterrcont           0.529108 -0.322486  \nyear_of_conflict   0.015373 -0.016281  \ncold_war           0.546352  0.361043  \nconstant          -2.356438 -8.609149  \nlog_likelihood    -1.678381 -1.512205  ",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>1</th>\n      <th>2</th>\n      <th>3</th>\n      <th>4</th>\n      <th>5</th>\n      <th>Truth Commissions</th>\n      <th>Reparations</th>\n      <th>Amnesty</th>\n      <th>Trials</th>\n      <th>Exiles</th>\n      <th>Purges</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>mobcap</th>\n      <td>0.661976</td>\n      <td>0.388605</td>\n      <td>0.241040</td>\n      <td>0.240883</td>\n      <td>-0.240883</td>\n      <td>0.388710</td>\n      <td>0.115131</td>\n      <td>-0.258683</td>\n      <td>0.490600</td>\n      <td>-0.475132</td>\n      <td>-0.460048</td>\n    </tr>\n    <tr>\n      <th>fightcap_high</th>\n      <td>-0.449099</td>\n      <td>0.457280</td>\n      <td>-0.829236</td>\n      <td>0.958880</td>\n      <td>-0.958879</td>\n      <td>9.692238</td>\n      <td>-1.852436</td>\n      <td>0.296176</td>\n      <td>-1.269715</td>\n      <td>-4.782811</td>\n      <td>7.576780</td>\n    </tr>\n    <tr>\n      <th>fightcap_moderate</th>\n      <td>0.103389</td>\n      <td>-0.053578</td>\n      <td>0.222631</td>\n      <td>-0.200837</td>\n      <td>0.200837</td>\n      <td>8.170877</td>\n      <td>-0.838711</td>\n      <td>0.501842</td>\n      <td>-0.671203</td>\n      <td>-0.996337</td>\n      <td>6.767420</td>\n    </tr>\n    <tr>\n      <th>fightcap_low</th>\n      <td>0.167188</td>\n      <td>-0.516068</td>\n      <td>0.515424</td>\n      <td>-0.650171</td>\n      <td>0.650172</td>\n      <td>8.116678</td>\n      <td>-1.293090</td>\n      <td>0.898837</td>\n      <td>-0.252559</td>\n      <td>-0.554519</td>\n      <td>5.739381</td>\n    </tr>\n    <tr>\n      <th>intens</th>\n      <td>0.634839</td>\n      <td>0.191754</td>\n      <td>0.336639</td>\n      <td>-0.070971</td>\n      <td>0.070971</td>\n      <td>0.289315</td>\n      <td>0.222522</td>\n      <td>-0.324709</td>\n      <td>-0.351910</td>\n      <td>0.299519</td>\n      <td>0.431241</td>\n    </tr>\n    <tr>\n      <th>polity</th>\n      <td>1.551596</td>\n      <td>-0.125052</td>\n      <td>1.304639</td>\n      <td>-0.743485</td>\n      <td>0.743485</td>\n      <td>0.703958</td>\n      <td>0.497264</td>\n      <td>-0.732421</td>\n      <td>0.362496</td>\n      <td>-0.065839</td>\n      <td>-0.673826</td>\n    </tr>\n    <tr>\n      <th>is_leftist_group</th>\n      <td>-0.472057</td>\n      <td>-0.310735</td>\n      <td>-0.119309</td>\n      <td>-0.307852</td>\n      <td>0.307852</td>\n      <td>-1.536770</td>\n      <td>0.749356</td>\n      <td>-0.194584</td>\n      <td>0.710211</td>\n      <td>-1.167977</td>\n      <td>-0.176958</td>\n    </tr>\n    <tr>\n      <th>incomp</th>\n      <td>-0.976216</td>\n      <td>-0.347354</td>\n      <td>-0.527997</td>\n      <td>-0.059748</td>\n      <td>0.059748</td>\n      <td>0.043450</td>\n      <td>0.155515</td>\n      <td>-0.156774</td>\n      <td>-0.032337</td>\n      <td>0.021043</td>\n      <td>-0.007348</td>\n    </tr>\n    <tr>\n      <th>terrcont</th>\n      <td>-0.769757</td>\n      <td>0.134406</td>\n      <td>-0.792893</td>\n      <td>0.599034</td>\n      <td>-0.599034</td>\n      <td>-0.333139</td>\n      <td>-0.730111</td>\n      <td>0.747777</td>\n      <td>-0.112496</td>\n      <td>0.529108</td>\n      <td>-0.322486</td>\n    </tr>\n    <tr>\n      <th>year_of_conflict</th>\n      <td>0.079885</td>\n      <td>0.024635</td>\n      <td>0.030991</td>\n      <td>0.014480</td>\n      <td>-0.014480</td>\n      <td>0.018288</td>\n      <td>0.026035</td>\n      <td>-0.029845</td>\n      <td>-0.003418</td>\n      <td>0.015373</td>\n      <td>-0.016281</td>\n    </tr>\n    <tr>\n      <th>cold_war</th>\n      <td>-1.734773</td>\n      <td>-0.812434</td>\n      <td>-0.942777</td>\n      <td>0.049247</td>\n      <td>-0.049247</td>\n      <td>-0.255991</td>\n      <td>-0.913336</td>\n      <td>0.816814</td>\n      <td>-0.473723</td>\n      <td>0.546352</td>\n      <td>0.361043</td>\n    </tr>\n    <tr>\n      <th>constant</th>\n      <td>0.788109</td>\n      <td>-0.868502</td>\n      <td>-0.627620</td>\n      <td>-0.231353</td>\n      <td>0.231352</td>\n      <td>-10.741586</td>\n      <td>-0.221894</td>\n      <td>0.217306</td>\n      <td>2.356162</td>\n      <td>-2.356438</td>\n      <td>-8.609149</td>\n    </tr>\n    <tr>\n      <th>log_likelihood</th>\n      <td>-7.054748</td>\n      <td>-7.121697</td>\n      <td>-10.276667</td>\n      <td>-10.238452</td>\n      <td>-10.238452</td>\n      <td>-3.910396</td>\n      <td>-8.500862</td>\n      <td>-11.986215</td>\n      <td>-3.190586</td>\n      <td>-1.678381</td>\n      <td>-1.512205</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "results"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:48:26.917670100Z",
     "start_time": "2024-08-06T12:48:26.885380800Z"
    }
   },
   "id": "bc72adf2a0fa1c0a"
  },
  {
   "cell_type": "markdown",
   "source": [
    "Note: Truth, exile and purge each contain less than 100 \"true\" rows"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "fd3e5c6fde7ae8e"
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "outputs": [],
   "source": [
    "import statsmodels.api as sm"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:56:25.538250400Z",
     "start_time": "2024-08-06T12:56:17.761043400Z"
    }
   },
   "id": "781dd8cbb11efbdd"
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''",
     "output_type": "error",
     "traceback": [
      "\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
      "\u001B[1;31mTypeError\u001B[0m                                 Traceback (most recent call last)",
      "Cell \u001B[1;32mIn[75], line 5\u001B[0m\n\u001B[0;32m      2\u001B[0m X_with_intercept \u001B[38;5;241m=\u001B[39m sm\u001B[38;5;241m.\u001B[39madd_constant(np\u001B[38;5;241m.\u001B[39marray(dataset3[[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mmobcap\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mfightcap_high\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mfightcap_moderate\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mfightcap_low\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mintens\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mpolity\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mis_leftist_group\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mincomp\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mterrcont\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124myear_of_conflict\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mcold_war\u001B[39m\u001B[38;5;124m'\u001B[39m]]))\n\u001B[0;32m      4\u001B[0m \u001B[38;5;66;03m# Fit the model using statsmodels\u001B[39;00m\n\u001B[1;32m----> 5\u001B[0m logit_model \u001B[38;5;241m=\u001B[39m sm\u001B[38;5;241m.\u001B[39mLogit(np\u001B[38;5;241m.\u001B[39marray(dataset3[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mtruth\u001B[39m\u001B[38;5;124m'\u001B[39m]), X_with_intercept)\u001B[38;5;241m.\u001B[39mfit()\n\u001B[0;32m      7\u001B[0m \u001B[38;5;66;03m# Get the p-values\u001B[39;00m\n\u001B[0;32m      8\u001B[0m p_values \u001B[38;5;241m=\u001B[39m logit_model\u001B[38;5;241m.\u001B[39mpvalues\n",
      "File \u001B[1;32m~\\anaconda3\\Lib\\site-packages\\statsmodels\\discrete\\discrete_model.py:475\u001B[0m, in \u001B[0;36mBinaryModel.__init__\u001B[1;34m(self, endog, exog, offset, check_rank, **kwargs)\u001B[0m\n\u001B[0;32m    472\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21m__init__\u001B[39m(\u001B[38;5;28mself\u001B[39m, endog, exog, offset\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mNone\u001B[39;00m, check_rank\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mTrue\u001B[39;00m, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs):\n\u001B[0;32m    473\u001B[0m     \u001B[38;5;66;03m# unconditional check, requires no extra kwargs added by subclasses\u001B[39;00m\n\u001B[0;32m    474\u001B[0m     \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_check_kwargs(kwargs)\n\u001B[1;32m--> 475\u001B[0m     \u001B[38;5;28msuper\u001B[39m()\u001B[38;5;241m.\u001B[39m\u001B[38;5;21m__init__\u001B[39m(endog, exog, offset\u001B[38;5;241m=\u001B[39moffset, check_rank\u001B[38;5;241m=\u001B[39mcheck_rank,\n\u001B[0;32m    476\u001B[0m                      \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs)\n\u001B[0;32m    477\u001B[0m     \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m \u001B[38;5;28missubclass\u001B[39m(\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m\u001B[38;5;18m__class__\u001B[39m, MultinomialModel):\n\u001B[0;32m    478\u001B[0m         \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m np\u001B[38;5;241m.\u001B[39mall((\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mendog \u001B[38;5;241m>\u001B[39m\u001B[38;5;241m=\u001B[39m \u001B[38;5;241m0\u001B[39m) \u001B[38;5;241m&\u001B[39m (\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mendog \u001B[38;5;241m<\u001B[39m\u001B[38;5;241m=\u001B[39m \u001B[38;5;241m1\u001B[39m)):\n",
      "File \u001B[1;32m~\\anaconda3\\Lib\\site-packages\\statsmodels\\discrete\\discrete_model.py:185\u001B[0m, in \u001B[0;36mDiscreteModel.__init__\u001B[1;34m(self, endog, exog, check_rank, **kwargs)\u001B[0m\n\u001B[0;32m    183\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21m__init__\u001B[39m(\u001B[38;5;28mself\u001B[39m, endog, exog, check_rank\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mTrue\u001B[39;00m, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs):\n\u001B[0;32m    184\u001B[0m     \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_check_rank \u001B[38;5;241m=\u001B[39m check_rank\n\u001B[1;32m--> 185\u001B[0m     \u001B[38;5;28msuper\u001B[39m()\u001B[38;5;241m.\u001B[39m\u001B[38;5;21m__init__\u001B[39m(endog, exog, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs)\n\u001B[0;32m    186\u001B[0m     \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mraise_on_perfect_prediction \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;01mFalse\u001B[39;00m  \u001B[38;5;66;03m# keep for backwards compat\u001B[39;00m\n\u001B[0;32m    187\u001B[0m     \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mk_extra \u001B[38;5;241m=\u001B[39m \u001B[38;5;241m0\u001B[39m\n",
      "File \u001B[1;32m~\\anaconda3\\Lib\\site-packages\\statsmodels\\base\\model.py:270\u001B[0m, in \u001B[0;36mLikelihoodModel.__init__\u001B[1;34m(self, endog, exog, **kwargs)\u001B[0m\n\u001B[0;32m    269\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21m__init__\u001B[39m(\u001B[38;5;28mself\u001B[39m, endog, exog\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mNone\u001B[39;00m, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs):\n\u001B[1;32m--> 270\u001B[0m     \u001B[38;5;28msuper\u001B[39m()\u001B[38;5;241m.\u001B[39m\u001B[38;5;21m__init__\u001B[39m(endog, exog, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs)\n\u001B[0;32m    271\u001B[0m     \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39minitialize()\n",
      "File \u001B[1;32m~\\anaconda3\\Lib\\site-packages\\statsmodels\\base\\model.py:95\u001B[0m, in \u001B[0;36mModel.__init__\u001B[1;34m(self, endog, exog, **kwargs)\u001B[0m\n\u001B[0;32m     93\u001B[0m missing \u001B[38;5;241m=\u001B[39m kwargs\u001B[38;5;241m.\u001B[39mpop(\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mmissing\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mnone\u001B[39m\u001B[38;5;124m'\u001B[39m)\n\u001B[0;32m     94\u001B[0m hasconst \u001B[38;5;241m=\u001B[39m kwargs\u001B[38;5;241m.\u001B[39mpop(\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mhasconst\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;28;01mNone\u001B[39;00m)\n\u001B[1;32m---> 95\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mdata \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_handle_data(endog, exog, missing, hasconst,\n\u001B[0;32m     96\u001B[0m                               \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs)\n\u001B[0;32m     97\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mk_constant \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mdata\u001B[38;5;241m.\u001B[39mk_constant\n\u001B[0;32m     98\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mexog \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mdata\u001B[38;5;241m.\u001B[39mexog\n",
      "File \u001B[1;32m~\\anaconda3\\Lib\\site-packages\\statsmodels\\base\\model.py:135\u001B[0m, in \u001B[0;36mModel._handle_data\u001B[1;34m(self, endog, exog, missing, hasconst, **kwargs)\u001B[0m\n\u001B[0;32m    134\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21m_handle_data\u001B[39m(\u001B[38;5;28mself\u001B[39m, endog, exog, missing, hasconst, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs):\n\u001B[1;32m--> 135\u001B[0m     data \u001B[38;5;241m=\u001B[39m handle_data(endog, exog, missing, hasconst, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs)\n\u001B[0;32m    136\u001B[0m     \u001B[38;5;66;03m# kwargs arrays could have changed, easier to just attach here\u001B[39;00m\n\u001B[0;32m    137\u001B[0m     \u001B[38;5;28;01mfor\u001B[39;00m key \u001B[38;5;129;01min\u001B[39;00m kwargs:\n",
      "File \u001B[1;32m~\\anaconda3\\Lib\\site-packages\\statsmodels\\base\\data.py:675\u001B[0m, in \u001B[0;36mhandle_data\u001B[1;34m(endog, exog, missing, hasconst, **kwargs)\u001B[0m\n\u001B[0;32m    672\u001B[0m     exog \u001B[38;5;241m=\u001B[39m np\u001B[38;5;241m.\u001B[39masarray(exog)\n\u001B[0;32m    674\u001B[0m klass \u001B[38;5;241m=\u001B[39m handle_data_class_factory(endog, exog)\n\u001B[1;32m--> 675\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m klass(endog, exog\u001B[38;5;241m=\u001B[39mexog, missing\u001B[38;5;241m=\u001B[39mmissing, hasconst\u001B[38;5;241m=\u001B[39mhasconst,\n\u001B[0;32m    676\u001B[0m              \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs)\n",
      "File \u001B[1;32m~\\anaconda3\\Lib\\site-packages\\statsmodels\\base\\data.py:88\u001B[0m, in \u001B[0;36mModelData.__init__\u001B[1;34m(self, endog, exog, missing, hasconst, **kwargs)\u001B[0m\n\u001B[0;32m     86\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mconst_idx \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;01mNone\u001B[39;00m\n\u001B[0;32m     87\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mk_constant \u001B[38;5;241m=\u001B[39m \u001B[38;5;241m0\u001B[39m\n\u001B[1;32m---> 88\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_handle_constant(hasconst)\n\u001B[0;32m     89\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_check_integrity()\n\u001B[0;32m     90\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_cache \u001B[38;5;241m=\u001B[39m {}\n",
      "File \u001B[1;32m~\\anaconda3\\Lib\\site-packages\\statsmodels\\base\\data.py:133\u001B[0m, in \u001B[0;36mModelData._handle_constant\u001B[1;34m(self, hasconst)\u001B[0m\n\u001B[0;32m    131\u001B[0m check_implicit \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;01mFalse\u001B[39;00m\n\u001B[0;32m    132\u001B[0m exog_max \u001B[38;5;241m=\u001B[39m np\u001B[38;5;241m.\u001B[39mmax(\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mexog, axis\u001B[38;5;241m=\u001B[39m\u001B[38;5;241m0\u001B[39m)\n\u001B[1;32m--> 133\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m np\u001B[38;5;241m.\u001B[39misfinite(exog_max)\u001B[38;5;241m.\u001B[39mall():\n\u001B[0;32m    134\u001B[0m     \u001B[38;5;28;01mraise\u001B[39;00m MissingDataError(\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mexog contains inf or nans\u001B[39m\u001B[38;5;124m'\u001B[39m)\n\u001B[0;32m    135\u001B[0m exog_min \u001B[38;5;241m=\u001B[39m np\u001B[38;5;241m.\u001B[39mmin(\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mexog, axis\u001B[38;5;241m=\u001B[39m\u001B[38;5;241m0\u001B[39m)\n",
      "\u001B[1;31mTypeError\u001B[0m: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''"
     ]
    }
   ],
   "source": [
    "# Add a constant term to the features (intercept)\n",
    "X_with_intercept = sm.add_constant(np.array(dataset3[['mobcap', 'fightcap_high', 'fightcap_moderate', 'fightcap_low', 'intens', 'polity', 'is_leftist_group', 'incomp', 'terrcont', 'year_of_conflict', 'cold_war']]))\n",
    "\n",
    "# Fit the model using statsmodels\n",
    "logit_model = sm.Logit(np.array(), X_with_intercept).fit()\n",
    "\n",
    "# Get the p-values\n",
    "p_values = logit_model.pvalues\n",
    "\n",
    "print(p_values)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:58:43.724479100Z",
     "start_time": "2024-08-06T12:58:43.655034800Z"
    }
   },
   "id": "65171e15688703ef"
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "outputs": [],
   "source": [
    "import numpy as np"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T12:58:41.970487800Z",
     "start_time": "2024-08-06T12:58:41.937911100Z"
    }
   },
   "id": "69dbc3282e9c7f68"
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "outputs": [],
   "source": [
    "dataset5 = dataset.replace({True: 1, False: 0})"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T13:01:41.446777200Z",
     "start_time": "2024-08-06T13:01:41.351401200Z"
    }
   },
   "id": "fccc9c0e744e37cd"
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "outputs": [],
   "source": [
    "dataset5.to_csv('CleanData1_0.csv')"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T13:02:15.192700700Z",
     "start_time": "2024-08-06T13:02:15.106141900Z"
    }
   },
   "id": "f91447312c3f877f"
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "outputs": [],
   "source": [
    "dataset5[dataset5['conciliatory'] == 1].to_csv('CleanData_conc.csv')\n",
    "dataset5[dataset5['coercive'] == 1].to_csv('CleanData_coer.csv')"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-06T13:09:22.465735900Z",
     "start_time": "2024-08-06T13:09:22.403981400Z"
    }
   },
   "id": "58104b9621a63aab"
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "outputs": [
    {
     "data": {
      "text/plain": "      acdid  year      location   gwno  region           epid  styear  \\\n1       100  1966       Nigeria  475.0       4       100_1966    1966   \n2       100  2009       Nigeria  475.0       4       100_2009    2009   \n3       100  2011       Nigeria  475.0       4       100_2011    2011   \n4       101  1966  South Africa  560.0       4  101_1966-1988    1966   \n5       101  1967  South Africa  560.0       4  101_1966-1988    1966   \n...     ...   ...           ...    ...     ...            ...     ...   \n1933      9  1949          Laos  812.0       3    9_1946-1953    1946   \n1934      9  1950          Laos  812.0       3    9_1946-1953    1946   \n1935      9  1951          Laos  812.0       3    9_1946-1953    1946   \n1936      9  1952          Laos  812.0       3    9_1946-1953    1946   \n1937      9  1953          Laos  812.0       3    9_1946-1953    1946   \n\n      endyear  epend  dcjdummy  ...  epdum_govdcj  epdum_rebdcj  polity  \\\n1        1966      1         0  ...             0             0    -7.0   \n2        2009      0         3  ...             1             0     4.0   \n3        2011      0        14  ...             1             0     4.0   \n4        1988      0         0  ...             1             0     4.0   \n5        1988      0         1  ...             1             0     4.0   \n...       ...    ...       ...  ...           ...           ...     ...   \n1933     1953      0         0  ...             0             0     NaN   \n1934     1953      0         0  ...             0             0     NaN   \n1935     1953      0         0  ...             0             0     NaN   \n1936     1953      0         0  ...             0             0     NaN   \n1937     1953      1         0  ...             0             0     NaN   \n\n      regime  rebstrength  bdeadbes  bdeadchgrel  chgbdeadrel  outcome  \\\n1        3.0          4.0      20.0          NaN          NaN      4.0   \n2        2.0          1.0       NaN          NaN          NaN      NaN   \n3        2.0          1.0       NaN          NaN          NaN      NaN   \n4        2.0          2.0       NaN          NaN          NaN      NaN   \n5        2.0          2.0       NaN          NaN          NaN      NaN   \n...      ...          ...       ...          ...          ...      ...   \n1933     NaN          1.0       NaN          NaN          NaN      NaN   \n1934     NaN          1.0       NaN          NaN          NaN      NaN   \n1935     NaN          1.0       NaN          NaN          NaN      NaN   \n1936     NaN          1.0       NaN          NaN          NaN      NaN   \n1937     NaN          1.0       NaN          NaN          NaN      5.0   \n\n      conflterm  \n1           2.0  \n2           NaN  \n3           NaN  \n4           NaN  \n5           NaN  \n...         ...  \n1933        NaN  \n1934        NaN  \n1935        NaN  \n1936        NaN  \n1937        3.0  \n\n[1937 rows x 66 columns]",
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>acdid</th>\n      <th>year</th>\n      <th>location</th>\n      <th>gwno</th>\n      <th>region</th>\n      <th>epid</th>\n      <th>styear</th>\n      <th>endyear</th>\n      <th>epend</th>\n      <th>dcjdummy</th>\n      <th>...</th>\n      <th>epdum_govdcj</th>\n      <th>epdum_rebdcj</th>\n      <th>polity</th>\n      <th>regime</th>\n      <th>rebstrength</th>\n      <th>bdeadbes</th>\n      <th>bdeadchgrel</th>\n      <th>chgbdeadrel</th>\n      <th>outcome</th>\n      <th>conflterm</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>1</th>\n      <td>100</td>\n      <td>1966</td>\n      <td>Nigeria</td>\n      <td>475.0</td>\n      <td>4</td>\n      <td>100_1966</td>\n      <td>1966</td>\n      <td>1966</td>\n      <td>1</td>\n      <td>0</td>\n      <td>...</td>\n      <td>0</td>\n      <td>0</td>\n      <td>-7.0</td>\n      <td>3.0</td>\n      <td>4.0</td>\n      <td>20.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>4.0</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>100</td>\n      <td>2009</td>\n      <td>Nigeria</td>\n      <td>475.0</td>\n      <td>4</td>\n      <td>100_2009</td>\n      <td>2009</td>\n      <td>2009</td>\n      <td>0</td>\n      <td>3</td>\n      <td>...</td>\n      <td>1</td>\n      <td>0</td>\n      <td>4.0</td>\n      <td>2.0</td>\n      <td>1.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>100</td>\n      <td>2011</td>\n      <td>Nigeria</td>\n      <td>475.0</td>\n      <td>4</td>\n      <td>100_2011</td>\n      <td>2011</td>\n      <td>2011</td>\n      <td>0</td>\n      <td>14</td>\n      <td>...</td>\n      <td>1</td>\n      <td>0</td>\n      <td>4.0</td>\n      <td>2.0</td>\n      <td>1.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>101</td>\n      <td>1966</td>\n      <td>South Africa</td>\n      <td>560.0</td>\n      <td>4</td>\n      <td>101_1966-1988</td>\n      <td>1966</td>\n      <td>1988</td>\n      <td>0</td>\n      <td>0</td>\n      <td>...</td>\n      <td>1</td>\n      <td>0</td>\n      <td>4.0</td>\n      <td>2.0</td>\n      <td>2.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>101</td>\n      <td>1967</td>\n      <td>South Africa</td>\n      <td>560.0</td>\n      <td>4</td>\n      <td>101_1966-1988</td>\n      <td>1966</td>\n      <td>1988</td>\n      <td>0</td>\n      <td>1</td>\n      <td>...</td>\n      <td>1</td>\n      <td>0</td>\n      <td>4.0</td>\n      <td>2.0</td>\n      <td>2.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>1933</th>\n      <td>9</td>\n      <td>1949</td>\n      <td>Laos</td>\n      <td>812.0</td>\n      <td>3</td>\n      <td>9_1946-1953</td>\n      <td>1946</td>\n      <td>1953</td>\n      <td>0</td>\n      <td>0</td>\n      <td>...</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>1.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>1934</th>\n      <td>9</td>\n      <td>1950</td>\n      <td>Laos</td>\n      <td>812.0</td>\n      <td>3</td>\n      <td>9_1946-1953</td>\n      <td>1946</td>\n      <td>1953</td>\n      <td>0</td>\n      <td>0</td>\n      <td>...</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>1.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>1935</th>\n      <td>9</td>\n      <td>1951</td>\n      <td>Laos</td>\n      <td>812.0</td>\n      <td>3</td>\n      <td>9_1946-1953</td>\n      <td>1946</td>\n      <td>1953</td>\n      <td>0</td>\n      <td>0</td>\n      <td>...</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>1.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>1936</th>\n      <td>9</td>\n      <td>1952</td>\n      <td>Laos</td>\n      <td>812.0</td>\n      <td>3</td>\n      <td>9_1946-1953</td>\n      <td>1946</td>\n      <td>1953</td>\n      <td>0</td>\n      <td>0</td>\n      <td>...</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>1.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>1937</th>\n      <td>9</td>\n      <td>1953</td>\n      <td>Laos</td>\n      <td>812.0</td>\n      <td>3</td>\n      <td>9_1946-1953</td>\n      <td>1946</td>\n      <td>1953</td>\n      <td>1</td>\n      <td>0</td>\n      <td>...</td>\n      <td>0</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>1.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>5.0</td>\n      <td>3.0</td>\n    </tr>\n  </tbody>\n</table>\n<p>1937 rows × 66 columns</p>\n</div>"
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_3"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-08-07T19:31:27.874121400Z",
     "start_time": "2024-08-07T19:31:27.835498700Z"
    }
   },
   "id": "2911c2a865bc003"
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false
   },
   "id": "e23ef2b0792e87ff"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}