Package 'LSEbootLS'

Title: Bootstrap Methods for Regression Models with Locally Stationary Errors
Description: Implements bootstrap methods for linear regression models with errors following a time-varying process, focusing on approximating the distribution of the least-squares estimator for regression models with locally stationary errors. It enables the construction of bootstrap and classical confidence intervals for regression coefficients, leveraging intensive simulation studies and real data analysis. The methodology is based on the approach described in Ferreira et al. (2020), allowing errors to be locally approximated by stationary processes.
Authors: Guillermo Ferreira [aut], Joel Muñoz [aut], Nicolas Loyola [aut, cre]
Maintainer: Nicolas Loyola <[email protected]>
License: GPL (>= 3)
Version: 0.1.0
Built: 2024-10-30 04:16:33 UTC
Source: https://github.com/nicolas-udec/lsebootls

Help Index


Calculate the bootstrap LSE for a long memory model

Description

Bootstrap procedure to approximate the sampling distribution of the LSE for time series linear regression with errors following a Locally Stationary process.

Usage

application(
  formula,
  data,
  start,
  d.order,
  s.order,
  N,
  S,
  B = 1,
  nr.cores = 1,
  seed = 123
)

Arguments

formula

(type: formula) an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted. The details of model specification are given under ‘Details’.

data

(type: data.frame) data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model.

start

(type: numeric) numeric vector, initial values for parameters to run the model.

d.order

(type: numeric) polynomial order, where d is the ARFIMA parameter.

s.order

(type: numeric) polynomial order noise scale factor.

N

(type: numeric) sample size of each block.

S

(type: numeric) shifting places from block to block. Observe that the number of blocks M is determined by the following formula M=TNS+1M = \left\lfloor \frac{T-N}{S} + 1 \right\rfloor, where .\left\lfloor . \right\rfloor takes a single numeric argument x and returns a numeric vector containing the integers formed by truncating the values in x toward 0.

B

(type: numeric) bootstrap replicates, 1 by default.

nr.cores

(type: numeric) number of CPU cores to be used for parallel processing. 1 by default.

seed

(type: numeric) random number generator seed to generate the bootstrap samples.

Details

This function estimates the parameters in the linear regression model for t=1,...,Tt = 1, ..., T,

Yt,T=Xt,Tβ+ϵt,T,Y_{t,T} = X_{t,T} \beta + \epsilon_{t,T},

where the error term ϵt,T\epsilon_{t,T} follows a Locally Stationary Autoregressive Fractionally Integrated Moving Average (LS-ARFIMA) structure, given by:

ϵt,T=(1B)d(u)σ(u)ηt,\epsilon_{t,T} =(1 - B)^{-d(u)} \sigma(u)\eta_t,

where u=t/T ∈ [0,1], d(u)d(u) represents the long-memory parameter, σ(u)\sigma(u) is the noise scale factor, and {ηt}\{\eta_t\} is a white noise sequence with zero mean and unit variance.

Particularly, we model d(u)d(u) and σ(u)\sigma(u) as polynomials of order d.orderd.order and s.orders.order respectively.

d(u)=i=0d.orderδiui,d(u) = \sum_{i=0}^{d.order} \delta_i u^i,

σ(u)=j=0s.orderαjuj,\sigma(u) = \sum_{j=0}^{s.order} \alpha_j u^j,

For more details, see references.

Value

A list with the following elements:

  • coeff: A tibble of estimated model coefficients, including intercepts, regression coefficients (β\beta), and coefficients of the δ\delta and α\alpha polynomials. Contains columns for coefficient name, estimate, t-value and p-value.

  • estimation: A matrix of bootstrap replicates for regression coefficients (β\beta).

  • delta: A matrix of bootstrap replicates for the δ\delta polynomial coefficients.

  • alpha: A matrix of bootstrap replicates for the α\alpha polynomial coefficients.

References

Ferreira G., Mateu J., Vilar J.A., Muñoz J. (2020). Bootstrapping regression models with locally stationary disturbances. TEST, 30, 341-363.

Examples

n    <- length(USinf)
shift<-201
u1<-c((1:shift)/shift,rep(0, n-shift))
u2<-c(rep(0, shift),(1:(n-shift))/(n-shift))
u<-(1:n)/n
switch <- c(rep(1,shift), rep(0, n-shift))
x1<-switch*u
x2<-(1-switch)*u

test <- data.frame(USinf, x1=x1, x2=x2)

application(formula=USinf~x1+x2,data=test,N=150,S=50,B=10,
start = c(0.16,2.0,-7,8,-3,0.25,-0.25,0.01),
d.order=4,s.order=2,nr.cores=1)

