idealstan Vignette: Time-Varying Ideal Points

Note: To report bugs with the package, please file an issue on the Github page.

If you use this package, please cite the following:

Kubinec, Robert. “Generalized Ideal Point Models for Time-Varying and Missing-Data Inference”. Working Paper.

This package implements to kinds of time-varying ideal point models. Because these time-varying models are independent of the specific outcome used, time-varying ideal point models can be fit with any outcome/response supported by the package, including binary, ordinal, counts, continuous and positive-continuous data, in addition to the latent space model for binary data. This vignette demonstrates the use of the two time-varying ideal point models and how to decide between them with example data drawn from Delaware’s state legislature.

data('delaware')
knitr::kable(slice(delaware,1:10))
outcome item_id person_id group_id time_id
NA 1 Atkins, John 1 R 1995-01-01
NA 1 Atkins, John 2 D 1995-01-01
Yes 1 Banning 3 D 1995-01-01
NA 1 Barbieri, Michael A. 4 D 1995-01-01
NA 1 Baumbach, Paul S. 5 D 1995-01-01
NA 1 Bennett, Andria 6 D 1995-01-01
NA 1 Bennett, E. 7 D 1995-01-01
NA 1 Bentz, David 8 D 1995-01-01
NA 1 Blakey, Donald 9 R 1995-01-01
NA 1 Bolden, Stephanie 10 D 1995-01-01

The process to create a time-varying ideal point model is no different than that for creating a static model, except that a column should exist in the data with dates, preferably in date or date-time format. If you have a character vector of dates that you need to convert to R’s date format, check out the excellent lubridate package.

There are three time-varying models included in idealstan package, each of which makes different assumptions about how ideal points change over time. It is important to note that none of these models is superior to the other. Ideal points do not have any natural time process as they are a latent, unobserved construct, so the question is more about which time process is most relevant to the social or physical process being studied. The models can be differentiated by whether they permit general description of time series versus inference on specific aspects, and also in terms of complexity.

The first kind of model included in idealstan is known as a random-walk process (also known as non-stationary time-series, Brownian motion and I(1)). This simple model of time implies that the location of an ideal point in the current time point is equal to the position of the ideal point in the prior time point plus some random noise. A helpful analogy is to imagine a frog hopping around a room. It could head in virtually any direction.

The advantage of the random-walk model is that it allows ideal points to move in any direction. The downside is that it can assume too much change in the ideal point process. It also does not provide a great deal of information about the time series other than the variance parameter of the time series that indicate the average rate of change over time (i.e., how bouncy the time series is). Furthermore, random-walk models change significantly when other covariates are included in the model, as an additional covariate that has a constant effect over time will push the time-series in a single direction, making it less than ideal for testing the effect of time-varying covariates.

Despite these limitations, this model is still useful, especially in two situations. First, when little is known about the time process/social situation, this model makes the most minimal assumptions about how ideal points change. Second, when the time series is of a relatively long time period, then the time series is likely to have some kind of random-walk nature, especially if there is no natural limit. For example, when looking at legislature voting data, ideal points may follow a random-walk pattern when looking at a legislator’s entire career over decades. In general, a random walk provides a good descriptive inference of where the ideal points are moving; it just won’t tell you a lot about why.

The second model included in idealstan is a stationary time series model (also called an AR(1) or first-order autoregressive time series). A stationary time-series is so called because it must return over time to a long-term average or mean. Change over time is conceived of as shocks that push the time series away from its long-term average. The AR(1) model includes additional parameters that measure how fast a time-series will return to its long-term average. A good empirical example for this model is economic growth over time. There are periods when “growth shocks” occur, such as recessions and boom times. Overall, though, economic growth for a specific country will tend towards some long-term average rate of growth. Economic growth can’t simply move off in any direction, especially in an upward direction, as that would over-heat the economy and result in massive inflation.

The third model is known as a Gaussian process. Fully explaining how Gaussian processes work is beyond the scope of this vignette, but I refer readers to this case study as a very helpful introduction. A Gaussian process is similar to a random walk in that it can in principle move in any direction. Unlike a random walk, the prior position of the time series doesn’t necessarily constrain the position of the time series in the present position. Rather, a Gaussian process is a generalized smoother: it will find a smooth path between the points, but can take any shape in principle.

One major advantage of the Gaussian process is that it is a so-called continuous time series model. In practice this means that the time series does not have to be sequential. For example, if legislators only vote at irregular intervals, and the fact that some bills are separated than more time than others is important, then a Gaussian process will take into account the actual length of time between each vote. Random walks and stationary models, on the other hand, consider each time point to be sequential to the previous time point, effectively ignoring any big gaps.

The main disadvantage of the Gaussian process is that the power and flexbility require a lot more data. It is not a useful model unless you have considerable numbers of bills/items. The model can handle additional time-varying covariates although their meaning is not as precise as the stationary model.

The stationary model, by contrast, assumes that ideal points have a single long-term average. The ideal points may receive “shocks” that force them away from the long-term mean, but they will inevitably return. While this is a more specific set of assumptions than the random walk or Gaussian process, stationary models have the significant advantage of allowing us to fit covariates that have a more meaningful interpretation: the estimates of covariates represent shocks to the ideal points away from their long-term average. We can even measure the time it takes for an ideal point process to return to its long-term average after experiencing the shock.1

To show what these models look like, we will fit each model to the delaware data in turn. We use the vb option to produce variational estimates of the true posterior; these approximations are much faster to fit than the full model but usually have some distortions. For finished analysis we would want to use the full sampler (use_vb=FALSE), unless we have so much data that processing time for the full model is infeasible.

Random-Walk Model

To fit the random walk model, we first create data in which we pass the name of the column of dates for each bill/item to the time_id option of id_make. One important thing to note about this model is that we code missing values as 'Absent', but we leave NA values in the outcome. These NA values will be dropped before running the model. They represent periods of time when legislators were not in office, and hence it is reasonable to exclude these periods of time from analysis.

delaware_data <- id_make(delaware,outcome = 'outcome',
                       person_id = 'person_id',
                       item_id = 'item_id',
                       group_id= 'group_id',
                       time_id='time_id',
                       miss_val='Absent')

We then pass this object to the id_estimate function and specify 'random_walk' in the vary_ideal_pts option. We also use model_type=2 to select a binary model (yes/no votes) that adjust for the missing data (legislator absences). We pass the names of two legislators to restrict their ideal points for identification. For the random walk model, only the first time points for these legislators will be fixed. If this method of identification did not work, we could also add a constraint to one of the time series by setting the restrict_mean option to TRUE.

