IQSS / Zelig

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

only setx1 appears to do anything with arima models #306

Closed christophergandrud closed 6 years ago

christophergandrud commented 7 years ago

From https://github.com/IQSS/Zelig/issues/305

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
christophergandrud commented 6 years ago

Currently setx is overwritten by setx1

summary for sim should show QI for each time point

christophergandrud commented 6 years ago

Documenting some digging:

In ztimeseries$sim method setx1 precedes setx unlike in normal zelig approach: https://github.com/IQSS/Zelig/blob/be652cbda815279197ec4f37c613365fcfc5967b/R/model-timeseries.R#L173-L179

In ci.plot only x or x1 quantity of interest values are plotted: https://github.com/IQSS/Zelig/blob/be652cbda815279197ec4f37c613365fcfc5967b/R/plots.R#L572-L577

christophergandrud commented 6 years ago

I made some simple modifications to the above code such that both setx and setx1 are run and plotted next to each other. This is the result:

stacked_setx

So, clearly not what we want.

Now turning to look more into what simx and simx1 are doing. In particular, does simx1 use a baseline created by simx, which I believe is the target behaviour?

christophergandrud commented 6 years ago

Part of our confusion may be caused by the effect size in the example not being very large. If you put in silly values for setx (e.g. 10 in the above example) the plot is different, so clearly setx is not completely ignored, as we see here in setx1: https://github.com/IQSS/Zelig/blob/be652cbda815279197ec4f37c613365fcfc5967b/R/model-timeseries.R#L138

Maybe rather than continuing to fumble around here it would be good if @tercer wrote up an example of exactly what is going on in this example. I feel like we haven't clearly defined what we want to achieve enough to even determine if it is already present.

(One thing that does kind of bug me is that Zelig is returning a plot of predicted values for 44 years for this example. Not sure how realistic that timeframe is for illustrating the effect of left seat share on unemployment.)

christophergandrud commented 6 years ago

After much discussion within the Zelig team. We have decided to deprecate all time series models. It was often unclear what the desired quantities of interest are and how the current implementation aimed to achieve them.

A warning will be added to the models and they will be fully deprecated on 1 February 2018.

christophergandrud commented 6 years ago

Implemented: 82e1e2b6887d83d27e3e60988daebf82753c2026