-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
82 lines (54 loc) · 1.91 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python
# https://stackoverflow.com/a/2429517/
"""
Replication Materials for "The Relational Bases of Informal Financial Cooperation".
Python Version Used for Analysis: CPython 3.9.10
PyMC Version Used for Analysis: 4.4.0
Data reanalysed for my paper come from:
Ferrali, R., Grossman, G., Platas, M. R., & Rodden, J. (2020). It Takes a
Village: Peer Effects and Externalities in Technology Adoption.
American Journal of Political Science, 64(3), 536–553.
https://doi.org/10.1111/ajps.12471
Ferrali, R., Grossman, G., Platas, M. R., & Rodden, J. (2021). Who Registers?
Village Networks, Household Dynamics, and Voter Registration in Rural Uganda.
Comparative Political Studies, 001041402110360.
https://doi.org/10.1177/00104140211036048
Author: Cohen R. Simpson
Maintainer: Cohen R. Simpson
Email: c.r.simpson@lse.ac.uk
"""
import os
os.chdir("/Users/cohen/Desktop IconFree/GitHub/money")
import arviz as az
import arviz.labels as azl
import aesara.tensor as at
import graphviz as gv
import itertools
import cloudpickle
import matplotlib.pyplot as plt
import mizani as miz
import numpy as np
import numexpr
import pandas as pd
import plotnine as p9
import pymc as pm # pip install pymc==4.4.0; Using Python v. 3.9.10
import scipy as sp
import scipy.stats
import xarray
# Set Random Seed for Analyses
np.random.seed(20200127)
# Set Number of CPU Cores for PyMC Parallel Processing + Define Markov Chains
# Note, PyMC uses no more than four CPU cores.
cpu_cores = 4
markov_chains = 4
draws_per_chain = 3000
tuning_iterations_per_chain = 2000
# TODO: Clarify if this is the best way to run all code components.
load_data = open("load_data.py")
build_features = open("build_features.py")
fit_models = open("fit_models.py")
visualise_results = open("visualise_results.py")
exec(load_data.read())
exec(build_features.read())
exec(fit_models.read())
exec(visualise_results.read())