del_est <- id_estimate(delaware_data,
                model_type = 2,
                 use_vb = T,
                fixtype='vb_partial',
                vary_ideal_pts='random_walk',
                 restrict_ind_high = "Brady, David 13",
                 restrict_ind_low="Blakey, Donald 9",
            seed=84520,
            refresh=0)

Given the fitted model, we can now plot the ideal points. We will turn off the option for showing the uncertainty interval as there are a lot of lines, one for each legislator:

id_plot_legis_dyn(del_est,use_ci = F) +
  scale_color_manual(values=c(R='red',
                              D='blue',
                              X='green'))

This plot does now show very much that is particularly interesting. Most of the ideal points are not changing over time, except for some of the moderate Democrats that become slightly more conservative over time. This small amount of change is not surprising as the Senate has become highly polarized and people are not shifting their policy positions.

However, we can also change the model’s parameters to induce more change over time. By default, idealstan restricts the over-time change in ideal points to have an SD of no more than .1. Restricting the variance this low helps with identification, however, it also prevents the ideal points from changing too much, such as switching signs from one time point to the next. We can relax that parameter and see if we get slightly more variation by increasing the restrict_var_high option have an SD of .5:

del_est_rw2 <- id_estimate(delaware_data,
                model_type = 2,
                 use_vb = T,
                fixtype='vb_partial',
                restrict_var_high = .5,
                vary_ideal_pts='random_walk',
                 restrict_ind_high = "Brady, David 13",
                 restrict_ind_low="Blakey, Donald 9",
            seed=84520,
            refresh=0)

id_plot_legis_dyn(del_est_rw2,use_ci = F) + ggtitle('Time-Varying Ideal Points of Delaware State Legislature',subtitle='Ideal Points Vary with Random-Walk Process') +
  scale_color_manual(values=c(R='red',
                              D='blue',
                              X='green'))

Now we can see a lot more movement, especially among Democrats, some of whom over the course of their careers moved from the liberal to conservative side of the ideal point spectrum.

We can also look at the variance of the ideal points to see which of the legislators had the highest variance in their ideal points:

id_plot_legis_var(del_est_rw2) + ggtitle('Variances of Time-Varying Ideal Points in Delaware State Legislature',subtitle='Higher Variances Indicate Less Stable Ideal Points') +
  scale_color_manual(values=c(R='red',
                              D='blue',
                              X='green'))

We can access the actual estimates of the variances by passing the return_data=TRUE option to the plot function:

out_d <- id_plot_legis_var(del_est_rw2,return_data = T)
knitr::kable(head(out_d$plot_data))
legis low_pt high_pt median_pt id_num person_id group_id
time_var_restrict[1] 0.0188078 0.2354400 0.0774120 1 Adams, Thurman Jr. 113 D
time_var_restrict[10] 0.0060303 0.1859794 0.0406554 10 Bennett, E. 7 D
time_var_restrict[100] 0.0081976 0.1906862 0.0505226 100 Plant, Hazel 77 D
time_var_restrict[101] 0.0908241 0.3585927 0.2109740 101 Poore, Nicole 138 D
time_var_restrict[102] 0.0059942 0.2258100 0.0497944 102 Postles, Charles S. 78 R
time_var_restrict[103] 0.0088015 0.2496016 0.0611890 103 Potter, Charles Jr. 79 D

Stationary Model

We now fit a stationary version of the model by passing 'AR1' to vary_ideal_pts. By default, this model does not put a hard upper limit on the over-time variance, but rather puts a tight prior on over-time variance that biases the variances to zero. We will put a hard upper limit as there are some legislators that move across the entire ideal point space, and we don’t want oscillation to occur–i.e, a legislator bouncing from one side of the ideal point spectrum to another every time point. While this behavior is entire possible within the model’s assumptions, it is unrealistic in the domain we are studying–legislative behavior. For that reason I put a hard .05 limit on the variance, however, even with this constraint, there is still some oscillation in ideal points:

del_est_ar1 <- id_estimate(delaware_data,
                model_type = 2,
                 use_vb = T,
                restrict_var_high = .05,
                restrict_var = T,
                fixtype='vb_partial',
                vary_ideal_pts='AR1',
                 restrict_ind_high = "Brady, David 13",
                 restrict_ind_low="Blakey, Donald 9",
            seed=84520)