Calculate the coverage of several long-memory models

Description

Generates coverage metrics for a parameter of interest using a specified long-memory model.

Usage

Coveragelongmemory(
  n,
  R,
  N,
  S,
  mu = 0,
  dist,
  method,
  B = NULL,
  nr.cores = 1,
  seed = 123,
  alpha,
  beta,
  start,
  sign = 0.05
)

Arguments

n

(type: numeric) size of the simulated series.

R

(type: numeric) number of realizations of the Monte Carlo experiments.

N

(type: numeric) sample size of each block.

S

(type: numeric) shifting places from block to block. Observe that the number of blocks M is determined by the following formula M=TNS+1M=\left\lfloor \frac{T-N}{S} + 1 \right\rfloor, where .\left\lfloor . \right\rfloor takes a single numeric argument x and returns a numeric vector containing the integers formed by truncating the values in x toward 0.

mu

(type: numeric) trend coefficient of the regression model.

dist

(type: character) white noise distribution for calculating coverage, it includes the "normal", "exponential" and "uniform" univariate distributions.

method

(type: character) methods are asymptotic ("asym"), bootstrap percentile ("boot") and bootstrap-t ("boott").

B

(type: numeric) the number of bootstrap replicates, NULL indicates the asymptotic method.

nr.cores

(type: numeric) number of CPU cores to be used for parallel processing. 1 by default.

seed

(type: numeric) random number generator seed to generate the bootstrap samples.

alpha

(type: numeric) numeric vector with values to simulate the time varying autoregressive parameters of model LSAR(1), ϕ(u)\phi(u).

beta

(type: numeric) numeric vector with values to simulate the time varying scale factor parameters of model LSAR(1), σ(u)\sigma(u).

start

(type: numeric) numeric vector, initial values for parameters to run the model.

sign

nominal significance level

Details

This function estimates the parameters in the linear regression model for t=1,...,Tt = 1, ..., T,

Yt,T=Xt,Tβ+ϵt,T,Y_{t,T} = X_{t,T} \beta + \epsilon_{t,T},

where a locally stationary fractional noise process (LSFN) is described by the equation:

ϵt,T=j=0ψj(u)ηtj\epsilon_{t,T} = \sum_{j=0}^\infty \psi_j(u) \eta_{t-j}

for u=t/T in [0,1], where ψj(u)=Γ[j+d(u)]Γ[j+1]Γ[d(u)]\psi_j(u) = \frac{\Gamma[j + d(u)]}{\Gamma[j+1] \Gamma[d(u)]} and d(u)d(u) is the smoothly varying long-memory coefficient. This model is referred to as locally stationary fractional noise (LSFN).

In this particular case, d(u)d(u) is modeled as a linear polynomial, and σ(u)\sigma(u) as a quadratic polynomial.

Resampling methods evaluated:

  • asym: Asymptotic method that uses the asymptotic variance of the estimator, based on the Central Limit Theorem, to construct confidence intervals under the assumption of normality in large samples.

  • boot: Standard bootstrap that generates replicas of the estimator β^\hat{\beta} by resampling the adjusted residuals ϵ^t\hat{\epsilon}_t. It approximates the distribution of the estimator by the variability observed in the bootstrap replicas of β^\hat{\beta}.

  • boott: Adjusted bootstrap that scales the bootstrap replicas of the estimator β^\hat{\beta} by its standard error, aiming to refine the precision of the confidence interval and adjust for the variability in the parameter estimation.

For more details, see references.

Value

A data frame containing the following columns:

  • n: Size of each simulated series.

  • method: Statistical method used for simulation.

  • coverage: Proportion of true parameter values within the intervals.

  • avg_width: Average width of the intervals.

  • sd_width: Standard deviation of the interval widths.

References

Ferreira G., Mateu J., Vilar J.A., Muñoz J. (2020). Bootstrapping regression models with locally stationary disturbances. TEST, 30, 341-363.

Examples

Coveragelongmemory(n=500,R=100,N=60,S=40,mu=0.5,dist="normal",method="asym",
beta=c(0.1,-2),alpha=c(0.15,0.25, 0.1),start = c(0.1,-2,0.15,0.2, 0.1))

Calculate the coverage for several short-memory models

Description

Generates coverage metrics for a parameter of interest using a specified short-memory model.

Usage

Coverageshortmemory(
  n,
  R,
  N,
  S,
  mu,
  dist,
  method,
  alpha,
  beta,
  start,
  Subdivisions = 100,
  m = 500,
  NN = 100,
  B,
  case,
  sign = 0.05
)

