Title: | Dynamic Panel Models with Orthogonal Reparameterization of Fixed Effects |
---|---|
Description: | Implements the orthogonal reparameterization approach recommended by Lancaster (2002) to estimate dynamic panel models with fixed effects (and optionally: panel specific intercepts). The approach uses a likelihood-based estimator and produces estimates that are asymptotically unbiased as N goes to infinity, with a T as low as 2. |
Authors: | Davor Cubranic [aut], Mark Pickup [aut, cre], Paul Gustafson [aut], Geoffrey Evans [aut], Jonoska Stojkova Biljana [ctb] |
Maintainer: | Mark Pickup <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.2-4 |
Built: | 2024-08-15 06:20:52 UTC |
Source: | CRAN |
This package includes the function opm()
, which implements the
orthogonal reparameterization approach recommended by Lancaster
(2002) to estimate dynamic panel models with fixed effects (and
optionally: panel specific intercepts). The OLS estimator for such
models is biased with a fixed (small) (Nickell 1981). Equivalently,
a maximum likelihood estimation leads to an incidental parameters
problem (Neyman and Scott 1948; Lancaster 2000). The approach by
Lancaster (2002) uses an orthogonal reparameterization of the fixed
effects to produce a likelihood-based estimator of the remaining
parameters that is exact and consistent as
approaches infinity
for
greater than or equal to 2.
Orthopanels can accomodate unbalanced panel data, in that some respondents may drop out early (attrition) and some respondents may enter the panel late (refreshment). It is assumed that once respondents enter the panel, they will have observations up until they dropout and then NAs in subsequent waves. The estimation is conducted under the assumption that the data is missing at random
Lancaster, T. (2000) The incidental parameter problem since 1948. Journal of Econometrics, 95, 391–413.
Lancaster, T. (2002) Orthogonal parameters and panel data. Review of Economic Studies, 69, 647–666.
Neyman, J. and Scott, E. L. (1948) Consistent estimation from partially consistent observations. Econometrica, 16, 1–32.
Nickell, S. (1981) Biases in dynamic models with fixed effects. Econometrica, 49, 1417–1426.
The dynamics of labour demand of firm in the United Kingdom
in year
as a function of real product wages, gross capital
stock and industry output. This is done using the data used by
Arellano and Bond (1991).
A data frame with 813 rows and 16 variables
A survey of 1845 respondents using 3 waves of panel survey data from the 2010 British Election Study. The variables are as follows:
id case number
year time wave
n log of employment in firm id
at time year
w natural log of the real product wage
k natural log of gross capital stock
ys natural log of industry output
l_w lag of w
l_k lag of k
l2_k two-step lag of k
l_ys lag of ys
l2_ys two-step lag of ys
yr1980..yr1984 time dummies
Arrelano M., and Bond S. (1991) Some Tests of Specification for Panel Data: Monte Carlo Evidence and an Application to Employment Equations. Review of Economic Studies, 58(2), 277–297.
A survey of 1845 respondents using 3 waves of panel survey data from the 2010 British Election Study. The variables are as follows:
A data frame with 5535 rows and 11 variables
n case number
t time wave
Econ Assessment of change in the national economic situation over the past 12 months (1-5, 1=‘got a lot worse’, 5=‘got a lot better’)
Clegg Evaluation of Liberal Party leader Nick Clegg (0-10, 0=‘strongly dislike’ and 10=‘strongly like’)
Brown Evaluation of Labour Party leader Gordon Brown
Cameron Evaluation of Conservative Party leader David Cameron
Approve Approval of the government, as expressed by feeling about the ruling Labour Party (0-10, 0=‘strongly dislike’, 10=‘strongly like’)
NHS Assesment of the current government's handling of the National Health Service (1-5, 1=‘very badly’, 5=‘very well’)
Terror Assesment of the current government's handling of terrorism (1-5, 1=‘very badly’, 5=‘very well’)
PID Personal identification with the Labour Party (0/1, 0=‘no’, 1=‘yes’)
Tax Preference for policy on taxes and health and social spending (0-10, 0=‘cut taxes a lot and spend much less’, 10=‘increase taxes a lot and spend much more’)
opm
Model ParametersCreates side-by-side plots of equal-tailed credible intervals of opm
model parameters. The intervals are displayed as horizontal lines,
with 90% interval using a thicker line width and 95% interval a
thinner one. The posterior median is indicated with a dot.
caterplot( x, parm, main = paste("Caterpillar plot of", xname), xlab = "Range of parameter samples", labels = colnames(ranges) )
caterplot( x, parm, main = paste("Caterpillar plot of", xname), xlab = "Range of parameter samples", labels = colnames(ranges) )
x |
an instance of class |
parm |
a specification of which parameters are to be plotted,
either a vector of names (" |
main , xlab
|
useful defaults for the plot title and X-axis label |
labels |
labels for each parameter's interval: see |
A matrix of 2.5%, 5%, 50%, 95%, and 97.5% quantiles for each of the desired parameters, with parameters arranged in columns.
## Not run: caterplot(o, main = NULL, labels = expression(alpha, beta, sigma^2)) ## End(Not run)
## Not run: caterplot(o, main = NULL, labels = expression(alpha, beta, sigma^2)) ## End(Not run)
opm
Model ParametersCreates side-by-side plots of equal-tailed credible intervals of opm
the long run effects parameters. The intervals are displayed as horizontal lines,
with 90% interval using a thicker line width and 95% interval a
thinner one. The posterior median is indicated with a dot.
caterplot_longRun( x, parm = NULL, main = "Caterpillar plot of long run effects", xlab = "Range of parameter samples", probs = c(0.025, 0.05, 0.5, 0.95, 0.975), labels = colnames(ranges) )
caterplot_longRun( x, parm = NULL, main = "Caterpillar plot of long run effects", xlab = "Range of parameter samples", probs = c(0.025, 0.05, 0.5, 0.95, 0.975), labels = colnames(ranges) )
x |
an instance of class |
parm |
a specification of which parameters are to be plotted, a vector of names are the only legal values. If missing, all parameters are considered. |
main , xlab
|
useful defaults for the plot title and X-axis label |
probs |
a vector specifying the quantiles, the defaults is 2.5%, 5%, 50%, 95%, and 97.5% quantiles |
labels |
labels for each parameter's interval: see |
A matrix of 2.5%, 5%, 50%, 95%, and 97.5% quantiles for each of the desired parameters, with model parameters arranged in columns.
## Not run: caterplot_longRun(o, main = NULL) ## End(Not run)
## Not run: caterplot_longRun(o, main = NULL) ## End(Not run)
Computes equal-tailed credible intervals for one or more parameters
in a fitted opm
model. The method used is the quantile
interval of the posterior sample.
## S3 method for class 'opm' confint(object, parm, level = 0.95, ...)
## S3 method for class 'opm' confint(object, parm, level = 0.95, ...)
object |
an instance of class |
parm |
a specification of which parameters are to be given
credible intervals, either a vector of names (" |
level |
the size of the interval (e.g., 0.95 for 95% C.I.) |
... |
additional argument(s) for methods |
A matrix with columns giving lower and upper limits of the credible interval for each parameter. These will be labeled as (1 - level/2) and 1 - (1 - level)/2 in % (by default, "2.5%" and "97.5%").
Computes the Deviance Information Criterion (DIC), which is a generalization of the Akaike Information Criterion. Models with smaller DIC are considered to fit better than models with larger DIC.
DIC(object, ...)
DIC(object, ...)
object |
an instance of class |
... |
further arguments passed to other methods. |
DIC is defined as
where:
DIC is calculated as: 2 * (-2 * mean(log-likelihood at each element of parameter samples)) - (-2 * log(likelihood at mean parameter sample value))
a numeric value with the corresponding DIC
Note the speed of computation of the DIC in proportional to the number of sampled values of the parameters in the opm object.
opm
ObjectMethod for hist
applied to opm
objects.
Each parameter will be plotted in a separate figure.
## S3 method for class 'opm' hist( x, parm, ask = dev.interactive(), plot = TRUE, main = NULL, xlab = NULL, ... )
## S3 method for class 'opm' hist( x, parm, ask = dev.interactive(), plot = TRUE, main = NULL, xlab = NULL, ... )
x |
an instance of class |
parm |
a specification of which parameters are to be plotted,
either a vector of names (" |
ask |
if " |
plot |
if " |
main , xlab
|
(optional) vector of titles and X-axis labels for each figure. |
... |
further arguments passed to the |
A list of objects of class "histogram
", one for each
requested model parameter. The elements are named after the
parameter.
opm
Model ParametersComputes long run effects and confidence intervals of opm
Model Parameters
longRunEffects(opm_obj, parm = NULL, probs = c(0.025, 0.5, 0.975))
longRunEffects(opm_obj, parm = NULL, probs = c(0.025, 0.5, 0.975))
opm_obj |
an instance of class |
parm |
a specification of which parameters are to be plotted, a vector of names are the only legal values. If missing, all parameters are considered. |
probs |
a vector of specified quantiles, by default, the c(0.025,0.5,0.975) are (" |
A matrix with quantiles on the rows, with number of rows specified as length of the probs
vector for the specified quantiles, with covariates on the columns
## Not run: longRunEffects(opm_obj) longRunEffects(opm_obj,probs=c(0.975, 0.16, 0.5, 0.84, 0.025)) ## End(Not run)
## Not run: longRunEffects(opm_obj) longRunEffects(opm_obj,probs=c(0.975, 0.16, 0.5, 0.84, 0.025)) ## End(Not run)
opm
is used to fit orthogonal panel models.
opm(x, ...) ## Default S3 method: opm(x, y, n.samp, add.time.indicators = FALSE, ...) ## S3 method for class 'formula' opm(x, data = environment(x), subset = NULL, index = 1:2, n.samp, ...)
opm(x, ...) ## Default S3 method: opm(x, y, n.samp, add.time.indicators = FALSE, ...) ## S3 method for class 'formula' opm(x, data = environment(x), subset = NULL, index = 1:2, n.samp, ...)
x |
a formula (see description of parameter |
... |
further arguments passed to other methods. |
y |
a matrix of dimensions |
n.samp |
number of samples to use to estimate the parameters. |
add.time.indicators |
(logical) if |
data |
an optional data frame, list, or environment containing
the variables in the model. If not found in |
subset |
an optional vector specifying a subset of observations to be used in the fitting process. |
index |
a two-element vector containing the index of the case and time variables, respectively. Variable indices can be specifed by name or position. This argument is ignored if the model is not specified by the formula, because the index is implicit in the organization of the terms and response arrays. |
The model can be either specified symbolically with the formula
response ~ term1 + term2 ...
or with the terms and response
given as a pair of 3- and 2-dimensional arrays, x
and
y
respectively. The arrays have to be in the format
time x variable x case
for terms and time x case
for
the response.
The lagged dependent variable does not need to be included in the formula or data, as it is included automatically.
An object of class opm
with the following elements:
samples
parameter samples used to estimate the model, as a list with following elements:
rho
a vector of n.samp
samples of .
v
a vector of n.samp
samples of .
beta
an n.samp x variable
matrix of samples of .
call
the matched call
index
the index variables, when using the formula interface
time.indicators
TRUE
if dummy time variables are used (see Notes), FALSE
otherwise
terms
the terms
object used
The function summary
(i.e., summary.opm
) can be used
to obtain or print a summary of the results. The generic accessor
functions coefficients
, fitted.values
,
residuals
, logLik
, and df.residual
can be used
to extract various useful features of the value returned by opm
.
Dummy time variables exist as an additional column for each
wave of data, excluding the first and second wave (i.e., at
and
using the terminology from Lancaster
(2000)). The new variables are named
tind.
, where
, and appear as such as elements of the estimated
beta
coefficient.
set.seed(123) N <- 5 T <- 2 beta <- .5 rho <- .5 v <- 1 f <- runif(N, -2, 2) K <- length(beta) beta <- matrix(beta, K, 1) ## $x_i = 0.75 f + N(0, 1)$: x <- array(.75*f, dim=c(N, K, (T+1))) + rnorm(N*K*(T+1)) ## $y_{i,t} = \rho y_{i,t-1} + \beta x_{i,t} + f_i + N(0,1)$: y <- matrix(0, N, T+1) for (t in seq_len(T+1)) { yy <- if (t>1) y[,t-1] else 0 y[,t] <- rho * yy + f + x[,,t] %*% beta + rnorm(N, sd = sqrt(1/v)) } d <- data.frame(i = rep(seq(N), T+1), t = rep(seq(T+1), each = N), as.data.frame(matrix(aperm(x, c(1, 3, 2)), N*(T+1), K, dimnames = list(NULL, paste0('x', seq(K))))), y = c(y)) opm(y~x1, d, n.samp = 10)
set.seed(123) N <- 5 T <- 2 beta <- .5 rho <- .5 v <- 1 f <- runif(N, -2, 2) K <- length(beta) beta <- matrix(beta, K, 1) ## $x_i = 0.75 f + N(0, 1)$: x <- array(.75*f, dim=c(N, K, (T+1))) + rnorm(N*K*(T+1)) ## $y_{i,t} = \rho y_{i,t-1} + \beta x_{i,t} + f_i + N(0,1)$: y <- matrix(0, N, T+1) for (t in seq_len(T+1)) { yy <- if (t>1) y[,t-1] else 0 y[,t] <- rho * yy + f + x[,,t] %*% beta + rnorm(N, sd = sqrt(1/v)) } d <- data.frame(i = rep(seq(N), T+1), t = rep(seq(T+1), each = N), as.data.frame(matrix(aperm(x, c(1, 3, 2)), N*(T+1), K, dimnames = list(NULL, paste0('x', seq(K))))), y = c(y)) opm(y~x1, d, n.samp = 10)
Returns the posterior density
p_rho(x, y, rho, log.p = FALSE)
p_rho(x, y, rho, log.p = FALSE)
x |
an array of dimension |
y |
a matrix of dimension |
rho |
vector of quantiles. |
log.p |
if |
opm
ObjectMethod for plot
applied to opm
objects.
Each parameter will be plotted as a density plot in a separate
figure.
## S3 method for class 'opm' plot(x, parm, ask = dev.interactive(), main = NULL, xlab = NULL, ...)
## S3 method for class 'opm' plot(x, parm, ask = dev.interactive(), main = NULL, xlab = NULL, ...)
x |
an instance of class |
parm |
a specification of which parameters are to be plotted,
either a vector of names (" |
ask |
if " |
main , xlab
|
(optional) vector of titles and X-axis labels for each figure. |
... |
further arguments passed to the |
A list of objects of class "density
", one for each
requested model parameter. The elements are named after the
parameter.
Produces quantiles of the posterior samples corresponding to the
given probabilities. In other words, it is equivalent to computing
"quantile(x, ...)
", where "x
" is the original Monte
Carlo sample of the parameter "parm
", as produced by
opm
.
## S3 method for class 'opm' quantile(x, parm, ...)
## S3 method for class 'opm' quantile(x, parm, ...)
x |
an instance of class |
parm |
a specification of which parameters are to be given
quantiles, either a vector of names (" |
... |
further arguments passed to the |
A matrix of quantiles for each of the desired parameters,
with parameters arranged in columns. If arguments include
"names = FALSE
", the quantile labels won't be included
(i.e., the rownames of the matrix will be NULL
).