## Chain 1: ------------------------------------------------------------
## Chain 1: EXPERIMENTAL ALGORITHM:
## Chain 1:   This procedure has not been thoroughly tested and may be unstable
## Chain 1:   or buggy. The interface is subject to change.
## Chain 1: ------------------------------------------------------------
## Chain 1: 
## Chain 1: 
## Chain 1: 
## Chain 1: Gradient evaluation took 0.011 seconds
## Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 110 seconds.
## Chain 1: Adjust your expectations accordingly!
## Chain 1: 
## Chain 1: 
## Chain 1: Begin eta adaptation.
## Chain 1: Iteration:   1 / 250 [  0%]  (Adaptation)
## Chain 1: Iteration:  50 / 250 [ 20%]  (Adaptation)
## Chain 1: Iteration: 100 / 250 [ 40%]  (Adaptation)
## Chain 1: Iteration: 150 / 250 [ 60%]  (Adaptation)
## Chain 1: Iteration: 200 / 250 [ 80%]  (Adaptation)
## Chain 1: Iteration: 250 / 250 [100%]  (Adaptation)
## Chain 1: Success! Found best value [eta = 0.1].
## Chain 1: 
## Chain 1: Begin stochastic gradient ascent.
## Chain 1:   iter             ELBO   delta_ELBO_mean   delta_ELBO_med   notes 
## Chain 1:    100       -48183.741             1.000            1.000
## Chain 1:    200       -37787.028             0.638            1.000
## Chain 1:    300       -33920.457             0.463            0.275
## Chain 1:    400       -32018.392             0.362            0.275
## Chain 1:    500       -31049.985             0.296            0.114
## Chain 1:    600       -30539.150             0.249            0.114
## Chain 1:    700       -30255.471             0.215            0.059
## Chain 1:    800       -30078.856             0.189            0.059
## Chain 1:    900       -29963.679             0.168            0.031
## Chain 1:   1000       -29885.896             0.152            0.031
## Chain 1:   1100       -29844.970             0.138            0.017
## Chain 1:   1200       -29813.140             0.127            0.017
## Chain 1:   1300       -29775.411             0.117            0.009
## Chain 1:   1400       -29750.232             0.109            0.009
## Chain 1:   1500       -29736.669             0.102            0.006
## Chain 1:   1600       -29703.923             0.095            0.006
## Chain 1:   1700       -29688.122             0.090            0.004
## Chain 1:   1800       -29682.554             0.085            0.004
## Chain 1:   1900       -29659.169             0.080            0.003
## Chain 1:   2000       -29653.636             0.076            0.003
## Chain 1:   2100       -29631.742             0.026            0.001
## Chain 1:   2200       -29648.245             0.013            0.001
## Chain 1:   2300       -29641.365             0.007            0.001
## Chain 1:   2400       -29626.957             0.004            0.001
## Chain 1:   2500       -29622.464             0.002            0.001
## Chain 1:   2600       -29624.156             0.002            0.001
## Chain 1:   2700       -29619.608             0.001            0.001
## Chain 1:   2800       -29612.852             0.001            0.001
## Chain 1:   2900       -29605.088             0.001            0.001
## Chain 1:   3000       -29591.568             0.001            0.000
## Chain 1:   3100       -29589.321             0.000            0.000
## Chain 1:   3200       -29606.779             0.000            0.000
## Chain 1:   3300       -29585.188             0.000            0.000
## Chain 1:   3400       -29578.899             0.000            0.000
## Chain 1:   3500       -29589.313             0.000            0.000
## Chain 1:   3600       -29583.928             0.000            0.000
## Chain 1:   3700       -29584.561             0.000            0.000
## Chain 1:   3800       -29576.700             0.000            0.000
## Chain 1:   3900       -29562.229             0.000            0.000
## Chain 1:   4000       -29571.346             0.000            0.000
## Chain 1:   4100       -29566.988             0.000            0.000
## Chain 1:   4200       -29569.339             0.000            0.000
## Chain 1:   4300       -29553.219             0.000            0.000
## Chain 1:   4400       -29556.885             0.000            0.000
## Chain 1:   4500       -29568.414             0.000            0.000
## Chain 1:   4600       -29552.321             0.000            0.000
## Chain 1:   4700       -29553.701             0.000            0.000
## Chain 1:   4800       -29534.613             0.000            0.000
## Chain 1:   4900       -29566.776             0.000            0.000
## Chain 1:   5000       -29545.501             0.000            0.000
## Chain 1:   5100       -29545.123             0.000            0.000
## Chain 1:   5200       -29543.037             0.000            0.000
## Chain 1:   5300       -29542.104             0.000            0.000
## Chain 1:   5400       -29545.956             0.000            0.000
## Chain 1:   5500       -29536.127             0.000            0.000
## Chain 1:   5600       -29552.638             0.000            0.000
## Chain 1:   5700       -29553.743             0.000            0.000
## Chain 1:   5800       -29542.600             0.000            0.000
## Chain 1:   5900       -29551.033             0.000            0.000
## Chain 1:   6000       -29544.900             0.000            0.000
## Chain 1:   6100       -29543.025             0.000            0.000
## Chain 1:   6200       -29558.073             0.000            0.000
## Chain 1:   6300       -29539.640             0.000            0.000
## Chain 1:   6400       -29520.316             0.000            0.000
## Chain 1:   6500       -29519.052             0.000            0.000
## Chain 1:   6600       -29536.195             0.000            0.000
## Chain 1:   6700       -29516.718             0.000            0.000
## Chain 1:   6800       -29512.379             0.000            0.000
## Chain 1:   6900       -29528.702             0.000            0.000
## Chain 1:   7000       -29537.065             0.000            0.000
## Chain 1:   7100       -29545.159             0.000            0.000
## Chain 1:   7200       -29520.462             0.000            0.000
## Chain 1:   7300       -29515.842             0.000            0.000
## Chain 1:   7400       -29534.523             0.000            0.000
## Chain 1:   7500       -29523.843             0.000            0.000
## Chain 1:   7600       -29517.633             0.000            0.000
## Chain 1:   7700       -29518.182             0.000            0.000
## Chain 1:   7800       -29523.754             0.000            0.000
## Chain 1:   7900       -29529.949             0.000            0.000
## Chain 1:   8000       -29517.329             0.000            0.000
## Chain 1:   8100       -29527.550             0.000            0.000
## Chain 1:   8200       -29515.025             0.000            0.000
## Chain 1:   8300       -29533.075             0.000            0.000
## Chain 1:   8400       -29517.548             0.000            0.000
## Chain 1:   8500       -29521.642             0.000            0.000
## Chain 1:   8600       -29538.412             0.000            0.000
## Chain 1:   8700       -29516.891             0.000            0.000
## Chain 1:   8800       -29522.746             0.000            0.000
## Chain 1:   8900       -29523.749             0.000            0.000
## Chain 1:   9000       -29517.389             0.000            0.000
## Chain 1:   9100       -29524.299             0.000            0.000
## Chain 1:   9200       -29509.135             0.000            0.000
## Chain 1:   9300       -29505.334             0.000            0.000
## Chain 1:   9400       -29519.273             0.000            0.000
## Chain 1:   9500       -29516.994             0.000            0.000
## Chain 1:   9600       -29507.503             0.000            0.000
## Chain 1:   9700       -29510.013             0.000            0.000
## Chain 1:   9800       -29514.711             0.000            0.000
## Chain 1:   9900       -29514.461             0.000            0.000
## Chain 1:   10000       -29501.926             0.000            0.000
## Chain 1:   10100       -29500.617             0.000            0.000
## Chain 1:   10200       -29518.666             0.000            0.000
## Chain 1:   10300       -29498.389             0.000            0.000
## Chain 1:   10400       -29515.645             0.000            0.000
## Chain 1:   10500       -29503.168             0.000            0.000
## Chain 1:   10600       -29512.006             0.000            0.000
## Chain 1:   10700       -29499.568             0.000            0.000
## Chain 1:   10800       -29501.279             0.000            0.000
## Chain 1:   10900       -29486.968             0.000            0.000
## Chain 1:   11000       -29506.212             0.000            0.000
## Chain 1:   11100       -29496.516             0.000            0.000
## Chain 1:   11200       -29502.912             0.000            0.000
## Chain 1:   11300       -29495.837             0.000            0.000
## Chain 1:   11400       -29497.001             0.000            0.000
## Chain 1:   11500       -29498.716             0.000            0.000
## Chain 1:   11600       -29502.049             0.000            0.000
## Chain 1:   11700       -29506.724             0.000            0.000
## Chain 1:   11800       -29493.078             0.000            0.000
## Chain 1:   11900       -29509.189             0.000            0.000
## Chain 1:   12000       -29497.664             0.000            0.000
## Chain 1:   12100       -29515.279             0.000            0.000
## Chain 1:   12200       -29507.872             0.000            0.000
## Chain 1:   12300       -29504.915             0.000            0.000
## Chain 1:   12400       -29500.495             0.000            0.000
## Chain 1:   12500       -29514.351             0.000            0.000
## Chain 1:   12600       -29486.397             0.000            0.000
## Chain 1:   12700       -29502.008             0.000            0.000
## Chain 1:   12800       -29485.411             0.000            0.000
## Chain 1:   12900       -29495.497             0.000            0.000
## Chain 1:   13000       -29497.081             0.000            0.000
## Chain 1:   13100       -29495.475             0.000            0.000
## Chain 1:   13200       -29489.905             0.000            0.000
## Chain 1:   13300       -29511.904             0.000            0.000
## Chain 1:   13400       -29495.364             0.000            0.000
## Chain 1:   13500       -29489.610             0.000            0.000
## Chain 1:   13600       -29497.392             0.000            0.000
## Chain 1:   13700       -29493.423             0.000            0.000
## Chain 1:   13800       -29483.785             0.000            0.000
## Chain 1:   13900       -29480.553             0.000            0.000
## Chain 1:   14000       -29472.651             0.000            0.000
## Chain 1:   14100       -29513.662             0.000            0.000
## Chain 1:   14200       -29491.323             0.000            0.000
## Chain 1:   14300       -29502.804             0.000            0.000
## Chain 1:   14400       -29504.835             0.000            0.000
## Chain 1:   14500       -29484.004             0.000            0.000
## Chain 1:   14600       -29493.765             0.000            0.000
## Chain 1:   14700       -29486.752             0.000            0.000
## Chain 1:   14800       -29508.250             0.000            0.000
## Chain 1:   14900       -29504.548             0.000            0.000
## Chain 1:   15000       -29501.379             0.000            0.000
## Chain 1:   15100       -29493.602             0.000            0.000
## Chain 1:   15200       -29516.926             0.000            0.000
## Chain 1:   15300       -29492.022             0.000            0.000
## Chain 1:   15400       -29483.829             0.000            0.000
## Chain 1:   15500       -29499.996             0.000            0.000
## Chain 1:   15600       -29508.249             0.000            0.000
## Chain 1:   15700       -29488.343             0.000            0.000
## Chain 1:   15800       -29488.354             0.000            0.000
## Chain 1:   15900       -29502.768             0.000            0.000
## Chain 1:   16000       -29500.562             0.000            0.000
## Chain 1:   16100       -29506.384             0.000            0.000
## Chain 1:   16200       -29491.529             0.000            0.000
## Chain 1:   16300       -29496.184             0.000            0.000
## Chain 1:   16400       -29488.131             0.000            0.000
## Chain 1:   16500       -29481.007             0.000            0.000
## Chain 1:   16600       -29486.580             0.000            0.000
## Chain 1:   16700       -29500.955             0.000            0.000
## Chain 1:   16800       -29487.044             0.000            0.000
## Chain 1:   16900       -29488.955             0.000            0.000
## Chain 1:   17000       -29516.595             0.000            0.000
## Chain 1:   17100       -29487.480             0.000            0.000
## Chain 1:   17200       -29476.657             0.000            0.000
## Chain 1:   17300       -29510.686             0.000            0.000
## Chain 1:   17400       -29485.847             0.000            0.000
## Chain 1:   17500       -29502.130             0.000            0.000
## Chain 1:   17600       -29494.418             0.000            0.000
## Chain 1:   17700       -29501.547             0.000            0.000
## Chain 1:   17800       -29485.522             0.000            0.000
## Chain 1:   17900       -29490.063             0.000            0.000
## Chain 1:   18000       -29496.208             0.000            0.000
## Chain 1:   18100       -29486.851             0.000            0.000
## Chain 1:   18200       -29501.961             0.000            0.000
## Chain 1:   18300       -29477.489             0.000            0.000
## Chain 1:   18400       -29485.276             0.000            0.000
## Chain 1:   18500       -29481.542             0.000            0.000
## Chain 1:   18600       -29474.810             0.000            0.000
## Chain 1:   18700       -29479.013             0.000            0.000
## Chain 1:   18800       -29490.588             0.000            0.000
## Chain 1:   18900       -29487.388             0.000            0.000
## Chain 1:   19000       -29492.016             0.000            0.000
## Chain 1:   19100       -29506.302             0.000            0.000
## Chain 1:   19200       -29488.112             0.000            0.000
## Chain 1:   19300       -29496.393             0.000            0.000
## Chain 1:   19400       -29495.766             0.000            0.000
## Chain 1:   19500       -29471.677             0.000            0.000
## Chain 1:   19600       -29482.190             0.000            0.000
## Chain 1:   19700       -29494.035             0.000            0.000
## Chain 1:   19800       -29497.125             0.000            0.000
## Chain 1:   19900       -29491.016             0.000            0.000
## Chain 1:   20000       -29486.008             0.000            0.000
## Chain 1: Informational Message: The maximum number of iterations is reached! The algorithm may not have converged.
## Chain 1: This variational approximation is not guaranteed to be meaningful.
## Chain 1: 
## Chain 1: Drawing a sample of size 1000 from the approximate posterior... 
## Chain 1: COMPLETED.
id_plot_legis_dyn(del_est_ar1,use_ci = F) +
  scale_color_manual(values=c(R='red',
                              D='blue',
                              X='green'))