Arguments

n

(type: numeric) size of the simulated series.

R

(type: numeric) number of realizations of the Monte Carlo experiments.

N

(type: numeric) sample size of each block.

S

(type: numeric) shifting places from block to block. Observe that the number of blocks M is determined by the following formula M=TNS+1M = \left\lfloor \frac{T-N}{S} + 1 \right\rfloor, where .\left\lfloor . \right\rfloor takes a single numeric argument x and returns a numeric vector containing the integers formed by truncating the values in x toward 0.

mu

(type: numeric) trend coefficient of the regression model.

dist

(type: character) white noise distribution for calculating coverage, it includes the "normal", "exponential" and "uniform" univariate distributions.

method

(type: character) methods are asymptotic ("asym"), bootstrap percentile ("boot"), bootstrap-t ("boott") and bootstrap-SP ("bootSP").

alpha

(type: numeric) numeric vector with values to simulate the time varying autoregressive parameters of model LSAR(1), ϕ(u)\phi(u).

beta

(type: numeric) numeric vector with values to simulate the time varying scale factor parameters of model LSAR(1), σ(u)\sigma(u).

start

(type: numeric) numeric vector, initial values for parameters to run the model.

Subdivisions

(type: numeric) the number of subintervals produced in the subdivision (integration) process; only required in the asymptotic method.

m

(type: numeric) parameter that allows to remove the first m observations when simulating the LSAR process.

NN

(type: numeric) parameter that allows to remove the first NN observations of noise from the LSAR model.

B

(type: numeric) the number of bootstrap replicates, NULL indicates the asymptotic method.

case

(type: character) nonlinear ("no-linear") and linear cases ("linear").

sign

nominal significance level

Details

This function estimates the parameters in the linear regression model for t=1,...,Tt = 1, ..., T,

Yt,T=Xt,Tβ+ϵt,T,Y_{t,T} = X_{t,T} \beta + \epsilon_{t,T},

where a locally stationary autoregressive process of order one (LSAR(1)) is described by the equation:

ϵt,T=ϕ(u)ϵt1,T+σ(u)ηt\epsilon_{t,T} = \phi(u) \epsilon_{t-1,T} + \sigma(u) \eta_t

where u=t/T in [0,1], with ϕ(u)\phi(u) is the autoregressive coefficient which is modeled as a linear polynomial, σ(u)\sigma(u) is modeled as a quadratic polynomial, and ηt\eta_t is a white noise sequence with zero mean and unit variance. This setup is referred to as a locally stationary autoregressive model (LSAR(1)).

Resampling methods evaluated:

  • asym: Asymptotic method that uses the asymptotic variance of the estimator, based on the Central Limit Theorem, to construct confidence intervals under the assumption of normality in large samples.

  • boot: Standard bootstrap that generates replicas of the estimator β^\hat{\beta} by resampling the adjusted residuals ϵ^t\hat{\epsilon}_t. It approximates the distribution of the estimator by the variability observed in the bootstrap replicas of β^\hat{\beta}.

  • boott: Adjusted bootstrap that scales the bootstrap replicas of the estimator β^\hat{\beta} by its standard error, aiming to refine the precision of the confidence interval and adjust for the variability in the parameter estimation.

  • bootSP: Symmetrized Percentile-t method, a variation of the boot-t that symmetrizes the bootstrap distribution around zero to handle skewed distributions or outliers more effectively. This method enhances the accuracy of confidence intervals by adjusting for asymmetries in the bootstrap replicas.

For more details, see references.

Value

A data frame containing the following columns:

  • n: Size of each simulated series.

  • method: Statistical method used for simulation.

  • coverage: Proportion of true parameter values within the intervals.

  • avg_width: Average width of the intervals.

  • sd_width: Standard deviation of the interval widths.

References

Ferreira G., Mateu J., Vilar J.A., Muñoz J. (2020). Bootstrapping regression models with locally stationary disturbances. TEST, 30, 341-363.

Examples

Coverageshortmemory(n=100,R=100,N=60,S=40,mu=0.5,dist="normal",method="asym",alpha=c(0.25,0.2),
beta=c(1,1,-0.5),start=c(0.15,0.15,1,1,-0.5),case="no-linear")

US Monthly Inflation Data

Description

Monthly inflation rates for the United States. The data covers the period from January 1965 to December 2011, totaling 564 observations.

Usage

USinf

Format

A time series object with 564 elements

Monthly inflation rate, expressed as a percentage.

Source

International Financial Statistics (IFS)