This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### Libraries ---- | |
library(tidyverse) | |
library(ggrepel) | |
library(ggthemr) | |
#### Data preparation ---- | |
# Data from: | |
# https://ourworldindata.org/grapher/life-expectancy?time=2019 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### Libraries -------------------- | |
library(haven) | |
library(tidyverse) | |
library(sjlabelled) | |
library(zoo) | |
#### Data Prep -------------------- | |
# from https://data.stanford.edu/hcmst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### Libraries -------------------- | |
library(data.table) | |
library(ggplot2) | |
library(msm) | |
library(glue) | |
#### Data -------------------- | |
# inputs from here https://jamanetwork.com/journals/jamapsychiatry/fullarticle/482702 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### Libraries -------------------- | |
library(WDI) | |
library(data.table) | |
library(ggplot2) | |
#### Data -------------------- | |
# uv data is from here | |
# https://apps.who.int/gho/data/view.main.35300 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.model_selection import train_test_split | |
from sklearn.datasets import make_classification | |
from sklearn.tree import DecisionTreeClassifier | |
from sklearn.ensemble import RandomForestClassifier | |
from sklearn.metrics import accuracy_score | |
import random | |
import numpy as np | |
import pandas as pd | |
random_state = 123 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Simulating performance of the IV estimators against unobserved covariates. | |
""" | |
import numpy as np | |
import pandas as pd | |
from modified_linear_dataset import modified_linear_dataset | |
from simulation_function import simulate_dag_violations | |
# Number of simulations | |
N = 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Simulating performance of the back-door estimators against unobserved covariates. | |
""" | |
import numpy as np | |
import pandas as pd | |
from modified_linear_dataset import modified_linear_dataset | |
from simulation_function import simulate_dag_violations | |
# Number of simulations | |
N = 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Function to run simulations on different versions of the original dataset from | |
https://microsoft.github.io/dowhy/dowhy_estimation_methods.html | |
modified_linear_dataset is a slighly modifed version of linear_dataset from | |
https://github.com/microsoft/dowhy/blob/master/dowhy/datasets.py | |
Full code is availible at https://github.com/aliaksandrkazlou/shinytools | |
""" | |
import numpy as np | |
import pandas as pd | |
from dowhy import CausalModel |