Using R, I am running regressions, simulations , and testing the significance on a simple data set ("approval" in Zelig).
All is going well until I try to test the statistical significance.
This is my code:
library(mvtnorm)
library(Zelig)
data(approval)
set.seed(12345)
xh1 <- setx(approval, avg.price = mean(approval$avg.price) + sd(approval$avg.price), sept.oct.2001=1)
xl1 <- setx(approval, avg.price= mean(approval$avg.price), sept.oct.2001=1)
xh0 <- setx(approval, avg.price = mean(approval$avg.price) + sd(approval$avg.price), sept.oct.2001 =0)
xl0 <- setx(approval, avg.price= mean(approval$avg.price), sept.oct.2001=0)
zh1 <- sim(approval, x=xh1)zl1 <- sim(approval, x=xl1)zh0 <-sim(approval, x=xh0)
zl0 <- sim(approval, x=xl0)
eff <- (zh1$qi$ev - zl1$qi$ev) -(zh0$qi$ev - zl0$qi$ev)
quantile(eff, c(.025, .975))
And the error that I get is
Quitting from lines 87-103 (Preview-151c5fba73e.Rmd) Error in terms.default(object) : no terms component nor attributeCalls: ... eval -> setx -> setx.default -> terms -> terms.default Execution halted
For reference,
m1<- zelig(approve~avg.price, model="ls", data=approval)
m2<- zelig(approve~avg.price+sept.oct.2001+iraq.war, model="ls", data=approval)
m3<- zelig(approve~avg.price+sept.oct.2001+avg.price:sept.oct.2001, model="ls", data=approval)
And for my simulations
x1 <- setx(m2, sept.oct.2001= 1)
s1 <- sim(m2, x=x1)
summary(s1)
x1 <- setx(m2, sept.oct.2001= 0)
s1 <- sim(m2, x=x1)
summary(s1)
oilprice<-min(approval$avg.price):max(approval$avg.price)
x2 <- setx(m2, sept.oct.2001=0, avg.price=oilprice)
s2 <-sim (m2, x=x2)
plot.ci(s2)
oilprice<-min(approval$avg.price):max(approval$avg.price)
x2 <- setx(m2, sept.oct.2001=1, avg.price=oilprice)
s2 <-sim (m2, x=x2)
plot.ci(s2)
This all worked totally fine.