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

only setx1 appears to do anything with arima models

christophergandrud opened this issue · comments

From #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
  • setx should set the baseline

  • setx1 should represent a shock

Currently setx is overwritten by setx1

summary for sim should show QI for each time point

Documenting some digging:

In ztimeseries$sim method setx1 precedes setx unlike in normal zelig approach:

Zelig/R/model-timeseries.R

Lines 173 to 179 in be652cb

# NOTE difference here from standard Zelig approach.
# Normally these are done in sequence, but now we do one or the other.
if (.self$bsetx1){
.self$simx1()
}else{
.self$simx()
}

In ci.plot only x or x1 quantity of interest values are plotted:

Zelig/R/plots.R

Lines 572 to 577 in be652cb

if (obj$bsetx & !obj$bsetx1) {
## If setx has been called and setx1 has not been called
ev<-t( obj$get_qi(qi=qi, xvalue="x") ) # NOTE THE NECESSARY TRANSPOSE. Should we more clearly standardize this?
} else {
ev<-t( obj$get_qi(qi=qi, xvalue="x1") ) # NOTE THE NECESSARY TRANSPOSE. Should we more clearly standardize this?
}

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?

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:

d <- zelig_mutate(d, mm = .self$setx.out$x$mm)

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.)

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.