IQSS / Zelig

A statistical framework that serves as a common interface to a large range of models
http://zeligproject.org
110 stars 43 forks source link

`summary` error with arima with sim #305

Closed christophergandrud closed 7 years ago

christophergandrud commented 7 years ago

Originally reported in https://github.com/IQSS/Zelig/issues/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
christophergandrud commented 7 years ago

The error is solved in: 4f2dc6b5284217895c9194be29addd26daebe4e9

However, it reveals what I suspected in https://github.com/IQSS/Zelig/issues/299#issuecomment-325093050 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.

christophergandrud commented 7 years ago

Reporting the latter in a new issue: https://github.com/IQSS/Zelig/issues/306