While most of the ideal points are relatively stationary, a handful oscillate across the ideal point spectrum, likely a sign of limited information about the true location of their ideal points. We could further crank down the variance to prevent oscillation, but I left this plot in as an illustration of when model-fitting produces a model that doesn’t work for all legislators. This model could still work, though, if the sole purpose was to test the effect of covariates.

Finally, we can also examine the individual ideal points by each time point using the summary function:

summary(del_est_ar1,pars='ideal_pts') %>% 
  head %>% 
  knitr::kable(.)
Person Group Time_Point Low Posterior Interval Posterior Median High Posterior Interval Parameter Name
Adams, Thurman Jr. 113 D 1995-01-01 1.283311 1.507530 1.7436420 L_tp1[1,1]
Bennett, E. 7 D 1995-01-01 1.104370 1.480680 1.8686430 L_tp1[1,10]
Plant, Hazel 77 D 1995-01-01 1.160098 1.530215 1.8746655 L_tp1[1,100]
Poore, Nicole 138 D 1995-01-01 1.149818 1.501750 1.8532020 L_tp1[1,101]
Postles, Charles S. 78 R 1995-01-01 -1.913669 -1.277445 -0.6450675 L_tp1[1,102]
Potter, Charles Jr. 79 D 1995-01-01 1.036874 1.403665 1.7838425 L_tp1[1,103]

