Built using Zelig version 5.1.4.90000


Quinn’s Dynamic Ecological Inference Model with eidynamic in ZeligEI.

Syntax

The EI models accept several different formula syntaxes. If \(C1\) and \(C2\) are the column totals, and \(R1\) and \(R2\) are the row totals, and \(N=R1_i + R2_i = C1_i + C2_i\) is the total in unit \(i\), then the formula can be expressed with just one row and one column, with the totals provided separately as:

z.out <- zelig(C1 ~ R1, N = N, data = data)

The argument N can be either a numeric vector of the total in each i-th unit, or the character name of a variable in the dataset that contains these values.

Or with both rows and columns coupled together, and omitting the totals:

z.out <- zelig( cbind(C1,C2) ~ cbind(R1,R2), data = data)

Additionally, if C1, C2, R1, R2 are percentages rather than counts, then either formula method above is acceptable, however, N must always be provided.

First load packages:

library(zeligverse)

Here is an example of all the syntax for the analysis using the first syntax method, and the direct use of the reference classes:

z5 <- zeidynamic$new()
z5$zelig(C1 ~ R1, N = myN, weights = w, data = myData)

With the Zelig 4 compatibility wrappers this looks like:

z.out <- zelig(C1 ~ R1, N=N, model = "eidynamic", weights = w,
               data = myData)

Additional Inputs

In addition, Zelig accepts the following additional inputs for eidynamic to monitor the convergence of the Markov chain:

  • burnin: number of the initial MCMC iterations to be discarded (defaults to 5,000).
  • mcmc: number of the MCMC iterations after burnin (defaults to 50,000).
  • thin: thinning interval for the Markov chain. Only every thin-th draw from the Markov chain is kept. The value of mcmc must be divisible by this value. The default value is 1.
  • verbose: defaults to FALSE. If TRUE, the progress of the sampler (every 10%) is printed to the screen.
  • seed: seed for the random number generator. The default is NA which corresponds to a random seed of 12345.

The model also accepts the following additional arguments to specify priors and other parameters:

  • W: a \(p\) × \(p\) numeric matrix describing the structure of the temporal dependence among elements of \(\theta_0\) and \(\theta_1\). The default value is 0, which constructs a weight matrix corresponding to random walk priors for \(\theta_0\) and \(\theta_1\) (assuming that the tables are equally spaced throughout time, and that the elements of \(t_0\), \(t_1\), \(x_0\), \(x_1\) are temporally ordered).
  • a0: \(a0/2\) is the shape parameter for the Inverse Gamma prior on \(\sigma_{02}\). The default is 0.825.
  • b0: \(b0/2\) is the scale parameter for the Inverse Gamma prior on \(\sigma_{02}\). The default is 0.0105.
  • a1: \(a1/2\) is the shape parameter for the Inverse Gamma prior on \(\sigma_{12}\). The default is 0.825.
  • b1: \(b1/2\) is the scale parameter for the Inverse Gamma prior on \(\sigma_{12}\). The default is 0.0105.

Users may wish to refer to help(MCMCdynamicEI) for more options.

Examples

You can check for convergence before summarizing the estimates with three diagnostic tests. See the section Diagnostics for Zelig Models for examples of the output with interpretation:

z.out$geweke.diag()
z.out$heidel.diag()
z.out$raftery.diag()

See also

The Quinn dynamic model is part of the MCMCpack package by Andrew Martin, Kevin Quinn, and Jong Hee Park. Advanced users may wish to refer to help(MCMCdynamicEI) in the MCMCpack package.

Quinn K (2004). “Ecological Inference in the Presence of Temporal Dependence.” In King G, Rosen O and Tanner M (eds.), Ecological Inference: New Methodological Strategies. Cambridge University Press, New York.

Martin AD, Quinn KM and Park JH (2011). “MCMCpack: Markov Chain Monte Carlo in R.” Journal of Statistical Software, 42 (9), pp. 22. <URL: http://www.jstatsoft.org/v42/i09/>.