panelAR(formula, data, panelVar, timeVar, autoCorr = c("ar1", "none", "psar1"), panelCorrMethod = c("none","phet","pcse","pwls", "parks"), rhotype ="breg", bound.rho = FALSE, rho.na.rm = FALSE, panel.weight = c("t-1", "t"), dof.correction = FALSE, complete.case = FALSE, seq.times = FALSE, singular.ok=TRUE)
formula
" (or one that can be coerced to that class): a symbolic description of the model to be fitted.
data
that contains the panel ID. It cannot contain any NA
s. May be set to NULL
, in which case all observations are assumed to belong to the same unit.
data
that contains the time ID. It must be a vector of integers and cannot contain any NA
s. Duplicate time observations per panel are not allowed. At least two time periods are required.
ar1
denotes AR(1)-type autocorrelation with a common correlation coefficient across all panels, psar1
denotes AR(1)-type autocorrelation with a unique correlation coefficient for each panel, and none
denotes no autocorrelation. Default: ar1
.
none
denotes homoskedasticity and no correlation across panels, phet
denotes a Huber-White style sandwich estimator for panel heteroskedasticity, pcse
denotes panel-corrected standard errors that are robust to both heteroskedasticity and contemporaneous correlation across panels, pwls
denotes that a panel weighted least squares procedure is to deal with panel heteroskedasticity, and parks
means that Parks-Kmenta FGLS is used to estimate both panel heteroskedasticity and correlation. Default: none
.
breg
, scorr
, freg
, theil
, dw
, and theil-nagar
. See Details. Default: breg
.
TRUE
, the panel-specific autocorrelation coefficient $\rho_i$ is bounded to $[-1,1]$ in the calculation of $\rho$; used only for autoCorr="ar1"
. Default: TRUE
.
FALSE
and $\rho_i$ cannot be calculated for a panel, function returns error. If TRUE
, $\rho_i$s that are NA
are ignored if calculating a common AR(1) coefficient or set to 0 if calculating panel-specific AR(1) coefficients. Default: FALSE
.
t
) or the number of time periods minus 1 (t-1
). Default: t
.
TRUE
, standard errors are adjusted by a factor of $N/(N-k)$, where $N$ is total number of observations and k
is the rank of the linear model. Default: FALSE
.
TRUE
, use only the time periods where every panel has a valid observation in the estimation of PCSEs or the Parks-Kmenta estimator. Otherwise, use pairwise procedure. Default: FALSE
.
TRUE
, observations are temporally ordered by panel and assigned a sequential time variable that ignores any gaps in the runs. Default: FALSE
.
FALSE
, a singular failure results in an error. Default: TRUE
.
panelAR
returns an object of class "panelAR"
.The function summary
can be used to obtain and print a summary of the results. Note that default methods coefficients
, fitted.values
, and residuals
returns vectors of regression coefficients, fitted values, and residuals, respectively. vcov
returns the estimated variance-covariance matrix of the coefficients.An object of class "panelAR"
contains the following components, very similar to the outputs of the standard lm
function:
NA
s.NULL
if PWLS or Parks-Kmenta procedures are used.panelStructure
:
TRUE
, panel $i$ at time $t$ has a valid observation. Panel structure is balanced if entire matrix is TRUE
."ar1"
option was used, vector of length $N_p$ (number of panels) if "psar1"
option was used, and NULL
if "none"
option was used.While generally designed to estimate Prais-Winsten models on panel data, setting panelVar
to NULL
will estimate an AR(1) time-series model treating the entire dataset as one unit. In this case, the panelCorrMethod
is ignored since equal variances are assumed across all observations.
A number of common estimators for the autocorrelation coefficient are supported. Specifically:
breg
scorr
freg
theil
dw
theil-nagar
In the expressions above, $\hat{\epsilon}$ denotes observed residuals from the first stage OLS regression, $T_i$ is the number of observations in panel $i$, and $k$ is the rank of the model matrix. Some of these estimators cannot be calculated for panels with one observation or multiple runs of one observation. In these cases, rho.na.rm
controls the treatment of these autocorrelation coefficients. If TRUE
, ignore panel-specific autocorrelation coefficients for panels where $\rho_i$ returns NA
if calculating a common AR(1) coefficient, and set them to 0 if calculating panel-specific AR(1) coefficients.
If PCSEs or the Parks-Kmenta estimator are selected, the default is to use all pairwise observations to estimate the time-constant covariances across units. In the case of no overlapping observations between panels, the panel covariance is assumed to be 0. If complete.case
is set to TRUE
, then only the time periods where every panel has a valid observation are used for the calculation of the contemporaneous correlation matrix.
Greene, William H. 2012. Econometric Analysis. 7ed. Prentice Hall.
Judge, George G., William E. Griffiths, R. Carter Hill, Helmut Lütkepohl, and Tsoung-Chao Lee. 1985. The Theory and Practice of Econometrics. 2ed. John Wiley & Sons.
Prais, S., and C. Winsten. 1954. Trend Estimation and Serial Correlation. Cowles Commission Discussion Paper No. 383, Chicago.
summary.panelAR
for summary.predict.panelAR
for prediction.
plot.panelAR
to plot image of panel structure.
run.analysis
for analysis of runs.
# Common AR(1) with PCSE
data(Rehm)
out <- panelAR(NURR ~ gini + mean_ur + selfemp + cum_right + tradeunion + deficit +
tradeopen + gdp_growth, data=Rehm, panelVar='ccode', timeVar='year', autoCorr='ar1',
panelCorrMethod='pcse', rho.na.rm=TRUE, panel.weight='t-1', bound.rho=TRUE)
summary(out)
# Panel-specific AR(1) with PCSE
data(WhittenWilliams)
# expect warning urging to use 'complete.case=FALSE'
out2 <- panelAR(milex_gdp~lag_milex_gdp+GOV_rl+gthreat+GOV_min+GOV_npty+election_yr+
lag_real_GDP_gr+cinclag+lag_alliance+lag_cinc_ratio+lag_us_change_milex_gdp,
data=WhittenWilliams, panelVar="ccode", timeVar="year", autoCorr="psar1",
panelCorrMethod="pcse", complete.case=TRUE)
summary(out2)
summary(out2)$rho
# Panel-specific AR(1) correlation with PWLS
data(BrooksKurtz)
out3 <- panelAR(kaopen ~ ldiffpeer + ldiffisi + ldiffgrowth + ldiffinflation +
ldiffneg + ldiffembi + limf + isi_objective + partisan + checks + lusffr +
linflation + lbankra + lcab + lgrowth + ltradebalance + lngdpcap + lngdp +
brk + timetrend + y1995, data=BrooksKurtz, panelVar='country', timeVar='year',
autoCorr='psar1', panelCorrMethod='pwls',rho.na.rm=TRUE, panel.weight='t',
seq.times=TRUE)
summary(out3)
Run the code above in your browser using DataLab