To examine trace plots of the actual MCMC sampling, we can use the stan_plot function to look at posterior sampling for the first time point for Lamar Alexander based on the value shown in Parameter Name in the table above:

stan_trace(del_est_ar1,'L_tp1[1,1]')

Group-level Time-varying Ideal Points

Finally, we can also change the model’s parameters to look at group-level, i.e. party-level, ideal points. To do so we need to specify the use_groups=T option in the id_estimate function, and we change the restricted parameters to parties:

del_est_rw3 <- id_estimate(delaware_data,
                model_type = 2,
                 use_vb = T,
                time_sd=0.2,
                use_groups = T,
                fixtype='vb_partial',
                vary_ideal_pts='random_walk',
                 restrict_ind_high = "D",
                 restrict_ind_low="R",
            seed=84520)
## Chain 1: ------------------------------------------------------------
## Chain 1: EXPERIMENTAL ALGORITHM:
## Chain 1:   This procedure has not been thoroughly tested and may be unstable
## Chain 1:   or buggy. The interface is subject to change.
## Chain 1: ------------------------------------------------------------
## Chain 1: 
## Chain 1: 
## Chain 1: 
## Chain 1: Gradient evaluation took 0.011 seconds
## Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 110 seconds.
## Chain 1: Adjust your expectations accordingly!
## Chain 1: 
## Chain 1: 
## Chain 1: Begin eta adaptation.
## Chain 1: Iteration:   1 / 250 [  0%]  (Adaptation)
## Chain 1: Iteration:  50 / 250 [ 20%]  (Adaptation)
## Chain 1: Iteration: 100 / 250 [ 40%]  (Adaptation)
## Chain 1: Iteration: 150 / 250 [ 60%]  (Adaptation)
## Chain 1: Iteration: 200 / 250 [ 80%]  (Adaptation)
## Chain 1: Success! Found best value [eta = 1] earlier than expected.
## Chain 1: 
## Chain 1: Begin stochastic gradient ascent.
## Chain 1:   iter             ELBO   delta_ELBO_mean   delta_ELBO_med   notes 
## Chain 1:    100       -76982.554             1.000            1.000
## Chain 1:    200       -76437.183             0.504            1.000
## Chain 1:    300       -76264.767             0.336            0.007
## Chain 1:    400       -76095.977             0.253            0.007
## Chain 1:    500       -76035.921             0.202            0.002
## Chain 1:    600       -75979.524             0.169            0.002
## Chain 1:    700       -75943.735             0.145            0.002
## Chain 1:    800       -75924.850             0.127            0.002
## Chain 1:    900       -75908.908             0.113            0.001
## Chain 1:   1000       -75878.978             0.101            0.001
## Chain 1:   1100       -75837.341             0.092            0.001
## Chain 1:   1200       -75823.056             0.085            0.001
## Chain 1:   1300       -75848.798             0.078            0.001
## Chain 1:   1400       -75815.924             0.073            0.001
## Chain 1:   1500       -75798.534             0.068            0.000
## Chain 1:   1600       -75780.631             0.064            0.000
## Chain 1:   1700       -75824.625             0.060            0.000
## Chain 1:   1800       -75787.133             0.057            0.000
## Chain 1:   1900       -75779.346             0.054            0.000
## Chain 1:   2000       -75769.142             0.051            0.000
## Chain 1:   2100       -75766.350             0.001            0.000
## Chain 1:   2200       -75776.520             0.001            0.000
## Chain 1:   2300       -75758.045             0.000            0.000
## Chain 1:   2400       -75764.225             0.000            0.000
## Chain 1:   2500       -75748.626             0.000            0.000
## Chain 1:   2600       -75742.094             0.000            0.000
## Chain 1:   2700       -75749.869             0.000            0.000
## Chain 1:   2800       -75750.151             0.000            0.000
## Chain 1:   2900       -75760.362             0.000            0.000
## Chain 1:   3000       -75731.380             0.000            0.000
## Chain 1:   3100       -75740.340             0.000            0.000
## Chain 1:   3200       -75746.765             0.000            0.000
## Chain 1:   3300       -75736.843             0.000            0.000
## Chain 1:   3400       -75732.492             0.000            0.000
## Chain 1:   3500       -75740.606             0.000            0.000
## Chain 1:   3600       -75718.534             0.000            0.000
## Chain 1:   3700       -75751.297             0.000            0.000
## Chain 1:   3800       -75727.455             0.000            0.000
## Chain 1:   3900       -75725.270             0.000            0.000
## Chain 1:   4000       -75730.271             0.000            0.000
## Chain 1:   4100       -75723.341             0.000            0.000
## Chain 1:   4200       -75728.637             0.000            0.000
## Chain 1:   4300       -75723.571             0.000            0.000
## Chain 1:   4400       -75729.011             0.000            0.000
## Chain 1:   4500       -75726.846             0.000            0.000   MEDIAN ELBO CONVERGED
## Chain 1: 
## Chain 1: Drawing a sample of size 1000 from the approximate posterior... 
## Chain 1: COMPLETED.
id_plot_legis_dyn(del_est_rw3,
                  include=c('D','R')) + scale_colour_manual(values=c(R='red',
                                                          D='blue',
                                                          I='green'),
                                                 name="Parties")

We can also overlay a bill/item midpoint to see where the line of indifference in voting is relative to party positions. In a dynamic ideal point model, the bill/item midpoint will be a straight line as the bill-item midpoint was only voted on in one time point, and hence has only one parameter:

id_plot_legis_dyn(del_est_rw3,item_plot='342',
                  text_size_label = 5,
                  include=c('D','R')) + scale_colour_manual(values=c(R='red',
                                                          D='blue',
                                                          I='green'),
                                                 name="Parties") +
  ggtitle('Time-Varying Party-level Ideal Points for the Delaware State Legislature',
          subtitle = 'Midpoint (Line of Indifference to Voting) for 342nd Roll-call Vote as Dotted Line') +
  guides(color='none') +
  annotate(geom='text',
           x = ymd('2016-01-01'),
           y=-1,
           label='Confirmation Vote for Wilhelmina Wright as U.S. District Judge')

As this plot shows, the line of indifference is in a no-person’s zone in the middle of the plot, signifying the lack of overlap and consensus on legislation in the current Senate.

I will now estimate additional AR(1) and a Gaussian process model to use as comparison points to the random-walk model for parties:

