IQSS / Zelig

A statistical framework that serves as a common interface to a large range of models

Home Page:http://zeligproject.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`summary` error with arima with sim

christophergandrud opened this issue · comments

Originally reported in #299

s.out <- zelig(unemp ~ leftseat, data = subset, model = "arima",
               order = c(2,0,1)) %>%
    setx(leftseat = 0.75) %>%
    setx1(leftseat = 0.25) %>%
    sim()
summary(s.out)

## sim x :
##  -----
## ev
## 
## Error in apply(qi, 2, quantile, c(0.5, 0.025, 0.975), na.rm = TRUE) : 
##  dim(X) must have a positive length

The error is solved in: 4f2dc6b

However, it reveals what I suspected in #299 (comment) that setx1 isn't doing anything here:

library(Zelig)
data(seatshare)

subset <- seatshare[seatshare$country == "UNITED KINGDOM",]

s.out <- zelig(unemp ~ leftseat, data = subset, model = "arima",
                   order = c(2,0,1)) %>%
        setx(leftseat = 0.25) %>%
        setx1(leftseat = 0.75) %>%
        sim()
summary(s.out)

 sim x :
 -----
ev
         mean      sd      50%     2.5%    97.5%
[1,] 91.30382 477.675 52.19226 18.83912 272.1593
pv
         mean       sd      50%     2.5%    97.5%
[1,] 91.31568 477.6912 52.46997 18.98119 271.0645
fd
         mean       sd       50%      2.5%    97.5%
[1,] 215.0737 6901.896 -14.90352 -42.87303 52.84499

 sim x1 :
 -----
ev
         mean      sd      50%     2.5%    97.5%
[1,] 91.30382 477.675 52.19226 18.83912 272.1593
pv
         mean       sd      50%     2.5%    97.5%
[1,] 91.31568 477.6912 52.46997 18.98119 271.0645
fd
         mean       sd       50%      2.5%    97.5%
[1,] 215.0737 6901.896 -14.90352 -42.87303 52.84499

I don't really think this is a problem (in time series, usually the QI is about changes over time rather than compared to other values of the covariates, though this could obviously be done by running the estimation twice). It is a problem however, if no informative error is returned when users enter something with setx1 and expect their results to be meaningful.

Reporting the latter in a new issue: #306