Description Usage Arguments Details Value Author(s) References See Also Examples
Estimates Arfima-OLS model for repeated cross-sectional data or pooled cross-sectional time-series data. For the variables specified by the user, the function automatically implements the aggregation and fractional differencing of time/level variables as well as the necessary procedures to remove deterministic components from the dependent as well as the major independent variables.
1 2 3 4 |
formula |
An object of the class “ |
data |
Data frame containing the original variables named in |
timevar |
Name of the variable indicating different timepoints in |
d |
Call for a specific estimation method for the fractional differencing parameter in the |
arma |
List of variables for which AR and MA parameters are to be estimated (after fractional differencing) as well as a vector containing the respective orders of the model to fit. |
ecmformula |
Specification of the cointegration regression to receive the residuals for the error correction mechanism (ecm) included in |
decm |
Call for estimation method for the fractional differencing parameter (see |
drop |
Number of time points from the beginning of the series dropped from analysis. Default is 5. |
report.data |
Logical. |
... |
Further arguments passed to the estimation procedures used within the function (e.g. for |
The original variable names of data
used in formula
can be extended by adding three different suffixes: .fd
, .xdif
, and .ydif
. These suffixes select variables for transformations according to the Arfima-OLS framework before estimating the actual model.
The suffix .fd
allows the user to select variables which are supposed to be transformed to a fractionally differenced level-variable (by aggregating individuals over each time point prior to fractionally differencing the series), or variables which are already included as a level-variable in the original dataset and are just supposed to be fractionally differenced before the multilevel model is estimated.
If the suffix .xdif
is added to an independent variable, the variable is simply filtered through the timepoint averages:
x.star[it]=x[it]-X[t]
If the suffix .ydif
is added to the dependent variable (e.g. y[it]), the function will remove the temporal deterministic component from the individual level variable, such that it only consists of within-timepoint, as well as non-temporally autocorrelated between-timepoint variation:
y.star[it]=y[it]-(Y[t]-Δ[df]Y[t])
If formula
contains ecm
as one of the independent variables, and ecmformula
is correctly specified, the function will include the lag of the fractionally differenced residuals of the cointegration regression as an error correction mechanism in the multilevel model. The ECM does not have to be estimated prior to calling the function.
In order to prevent errors in the estimation procedure, none of the original variable names in data
should include “.ydif
”, “.xdif
” or “.fd
”.
The function returns a list of the class 'arfimaOLS' with the following items:
result |
Output of the linear model as specified in |
d |
Matrix of fractional differencing parameters estimated for the level variables ( |
arma |
List of |
ecm |
Output of the cointegration regression (returned if |
data.mean |
Data frame of variable means declared in |
data.fd |
Data frame of fractionally differenced level variables for each time point specified in |
data.merged |
Merged data frame used to estimate the OLS model consisting of the original data, |
Patrick Kraft
Lebo, M. and Weber, C. 2015. “An Effective Approach to the Repeated Cross Sectional Design.” American Journal of Political Science 59(1): 242-258.
lm
, fracdiff
, hurstSpec
, arfimaPrep
, fd
, and ArfimaMLM
for a package overview.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | require(fractal)
require(fracdiff)
### set basic parameters for simulation
t = 100 # number of time points
n = 500 # number of observations within time point
N = t*n # total number of observations
### generate fractional ARIMA Time Series for y_t, x1_t, z1_t, z2_t
set.seed(123)
y_t <- fracdiff.sim(t, d=0.4, mu=10)$series
x1_t <- fracdiff.sim(t, d=0.3, mu=5)$series
z1_t <- fracdiff.sim(t, d=0.1, mu=2)$series
z2_t <- fracdiff.sim(t, d=0.25, mu=3)$series
### simulate data
data <- NULL; data$time <- rep(seq(1:t),each=n)
data <- data.frame(data)
data$x1 <- rnorm(N,rep(x1_t,each=n),2)
data$x2 <- rnorm(N,0,40)
data$z1 <- rnorm(N,rep(z1_t,each=n),3)
data$z2 <- rep(z2_t,each=n)
b1 <- 0.2+rep(rnorm(t,0,0.1),each=n)
data$y <- (b1*data$x1-0.05*data$x2+0.3*rep(z1_t,each=n)
+0*data$z2+rnorm(N,rep(y_t,each=n),1))
### estimate models
# basic example
m1 <- arfimaOLS(y.ydif ~ x1.xdif + x2 + z1.fd + z2.fd
, data = data, timevar = "time")
# model including error correction mechanism
# change estimation method for differencing parameter for all variables
m2 <- arfimaOLS(y.ydif ~ x1.xdif + x2 + z1.fd + z2.fd + ecm
, data = data, timevar = "time", d="ML"
, ecmformula = y.mean ~ x1.mean
, decm="Sperio")
# vary estimation method for differencing parameter between variables
# specify AR/MA models
m3 <- arfimaOLS(y.ydif ~ x1.xdif + x2 + z1.fd + z2.fd
, data = data, timevar = "time"
, d=list(y="ML", z1="Sperio", z2=0.25)
, arma=list(y=c(1,0),z2=c(0,1)))
# specify AR/MA models while holding AR[2] fixed for y
m4 <- arfimaOLS(y.ydif ~ x1.xdif + x2 + z1.fd + z2.fd
, data = data, timevar = "time"
, arma=list(y=list(c(1,3),0),z2=c(0,1)))
m1
summary(m2)
summary(m3$result)
m4$arma
|
Loading required package: lme4
Loading required package: Matrix
Loading required package: fractal
Loading required package: splus2R
Loading required package: ifultools
Loading required package: fracdiff
###################################
Fractional Differencing Parameters:
Method Estimate
y Hurst 0.41713434
z1 Hurst 0.01679005
z2 Hurst 0.10887414
##################
Results OLS Model:
Call:
lm(formula = formula, data = new$data.merged)
Coefficients:
(Intercept) x1.xdif x2 z1.fd z2.fd
0.05505 0.20334 -0.04985 0.20352 -0.07058
###################################
Summary Error Correction Mechanism:
Call:
lm(formula = ecmformula, data = data.mean)
Residuals:
Min 1Q Median 3Q Max
-3.2427 -0.7130 0.0182 0.7618 2.6427
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 11.1164 0.5400 20.584 <2e-16 ***
x1.mean 0.1630 0.1194 1.364 0.176
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.13 on 98 degrees of freedom
Multiple R-squared: 0.01864, Adjusted R-squared: 0.008626
F-statistic: 1.861 on 1 and 98 DF, p-value: 0.1756
###################################
Fractional Differencing Parameters:
Method Estimate
y ML 0.27174837
z1 ML 0.09300433
z2 ML 0.12142851
ecm Sperio 0.36545132
##################
Summary OLS Model:
Call:
lm(formula = formula, data = new$data.merged)
Residuals:
Min 1Q Median 3Q Max
-5.8499 -0.9610 0.0289 0.9987 5.6594
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.0590680 0.0066877 8.832 <2e-16 ***
x1.xdif 0.2033355 0.0033374 60.926 <2e-16 ***
x2 -0.0498911 0.0001671 -298.572 <2e-16 ***
z1.fd 0.2226591 0.0071783 31.019 <2e-16 ***
z2.fd -0.1202803 0.0065465 -18.373 <2e-16 ***
ecm -0.0664588 0.0063169 -10.521 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.455 on 47494 degrees of freedom
Multiple R-squared: 0.6649, Adjusted R-squared: 0.6648
F-statistic: 1.885e+04 on 5 and 47494 DF, p-value: < 2.2e-16
Call:
lm(formula = formula, data = new$data.merged)
Residuals:
Min 1Q Median 3Q Max
-5.8569 -0.9601 0.0273 0.9961 5.6257
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.0585643 0.0066831 8.763 <2e-16 ***
x1.xdif 0.2033354 0.0033381 60.913 <2e-16 ***
x2 -0.0498788 0.0001671 -298.453 <2e-16 ***
z1.fd 0.2282936 0.0071695 31.842 <2e-16 ***
z2.fd -0.1073094 0.0064299 -16.689 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.455 on 47495 degrees of freedom
Multiple R-squared: 0.6647, Adjusted R-squared: 0.6647
F-statistic: 2.354e+04 on 4 and 47495 DF, p-value: < 2.2e-16
$y
Call:
arima(x = data.fd[, names(arma)[i]], order = c(max(arma[[i]][[1]]), 0, max(arma[[i]][[2]])),
include.mean = FALSE, transform.pars = FALSE, fixed = fixed)
Coefficients:
ar1 ar2 ar3
-0.1323 0 0.1575
s.e. 0.0978 0 0.0972
sigma^2 estimated as 1.057: log likelihood = -144.69, aic = 295.39
$z2
Call:
arima(x = data.fd[, names(arma)[i]], order = c(arma[[names(arma)[i]]][1], 0,
arma[[names(arma)[i]]][2]), include.mean = FALSE)
Coefficients:
ma1
0.0470
s.e. 0.0973
sigma^2 estimated as 1.048: log likelihood = -144.24, aic = 292.47
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.