del_est_ar2 <- id_estimate(delaware_data,
                model_type = 2,
                 use_vb = T,
                time_sd=0.2,
                use_groups = T,
                fixtype='vb_partial',
                vary_ideal_pts='AR1',
                 restrict_ind_high = "D",
                 restrict_ind_low="R",
            seed=84520)
## Chain 1: ------------------------------------------------------------
## Chain 1: EXPERIMENTAL ALGORITHM:
## Chain 1:   This procedure has not been thoroughly tested and may be unstable
## Chain 1:   or buggy. The interface is subject to change.
## Chain 1: ------------------------------------------------------------
## Chain 1: 
## Chain 1: 
## Chain 1: 
## Chain 1: Gradient evaluation took 0.011 seconds
## Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 110 seconds.
## Chain 1: Adjust your expectations accordingly!
## Chain 1: 
## Chain 1: 
## Chain 1: Begin eta adaptation.
## Chain 1: Iteration:   1 / 250 [  0%]  (Adaptation)
## Chain 1: Iteration:  50 / 250 [ 20%]  (Adaptation)
## Chain 1: Iteration: 100 / 250 [ 40%]  (Adaptation)
## Chain 1: Iteration: 150 / 250 [ 60%]  (Adaptation)
## Chain 1: Iteration: 200 / 250 [ 80%]  (Adaptation)
## Chain 1: Success! Found best value [eta = 1] earlier than expected.
## Chain 1: 
## Chain 1: Begin stochastic gradient ascent.
## Chain 1:   iter             ELBO   delta_ELBO_mean   delta_ELBO_med   notes 
## Chain 1:    100       -30149.866             1.000            1.000
## Chain 1:    200       -29836.895             0.505            1.000
## Chain 1:    300       -29762.299             0.338            0.010
## Chain 1:    400       -29713.424             0.254            0.010
## Chain 1:    500       -29693.876             0.203            0.003
## Chain 1:    600       -29669.868             0.169            0.003
## Chain 1:    700       -29679.070             0.145            0.002
## Chain 1:    800       -29684.109             0.127            0.002
## Chain 1:    900       -29630.277             0.113            0.002
## Chain 1:   1000       -29621.153             0.102            0.002
## Chain 1:   1100       -29606.684             0.093            0.001
## Chain 1:   1200       -29600.046             0.085            0.001
## Chain 1:   1300       -29613.163             0.078            0.001
## Chain 1:   1400       -29599.019             0.073            0.001
## Chain 1:   1500       -29586.074             0.068            0.000
## Chain 1:   1600       -29568.490             0.064            0.001
## Chain 1:   1700       -29552.141             0.060            0.001
## Chain 1:   1800       -29586.664             0.057            0.001
## Chain 1:   1900       -29573.367             0.054            0.001
## Chain 1:   2000       -29558.048             0.051            0.001
## Chain 1:   2100       -29561.164             0.001            0.001
## Chain 1:   2200       -29559.348             0.001            0.000
## Chain 1:   2300       -29570.166             0.001            0.000
## Chain 1:   2400       -29579.341             0.001            0.000
## Chain 1:   2500       -29553.670             0.001            0.000
## Chain 1:   2600       -29547.005             0.000            0.000
## Chain 1:   2700       -29556.460             0.000            0.000
## Chain 1:   2800       -29545.536             0.001            0.000
## Chain 1:   2900       -29549.433             0.000            0.000
## Chain 1:   3000       -29539.794             0.000            0.000
## Chain 1:   3100       -29546.344             0.000            0.000
## Chain 1:   3200       -29542.059             0.000            0.000
## Chain 1:   3300       -29530.047             0.000            0.000
## Chain 1:   3400       -29528.722             0.000            0.000
## Chain 1:   3500       -29539.556             0.000            0.000
## Chain 1:   3600       -29526.786             0.000            0.000
## Chain 1:   3700       -29538.712             0.000            0.000
## Chain 1:   3800       -29531.398             0.000            0.000
## Chain 1:   3900       -29541.907             0.000            0.000
## Chain 1:   4000       -29526.209             0.000            0.000
## Chain 1:   4100       -29528.879             0.000            0.000
## Chain 1:   4200       -29519.846             0.000            0.000
## Chain 1:   4300       -29531.457             0.000            0.000
## Chain 1:   4400       -29520.414             0.000            0.000
## Chain 1:   4500       -29521.594             0.000            0.000
## Chain 1:   4600       -29521.714             0.000            0.000
## Chain 1:   4700       -29519.389             0.000            0.000
## Chain 1:   4800       -29522.214             0.000            0.000
## Chain 1:   4900       -29519.735             0.000            0.000
## Chain 1:   5000       -29507.465             0.000            0.000
## Chain 1:   5100       -29521.328             0.000            0.000
## Chain 1:   5200       -29512.146             0.000            0.000
## Chain 1:   5300       -29542.612             0.000            0.000
## Chain 1:   5400       -29516.019             0.000            0.000
## Chain 1:   5500       -29522.272             0.000            0.000
## Chain 1:   5600       -29517.737             0.000            0.000
## Chain 1:   5700       -29513.701             0.000            0.000
## Chain 1:   5800       -29512.665             0.000            0.000
## Chain 1:   5900       -29508.489             0.000            0.000
## Chain 1:   6000       -29510.899             0.000            0.000
## Chain 1:   6100       -29510.038             0.000            0.000
## Chain 1:   6200       -29518.481             0.000            0.000
## Chain 1:   6300       -29507.113             0.000            0.000
## Chain 1:   6400       -29508.178             0.000            0.000
## Chain 1:   6500       -29499.759             0.000            0.000
## Chain 1:   6600       -29496.607             0.000            0.000
## Chain 1:   6700       -29504.669             0.000            0.000
## Chain 1:   6800       -29509.476             0.000            0.000
## Chain 1:   6900       -29511.629             0.000            0.000
## Chain 1:   7000       -29501.483             0.000            0.000
## Chain 1:   7100       -29496.896             0.000            0.000
## Chain 1:   7200       -29507.130             0.000            0.000
## Chain 1:   7300       -29507.343             0.000            0.000
## Chain 1:   7400       -29511.002             0.000            0.000
## Chain 1:   7500       -29492.190             0.000            0.000
## Chain 1:   7600       -29496.672             0.000            0.000
## Chain 1:   7700       -29504.455             0.000            0.000
## Chain 1:   7800       -29492.290             0.000            0.000
## Chain 1:   7900       -29517.293             0.000            0.000
## Chain 1:   8000       -29512.350             0.000            0.000
## Chain 1:   8100       -29502.434             0.000            0.000
## Chain 1:   8200       -29485.079             0.000            0.000
## Chain 1:   8300       -29504.212             0.000            0.000
## Chain 1:   8400       -29501.386             0.000            0.000
## Chain 1:   8500       -29500.136             0.000            0.000
## Chain 1:   8600       -29499.941             0.000            0.000
## Chain 1:   8700       -29495.532             0.000            0.000
## Chain 1:   8800       -29497.346             0.000            0.000
## Chain 1:   8900       -29507.671             0.000            0.000
## Chain 1:   9000       -29487.153             0.000            0.000
## Chain 1:   9100       -29504.107             0.000            0.000
## Chain 1:   9200       -29506.952             0.000            0.000
## Chain 1:   9300       -29483.281             0.000            0.000
## Chain 1:   9400       -29507.215             0.000            0.000
## Chain 1:   9500       -29507.739             0.000            0.000
## Chain 1:   9600       -29497.631             0.000            0.000
## Chain 1:   9700       -29499.924             0.000            0.000
## Chain 1:   9800       -29502.960             0.000            0.000
## Chain 1:   9900       -29483.932             0.000            0.000
## Chain 1:   10000       -29512.219             0.000            0.000
## Chain 1:   10100       -29493.376             0.000            0.000
## Chain 1:   10200       -29499.825             0.000            0.000
## Chain 1:   10300       -29498.173             0.000            0.000
## Chain 1:   10400       -29497.088             0.000            0.000
## Chain 1:   10500       -29482.510             0.000            0.000
## Chain 1:   10600       -29494.030             0.000            0.000
## Chain 1:   10700       -29482.191             0.000            0.000
## Chain 1:   10800       -29494.381             0.000            0.000
## Chain 1:   10900       -29492.055             0.000            0.000
## Chain 1:   11000       -29501.922             0.000            0.000
## Chain 1:   11100       -29510.930             0.000            0.000
## Chain 1:   11200       -29499.430             0.000            0.000
## Chain 1:   11300       -29497.879             0.000            0.000
## Chain 1:   11400       -29492.030             0.000            0.000
## Chain 1:   11500       -29479.635             0.000            0.000
## Chain 1:   11600       -29502.251             0.000            0.000
## Chain 1:   11700       -29488.106             0.000            0.000
## Chain 1:   11800       -29489.104             0.000            0.000
## Chain 1:   11900       -29487.339             0.000            0.000
## Chain 1:   12000       -29496.874             0.000            0.000
## Chain 1:   12100       -29495.565             0.000            0.000
## Chain 1:   12200       -29483.638             0.000            0.000
## Chain 1:   12300       -29498.526             0.000            0.000
## Chain 1:   12400       -29491.305             0.000            0.000
## Chain 1:   12500       -29495.202             0.000            0.000
## Chain 1:   12600       -29494.428             0.000            0.000
## Chain 1:   12700       -29490.940             0.000            0.000
## Chain 1:   12800       -29493.420             0.000            0.000
## Chain 1:   12900       -29486.928             0.000            0.000
## Chain 1:   13000       -29492.358             0.000            0.000
## Chain 1:   13100       -29493.466             0.000            0.000
## Chain 1:   13200       -29485.395             0.000            0.000
## Chain 1:   13300       -29507.190             0.000            0.000
## Chain 1:   13400       -29477.035             0.000            0.000
## Chain 1:   13500       -29497.757             0.000            0.000
## Chain 1:   13600       -29478.932             0.000            0.000
## Chain 1:   13700       -29492.790             0.000            0.000
## Chain 1:   13800       -29498.555             0.000            0.000
## Chain 1:   13900       -29491.009             0.000            0.000
## Chain 1:   14000       -29471.730             0.000            0.000
## Chain 1:   14100       -29484.021             0.000            0.000
## Chain 1:   14200       -29475.802             0.000            0.000
## Chain 1:   14300       -29488.001             0.000            0.000
## Chain 1:   14400       -29483.016             0.000            0.000
## Chain 1:   14500       -29480.766             0.000            0.000
## Chain 1:   14600       -29480.429             0.000            0.000
## Chain 1:   14700       -29493.578             0.000            0.000
## Chain 1:   14800       -29482.203             0.000            0.000
## Chain 1:   14900       -29477.933             0.000            0.000
## Chain 1:   15000       -29483.362             0.000            0.000
## Chain 1:   15100       -29496.306             0.000            0.000
## Chain 1:   15200       -29493.616             0.000            0.000
## Chain 1:   15300       -29491.651             0.000            0.000
## Chain 1:   15400       -29506.876             0.000            0.000
## Chain 1:   15500       -29488.223             0.000            0.000
## Chain 1:   15600       -29493.966             0.000            0.000
## Chain 1:   15700       -29484.366             0.000            0.000
## Chain 1:   15800       -29486.475             0.000            0.000
## Chain 1:   15900       -29486.342             0.000            0.000
## Chain 1:   16000       -29491.577             0.000            0.000
## Chain 1:   16100       -29490.506             0.000            0.000
## Chain 1:   16200       -29487.604             0.000            0.000
## Chain 1:   16300       -29480.673             0.000            0.000
## Chain 1:   16400       -29493.374             0.000            0.000
## Chain 1:   16500       -29481.995             0.000            0.000
## Chain 1:   16600       -29484.847             0.000            0.000
## Chain 1:   16700       -29476.910             0.000            0.000
## Chain 1:   16800       -29482.364             0.000            0.000
## Chain 1:   16900       -29482.320             0.000            0.000
## Chain 1:   17000       -29492.254             0.000            0.000
## Chain 1:   17100       -29481.689             0.000            0.000
## Chain 1:   17200       -29480.946             0.000            0.000
## Chain 1:   17300       -29486.079             0.000            0.000
## Chain 1:   17400       -29471.588             0.000            0.000
## Chain 1:   17500       -29477.781             0.000            0.000
## Chain 1:   17600       -29493.119             0.000            0.000
## Chain 1:   17700       -29479.387             0.000            0.000
## Chain 1:   17800       -29488.799             0.000            0.000
## Chain 1:   17900       -29480.429             0.000            0.000
## Chain 1:   18000       -29482.286             0.000            0.000
## Chain 1:   18100       -29499.377             0.000            0.000
## Chain 1:   18200       -29481.808             0.000            0.000
## Chain 1:   18300       -29489.742             0.000            0.000
## Chain 1:   18400       -29499.288             0.000            0.000
## Chain 1:   18500       -29483.237             0.000            0.000
## Chain 1:   18600       -29485.837             0.000            0.000
## Chain 1:   18700       -29486.339             0.000            0.000
## Chain 1:   18800       -29481.478             0.000            0.000
## Chain 1:   18900       -29489.440             0.000            0.000
## Chain 1:   19000       -29498.715             0.000            0.000
## Chain 1:   19100       -29482.132             0.000            0.000
## Chain 1:   19200       -29478.789             0.000            0.000
## Chain 1:   19300       -29477.871             0.000            0.000
## Chain 1:   19400       -29477.461             0.000            0.000
## Chain 1:   19500       -29481.682             0.000            0.000
## Chain 1:   19600       -29482.110             0.000            0.000
## Chain 1:   19700       -29484.493             0.000            0.000
## Chain 1:   19800       -29486.450             0.000            0.000
## Chain 1:   19900       -29496.255             0.000            0.000
## Chain 1:   20000       -29485.451             0.000            0.000
## Chain 1: Informational Message: The maximum number of iterations is reached! The algorithm may not have converged.
## Chain 1: This variational approximation is not guaranteed to be meaningful.
## Chain 1: 
## Chain 1: Drawing a sample of size 1000 from the approximate posterior... 
## Chain 1: COMPLETED.
del_est_gp1 <- id_estimate(delaware_data,
                           model_type = 2,
                           use_vb = T,
                           tol_rel_obj = .0005,
                           use_groups = T,
                           gp_sd_par = 0.025,
                           gp_m_sd_par =c(0.3,10),
                           gp_num_diff=c(3,.01),
                           gp_min_length = 0,
                           fixtype='vb_partial',
                           vary_ideal_pts='GP',
                           restrict_ind_high = "D",
                           restrict_ind_low="R",
                            seed=84520)
