Created
April 24, 2013 12:58
-
-
Save chrishanretty/5451937 to your computer and use it in GitHub Desktop.
Predictions for duration of government formation, Letta government
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(foreign) | |
library(survival) | |
dat <- read.dta("delay.dta") | |
dat$bargainingdays [which(dat$bargainingdays == 0)] <- .01 | |
dat$post_legislative_parties <- dat$postelection * dat$legislative_parties | |
dat$post_polariz <- dat$postelection * dat$polarization | |
dat$post_positive <- dat$postelection * dat$positive_parl | |
mod.golder <- coxph(Surv(bargainingdays, ) ~ | |
postelection+legislative_parties+polarization+positive_parl+continuation+singleparty_majority, | |
data=subset(dat,nonpartisan==0)) | |
## Create new data for Letta govt. | |
effnum <- function(x) 1/sum((x/sum(x))^2) | |
senato.shares <- c(106,92,53,21,17,0,10,20) | |
newdata <- data.frame(bargainingdays = NA, postelection = 1, | |
legislative_parties = effnum(senato.shares), | |
polarization = mean(dat$polarization[which(dat$countryname == "Italy")]), | |
positive_parl = 1, | |
continuation = 0, | |
singleparty_majority = 0) | |
curves <- survfit(mod.golder, newdata = newdata) | |
plot(curves) | |
the.day <- which.min(abs(curves$surv - 0.5)) | |
the.day.upper <- which.min(abs(curves$upper - 0.5)) | |
the.day.lower <- which.min(abs(curves$lower - 0.5)) | |
abline(h=.5,lty=2) | |
abline(v=the.day,lty=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment