arfimaMLM: Arfima-MLM for repeated cross-sectional data and pooled...

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/arfimaMLM.R

Description

Estimates Arfima-MLM 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.

Usage

1
2
3
4
arfimaMLM(formula, data, timevar
          , d = "Hurst", arma = NULL
          , ecmformula = NULL, decm = "Hurst"
          , drop = 5, report.data = TRUE, ...)

Arguments

formula

An object of the class “formula” that specifies the multilevel model to be estimated (see lmer for details): a two-sided linear formula object describing both the fixed-effects and fixed-effects part of the model, with the response on the left of a ~ operator and the terms, separated by + operators, on the right. Random-effects terms are distinguished by vertical bars (“|”) separating expressions for design matrices from grouping factors (i.e. the variable indicating the timepoints of the repeated cross-sectional design as well as potentially further clustering variables). See details below for further information about selecting variables for automatic aggregation, fractional differencing, and the removal of deterministic components.

data

Data frame containing the original variables named in formula.

timevar

Name of the variable indicating different timepoints in data.

d

Call for a specific estimation method for the fractional differencing parameter in the fractal-package (``Hurst'') or in the fracdiff-package (``ML'', ``GPH'', or ``Sperio''). Default estimation procedure is by estimating the Hurst exponent. If the user wants to specify the methods for each variable individually, d can be a list containing a call for every individual variable. Furthermore, the list can contain numeric values for differencing parameters which were estimated externally (e.g. 1 for simple differencing, also see example for further details). A variable will not be differenced if d is specified as 0.

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. order[1] corresponds to the AR part and order[2] to the MA part, similar to the model specification in arima (just excluding the d parameter here). For variables specified in arma, the function will use the residuals of the ARMA model for the subsequent model estimation in order to remove their deterministic components. All variables included in the arma list have to included in either varlist.fd, varlist.ydif, or varlist.xdif. It is also possible to keep some of the AR/MA parameters fixed at zero (e.g. if the model is only supposed to estimate AR[1] and AR[3] parameters, but not AR[2]). In order to specify such a model, replace the vector containing the orders of the model with a list containing two vectors indicating each individual AR or MA parameter to be estimated. Please see the examples for clarification.

ecmformula

Specification of the cointegration regression to receive the residuals for the error correction mechanism (ecm) included in formula: linear formula object with the response on the left of a ~ operator and the independent variables, separated by + operators, on the right. Note that the variable names included here cannot be the original variable names included in data, but rather has to be extended by adding “.mean” to the original names, since the ecm is always based on the level/time aggreegates (see example).

decm

Call for estimation method for the fractional differencing parameter (see d for details). Can be either “Hurst”, “ML”, “GPH”, or “Sperio”. Default is “Hurst”.

drop

Number of time points from the beginning of the series dropped from analysis. Default is 5.

report.data

Logical. arfimaMLM returns the transformed dataset used to estimate the final model as part of the results. Default is TRUE.

...

Further arguments passed to the estimation procedures used within the function (e.g. for lmer).

Details

Value

The function returns a list of the class 'arfimaMLM' with the following items:

result

Output of the multilevel model as specified in formula.

d

Matrix of fractional differencing parameters estimated for the level variables (.fd and .ydif) as well as the estimation method for each variable. Returns the specified value for d if it was specified in the initial call of the function.

arma

List of arima results for each variable specified in the model call. Contains AR/MA estimates as well as the model residuals.

ecm

Output of the cointegration regression (returned if ecmformula is specified). The lagged residuals of the cointegration regression are included in the multilevel model if ecm is included in formula.

data.mean

Data frame of variable means declared in formula as .fd, .xdif or .ydif (as well as .mean in ecmformula) for each time point specified by the level variable in timevar.

data.fd

Data frame of fractionally differenced level variables for each time point specified in timevar, which were declared as .fd or .ydif in formula. If arma was additionally specified for a variable, it contains the residuals of the ARMA model fitted after (fractionally) differencing.

data.merged

Merged data frame used to estimate the multilevel model consisting of the original data, data.mean, data.fd, as well as the variables specified as .xdif and .ydif in formula

Author(s)

Patrick Kraft

References

Lebo, M. and Weber, C. 2015. “An Effective Approach to the Repeated Cross Sectional Design.” American Journal of Political Science 59(1): 242-258.

See Also

lme4, fracdiff, hurstSpec, arfimaPrep, fd, and ArfimaMLM for a package overview.

Examples

 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
57
require(fractal)
require(fracdiff)
require(lme4)

### 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 <- arfimaMLM(y.ydif ~ x1.xdif + x2 + z1.fd + z2.fd + (1 | time)
                , data = data, timevar = "time")

# model including error correction mechanism
# change estimation method for differencing parameter for all variables
m2 <- arfimaMLM(y.ydif ~ x1.xdif + x2 + z1.fd + z2.fd + ecm + (1 | time)
                , 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 <- arfimaMLM(y.ydif ~ x1.xdif + x2 + z1.fd + z2.fd + (1+x1.xdif|time)
                , 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 <- arfimaMLM(y.ydif ~ x1.xdif + x2 + z1.fd + z2.fd + (1+x1.xdif|time)
                , data = data, timevar = "time"
                , arma=list(y=list(c(1,3),0),z2=c(0,1)))                 
                
m1
summary(m2)
summary(m3$result)
m4$arma

ArfimaMLM documentation built on May 2, 2019, 2:18 a.m.