## Chain 1: ------------------------------------------------------------
## Chain 1: EXPERIMENTAL ALGORITHM:
## Chain 1:   This procedure has not been thoroughly tested and may be unstable
## Chain 1:   or buggy. The interface is subject to change.
## Chain 1: ------------------------------------------------------------
## Chain 1: 
## Chain 1: 
## Chain 1: 
## Chain 1: Gradient evaluation took 0.01 seconds
## Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 100 seconds.
## Chain 1: Adjust your expectations accordingly!
## Chain 1: 
## Chain 1: 
## Chain 1: Begin eta adaptation.
## Chain 1: Iteration:   1 / 250 [  0%]  (Adaptation)
## Chain 1: Iteration:  50 / 250 [ 20%]  (Adaptation)
## Chain 1: Iteration: 100 / 250 [ 40%]  (Adaptation)
## Chain 1: Iteration: 150 / 250 [ 60%]  (Adaptation)
## Chain 1: Iteration: 200 / 250 [ 80%]  (Adaptation)
## Chain 1: Success! Found best value [eta = 1] earlier than expected.
## Chain 1: 
## Chain 1: Begin stochastic gradient ascent.
## Chain 1:   iter             ELBO   delta_ELBO_mean   delta_ELBO_med   notes 
## Chain 1:    200       -30497.757             1.000            1.000
## Chain 1:    400       -30357.173             0.502            1.000
## Chain 1:    600       -30311.158             0.335            0.005
## Chain 1:    800       -30261.071             0.252            0.005
## Chain 1:   1000       -30267.802             0.202            0.002
## Chain 1:   1200       -30264.078             0.168            0.002
## Chain 1:   1400       -30237.364             0.144            0.002
## Chain 1:   1600       -30251.306             0.126            0.002
## Chain 1:   1800       -30238.626             0.112            0.001
## Chain 1:   2000       -30230.216             0.101            0.001
## Chain 1:   2200       -30235.146             0.001            0.000   MEDIAN ELBO CONVERGED
## Chain 1: 
## Chain 1: Drawing a sample of size 1000 from the approximate posterior... 
## Chain 1: COMPLETED.

We can the use an option in the id_plot_legis_dyn function to pass in all three models as a list to see how they compare to each other over the same groups:

id_plot_legis_dyn(list(RW=del_est_rw3,
                       AR1=del_est_ar2,
                       GP=del_est_gp1),
                  include=c('D','R'))

This plot shows that are substantial divergences between the different models. Broadly speaking, the random-walk and GP models are close to each other, as we might expect given that both models impose relatively little structure on the time series. The AR model, on the other hand, constrains change over time, and it is not surprising that it shows the Democrats and Republicans much closer to each other. The advantage of the AR1 model, of course, is that it can estimate the effect of covariates on the long-term mean of the series, a very precise interpretation.

The GP model has several parameters that control the ability of the time series to wiggle or adjust to over-time change in the ideal points. These parameters are given defaults that restrict movement in the ideal points to help ensure identification. As such, they tend to be fairly conservative, and can be adjusted to see if the ideal points can handle greater variation.

The advantage of the GP model is that it combines the relatively minimalistic structure of the random walk with the ability to fit covariates on the time series. I refer the reader to the covariate vignette for more information about how to fit covariate models using idealstan. It is important to note, however, that the GP interpretation of a covariate is different than the AR1 covariate. In an AR1 model, the value of the covariate represents the shift in the long-term mean of the series, whereas in a GP model the covariate is a non-parametric effect of the covariate on the time series averaged over the entire series. These parameters are explained in the table below:

Parameters in the Gaussian Process Time-Series Model
Parameter Description
gp_sd_par This parameter represents residual variation in the series that the GP does not account for. As such, its default is a very low value, as increasing it will generally increase oscillation in the series.
gp_num_diff This parameter is a multiplier that is used to set the prior for the length-scale of the GP. Loosely speaking, the length-scale determines the number of times that the time-series can cross zero, and so lowering this parameter will decrease the length-scale and subsequently increase the number of times the series can cross zero. The length-scale is given a prior equal to the difference between the maximum and minimum length of the time series in whatever units it is recorded in (days, weeks, etc) times the parameter gp_num_diff. The second numeric value of this parameter represents the standard deviation of the log-normal prior of the length scale. Increasing the standard deviation will put more weight on the data in determining the amount of flexibility in the time series.
gp_m_sd_par This parameter has two values that set the GP’s marginal standard deviation. This parameter loosely represents the amount of time-series variation in the series. The first numeric value represents the hard upper limit for this parameter to prevent the series oscillating. The second numeric value is equal to the shape of an inverse-gamma prior defined over the interval between 0 and the first numeric value (the hard upper limit). It is a weakly informative prior that pulls values away from zero to prevent divergences. Increasing the first numeric value (the upper limit) will increase marginal standard deviation, while the second numeric value can increase marginal standard deviation by decreasing its value, resulting in a flatter inverse-gamma prior.

  1. This is known as calculating the impulse response function. While these can be readily calculated from the raw model output of an idealstan object, they are not currently implemented as functions in the package.