#Using Benoit data from Benoit and Marsh (2009) PRQ dir<-setwd('d:\\classes\\pol290g\\Spring2009\\lectures') dir<-setwd('c:\\braddocs\\classes\\pol290g\\Spring2009\\lectures') # note: convert.factors=F since this makes dummy vars 0/1 numeric dail <- read.dta("dailprobit.dta", convert.factors=F) attach(dail) m1<-lm(votes1st~spend_total + incumb + spend_total:incumb) summary(m1)$coeff #Five-Number Summary (good to use to understand typical covariate profile) fivenum(dail$spend_total) x0 <- c(1, 75000, 1, 75000) # set some predictor values (cons, spend, incumb, s:i) (y0 <- sum(x0*coef(m1))) # compute predicted response fivenum(dail$votes1st) # how typical is this response? quantile(dail$votes1st, .99, na.rm=T) # versus 99th percentile x0.df <- data.frame(incumb=1, spend_total=75000) predict(m1, x0.df) predict(m1, x0.df, interval="confidence") predict(m1, x0.df, interval="prediction")