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
import random | |
from random import randint | |
import pylab | |
class TrafficSimulation: | |
"""A class that simulates traffic on a single lane. """ | |
def __init__(self, length, density, maxvel, prob): | |
""" Initializes the instance of a simulation. The user has to specify the length of the road, | |
the initial density, max velocity and the probability of slowing down. | |
""" |
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
# Installing all the necessary libraries | |
library(Matching) | |
library(rbounds) | |
library(tableHTML) | |
# Loading the data | |
load("datamatch.Rdata") | |
# Outcome variables | |
outcomes <- datamatch[10:18] |
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
library(haven) | |
# Installing thelibraries and importing the data | |
library(foreign) | |
library(Matching) | |
setwd("~/Downloads") | |
nsw_dw <- read_dta("nsw_dw.dta") | |
# Subsetting the treatment and control groups | |
treat <- subset(nsw_dw, treat==1) | |
control <- subset(nsw_dw, treat == 0) |
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
install.packages("Matching") | |
library(Matching) | |
data(lalonde) | |
#Creaing two subsets: people with high school degree and people without high school degree | |
nodegree <- subset(lalonde, nodegr==1) | |
degree <- subset(lalonde, nodegr==0) | |
mean(nodegree$re78) | |
#[1] 4929.842 | |
mean(degree$re78) |