Package 'PanelTM'

Title: Two- And Three-Way Dynamic Panel Threshold Regression Model for Change Point Detection
Description: Estimation of two- and three-way dynamic panel threshold regression models (Di Lascio and Perazzini (2024) <https://repec.unibz.it/bemps104.pdf>; Di Lascio and Perazzini (2022, ISBN:978-88-9193-231-0); Seo and Shin (2016) <doi:10.1016/j.jeconom.2016.03.005>) through the generalized method of moments based on the first difference transformation and the use of instrumental variables. The models can be used to find a change point detection in the time series. In addition, random number generation is also implemented.
Authors: Selene Perazzini [aut], F. Marta L. Di Lascio [aut, cre]
Maintainer: F. Marta L. Di Lascio <[email protected]>
License: GPL (>= 2)
Version: 1.0
Built: 2024-10-31 21:26:04 UTC
Source: CRAN

Help Index


Biompedance measurements on bananas.

Description

Bioimpedance measurements and weight of a production batch of 50 bananas observed for 11 days. Bioimpedance has been measured at 3 different electrical frequencies of a portable electrical impedance spectroscopy device, called Fruit Meter. The experiment has been conducted by the Sensing Technologies Laboratory https://sensingtechnologies.groups.unibz.it/ of the Faculty of Engineering (ex Fac. Science and Technology) at the Free University of Bozen-Bolzano (Unibz, Italy) in the context of an interdisciplinary research project with the Faculty of Economics and Management (Unibz, Italy).

Format

A matrix containing three-way observations.

References

Ibba, P., Falco, A., Abera, B., Cantarella, G., Petti, L., and Lugli, P. (2019). Bio-impedance and circuit parameters: An analysis for tracking fruit ripening. Postharvest Biology and Technology, 159. DOI: 10.1016/j.postharvbio.2019.110978.

Ibba P., et al. (2021). Design and Validation of a Portable AD5933-Based Impedance Analyzer for Smart Agriculture, in IEEE Access, 9, pp. 63656-63675. DOI: 10.1109/ACCESS.2021.3074269.

Ibba, P. (2021). Fruit quality evaluation using electrical impedance spectroscopy. PhD thesis, 196, Supervisor: Lugli P., Free University of Bozen-Bolzano.


Computation of the regime switch time in a (two-way or three-way) panel threshold regression model.

Description

A measure for computing the time at which a regime changes, i.e. the change point.

Usage

cpoint(data., nameI=NA, nameT=NA, nameJ=NA, nameY=NA, thresholds)

Arguments

data.

A (two-way or three-way) panel dataset. It can be either a N×TN\times T matrix of the dependent variable(s) where the row represents the statistical unit (ii) and the column the time (tt) or a data.frame containing columns nameI, nameT, nameJ, and nameY, which should all be specified.

nameI

If data. is a data.frame, the name of the (numerical) variable that identifies the statistical units. Otherwise, it is NULL.

nameT

If data. is a data.frame, the name of the (numerical) time variable. Otherwise, it is NULL.

nameJ

If data. is a data.frame, the name of the (numerical/categorical) variable that indicates the third dimension. Otherwise, it is NULL.

nameY

If data. is a data.frame, the name of the (numerical) dependent variable. Otherwise, it is NULL.

thresholds

The vector of estimated threshold value(s). If data. is a matrix, the object should contain one value γ\gamma. If data. is a data.frame, the vector should contain one threshold value per each value of j, i.e. γj\gamma_j.

Details

cpoint computes the change point on the dependent variable (YY) for each statistical unit i given the time series of YY and the estimated threshold value γij\gamma_{ij}. If the observed value YY is greater (lower) than the estimated threshold parameter, t=4t=4 belongs to the upper (lower) regime, and the change point is identified as the time tt after which the longest sequence of days in the lower (upper) regime is observed.

Value

An object of S4 class "cpoint", which is a matrix reporting the change point per each statistical unit ii and each jj.

Note

The change point is detected in t>4t>4 since the criterion has been inspired by the (two-way or three-way) dynamic panel threshold regression model that requires at least 6 times of observation: four lags of the dependent and independent variables are used as instruments and two more are necessary to identify the regime switch (i.e., one per regime).

Author(s)

Francesca Marta Lilja Di Lascio <[email protected]>

Selene Perazzini <[email protected]>

References

Di Lascio, F.M.L. and Perazzini, S. (202x) A three-way dynamic panel threshold regression model for change point detection in bioimpedance data. WP BEMPS <https://repec.unibz.it/bemps104.pdf>.

Di Lascio, F.M.L. and Perazzini, S. (2022) Change point detection in fruit bioimpedance using a three-way panel model. Book of short papers - SIS2022, p.1184-1189, Eds. A. Balzanella, M. Bini, C. Cavicchia, R. Verde. Pearson. ISBN: 978-88-9193-231-0.

See Also

See also banana, ptm2, and ptm3.

Examples

# Import data
data(banana)

## Example 1: Application to a three-way panel data

# Select data for all the three levels of the third way 
bioimp.df2 <- banana

# Estimation: three-way ptm on bioimpedance data with the lagged 
# dependent variable as transition variable
estimates2 <- ptm3(data.=bioimp.df2, nameI="i", nameT="t",  
                   nameJ="j", nameY="bioimpedance", nameTV=NULL, 
                   nameXexo="weight", nameIV=NULL, trimrate=0.4, 
                   ngrid=100, h0=1.5, Iweight=FALSE, 
                   test.lin=FALSE)

# Change point computation using a data frame (unique input choice)
CP3 <- cpoint(data.=bioimp.df2, nameI="i", nameT="t", nameJ="j", 
              nameY="bioimpedance", 
              thresholds=estimates2@"threshold"[,2])

## NOT RUN           
### Example 2: Application to a two-way panel data
#
## Select data for a specific level of the third way 
#bioimp.df <- banana[which(banana$j==1),]
#
## Prepare input matrix for ptm2
#bioimp.m <-  matrix(bioimp.df$bioimpedance, 
#                    ncol=length(unique(bioimp.df$t)), byrow=TRUE)
#
## Estimation: two-way ptm on bioimpedance data with the lagged 
## dependent variable as transition variable
#estimates <- ptm2(Y=bioimp.m, TV=NULL, Xendo=NULL, Xexo=NULL,  
#                  IV=NULL, trimrate=0.4, ngrid=100, h0=1.5, 
#                  Iweight=FALSE, test.lin=FALSE)
#
## Change point computation using a data frame as input
#CP1 <- cpoint(data.=bioimp.df, nameI="i", nameT="t", nameJ="j", 
#              nameY="bioimpedance", 
#              thresholds=estimates@"threshold"[[1]])
#    
## Change point computation using a data matrix as input
#CP2 <- cpoint(data.=bioimp.m, nameI=NA, nameT=NA, nameJ=NA, 
#              nameY=NA, thresholds=estimates@"threshold"[[1]])
##

Class "cpoint"

Description

A class for cpoint and its extensions

Objects from the Class

Objects can be created by calls of the form new("cpoint", ...).

Slots

CP:

Object of class matrix. A matrix reporting the computed change point per each statistical unit and each level/category/value of the third way.

Methods

No methods defined with class "cpoint" in the signature.

Author(s)

Selene Perazzini <[email protected]>

Francesca Marta Lilja Di Lascio <[email protected]>

References

Di Lascio, F.M.L. and Perazzini, S. (202x) A three-way dynamic panel threshold regression model for change point detection in bioimpedance data. WP BEMPS <https://repec.unibz.it/bemps104.pdf>.

Di Lascio, F.M.L. and Perazzini, S. (2022) Change point detection in fruit bioimpedance using a three-way panel model. Book of short papers - SIS2022, p.1184-1189, Eds. A. Balzanella, M. Bini, C. Cavicchia, R. Verde. Pearson. ISBN: 978-88-9193-231-0.

See Also

See also ptm2 and ptm3.

Examples

showClass("cpoint")

Performance measures of the (two-way or three-way) panel threshold regression model estimated on simulated data.

Description

Computes the relative bias, the bias, the root mean squared error, and the relative root mean squared error.

Usage

perfm(truepar,estpar)

Arguments

truepar

True value of the parameter.

estpar

Vector of the estimated parameters (one value per each simulated dataset).

Details

perfm computes the following performance measures: the relative bias, the bias, the root mean squared error, and the relative root mean squared error.

Value

An object of S4 class "perfm", which is a list with the following values: the true value of the parameters, the relative bias, the bias, the root relative mean squared error, the relative root relative means squared error.

Note

The vector of the estimated parameters can contain missing values that are excluded from the computation of the performance mesaures.

Author(s)

Francesca Marta Lilja Di Lascio <[email protected]>

Selene Perazzini <[email protected]>

References

Di Lascio, F.M.L. and Perazzini, S. (202x) A three-way dynamic panel threshold regression model for change point detection in bioimpedance data. Submitted.

Di Lascio, F.M.L. and Perazzini, S. (2022) Change point detection in fruit bioimpedance using a three-way panel model. Book of short papers - SIS2022, p.1184-1189, Eds. A. Balzanella, M. Bini, C. Cavicchia, R. Verde. Pearson. ISBN: 978-88-9193-231-0.

See Also

See also ptm2, ptm3 and simptm.

Examples

# Simulation of the two-way panel threshold model 
# y_{it} = (-0.7-0.5*x_{it})1(y_{it-1}<=0) + (1.8+0.8*x_{it})1(y_{it-1}>0)
# Two datasets with 20 individuals observed over 15 times with change  
# point at time 12 and an autoregressive error term (with parameter 0.7 
# and unit error variance).

sims <- simptm(n=20, T.=15, J=1, CP=12, gamma=c(0),  
               phi_c=matrix(c(-0.7,1.8), nrow=1, byrow=TRUE), 
               phi_X=matrix(c(-0.5,0.8), nrow=1, byrow=TRUE), sigmau=1, 
               parAR=0.2, B=2, seedstart=1)

# Estimate the two simulated two-way panel threshold models

estimates1 <- ptm3(sims@simulation[[1]], nameI="i", nameT="t", nameJ="j", 
                   nameY="Y", nameXexo="X1", nameXendo=NULL, nameTV=NULL, 
                   nameIV=NULL, trimrate=0.4, ngrid=100, h0=1.5, 
                   Iweight=FALSE, test.lin=FALSE)

estimates2 <- ptm3(sims@simulation[[2]], nameI="i", nameT="t", nameJ="j", 
                   nameY="Y", nameXexo="X1", nameXendo=NULL, nameTV=NULL, 
                   nameIV=NULL, trimrate=0.4, ngrid=100, h0=1.5,
                   Iweight=FALSE, test.lin=FALSE)

# Compute performance measures for the parameter beta of the exogenous 
# regressor (for details see refs)
pm1 <- perfm(truepar=-0.5, estpar=c(estimates1@param[,2],
             estimates2@param[,2]))
pm1

# Compute performance measures for the delta corresponding to the
# difference between the constants of the model (for details see refs)
pm2 <- perfm(truepar=c(1.8+0.7), estpar=c(estimates1@param[,4], 
             estimates2@param[,4]))
pm2

# Compute performance measures for the delta corresponding to the
# difference between the regressors coefficients of the model 
# (for details see refs)
pm3 <- perfm(truepar=c(0.8+0.5), estpar=c(estimates1@param[,6],
             estimates2@param[,6]))
pm3

Class "perfm"

Description

A class for perfm and its extensions

Objects from the Class

Objects can be created by calls of the form new("perfm", ...).

Slots

trueval

Object of class numeric. The true value of the parameter.

rb

Object of class numeric. The relative bias.

nrb

Object of class numeric. The bias.

rrmse

Object of class numeric. The relative root mean squared error.

rmse

Object of class numeric. The root mean squared error.

Methods

No methods defined with class "perfm" in the signature.

Author(s)

Selene Perazzini <[email protected]>

Francesca Marta Lilja Di Lascio <[email protected]>

References

Di Lascio, F.M.L. and Perazzini, S. (202x) A three-way dynamic panel threshold regression model for change point detection in bioimpedance data. WP BEMPS <https://repec.unibz.it/bemps104.pdf>.

Di Lascio, F.M.L. and Perazzini, S. (2022) Change point detection in fruit bioimpedance using a three-way panel model. Book of short papers - SIS2022, p.1184-1189, Eds. A. Balzanella, M. Bini, C. Cavicchia, R. Verde. Pearson. ISBN: 978-88-9193-231-0.

See Also

See also perfm.

Examples

showClass("perfm")

Two-way panel threshold regression model.

Description

Two-way panel threshold regression model with the 2-step GMM estimator.

Usage

ptm2(Y, TV=NULL, Xendo=NULL, Xexo=NULL, IV=NULL, trimrate=0.4,  
    ngrid=100, h0=1.5, Iweight=FALSE, test.lin=TRUE, B=1000)

Arguments

Y

a N×TN\times T matrix of the dependent variable where the rows represent the statistical units and the columns the time.

TV

a N×TN\times T transition variable matrix where the rows represent the statistical units and the columns the time. If not specified, the first lag of YY is taken.

Xendo

a Nkendo×TNk_{endo}\times T matrix of the independent variables (if any). The rows contain in order X1i=1,X1i=2,,X1i=N,X2i=1,X2i=2,,X2i=N,,Xkendoi=1,X_{1i=1}, X_{1i=2}, \dots, X_{1i=N}, X_{2i=1},X_{2i=2}, \dots, X_{2i=N}, \dots, X_{k_{endo}i=1}, Xkendoi=2,,Xkendoi=NX_{k_{endo}i=2}, \dots, X_{k_{endo}i=N}.

Xexo

a Nkexo×TNk_{exo}\times T matrix of the independent variables (if any). The rows contain in order X1i=1,X1i=2,,X1i=N,X2i=1,X2i=2,,X2i=N,,Xkexoi=1,X_{1i=1}, X_{1i=2}, \dots, X_{1i=N}, X_{2i=1},X_{2i=2}, \dots, X_{2i=N}, \dots, X_{k_{exo}i=1}, Xkexoi=2,,Xkexoi=NX_{k_{exo}i=2}, \dots, X_{k_{exo}i=N}.

IV

a matrix of the additional instrumental variables to include in the analysis. The rows contain in order z1i=1,z1i=2,,z1i=N,z2i=1,z2i=2,,z2i=N,,z_{1i=1}, z_{1i=2}, \dots, z_{1i=N}, z_{2i=1}, z_{2i=2}, \dots, z_{2i=N}, \dots, \quad zli=1,zli=2,,zli=Nz_{li=1}, z_{li=2}, \dots, z_{li=N}. The lagged dependent and independent variables are automatically included in the estimation and should not be specified in IV. If not specified, only the lags of the dependent and independent variables are taken as instrumental variables.

trimrate

the trim rate when constructing the grid for estimating the threshold. Default is set to 0.4.

ngrid

the number of grid points to estimate the threshold. Default is set to 100.

h0

the parameter for Silverman's rule of thumb for kernel estimation. The default is set to 1.5.

Iweight

the 1-st step weight matrix. If TRUE, the identity matrix is used. If FALSE, the 1-st step weight matrix is constructed from the instrumental variables and the moments matrix. Default is set to FALSE.

test.lin

if TRUE (default), the linearity test is performed; if FALSE, not.

B

if test.lin=TRUE, it is the number of bootstrap iterations for the linearity test.

Details

ptm2 performs the first-difference 2-step GMM estimator by Seo and Shin (2016) for panel threshold regression. The following steps are performed in the estimation algorithm:

  1. Computes the first differences of the dependent and independent variables.

  2. Defines the instrumental variables matrix, which includes the lagged dependent and independent variables, and the additional instrumental variables in the IV matrix (if specified).

  3. Constructs the 1-st step weight matrix according to the Iweight option.

  4. Identifies a set of equally distant points between quantiles (trimrate/2) and 1-(trimrate/2) of the threshold variable vector. The number of points is specified in the option ngrid.

  5. Computes the GMM estimator setting the threshold equal to each selected point and computes the residuals. Identifies the 1st-step estimator by minimizing the residual.

  6. Constructs the 2nd-step weight matrix from the residuals associated with the 1st-step estimator.

  7. Repeats steps 4. and 5. and returns the 2nd-step estimator of the 1st-differenced parameters, the threshold, and the covariance matrix.

Value

An object of S4 class "ptm2", which is a list with the following elements:

threshold

the estimated threshold and the associated p-value.

estimates

the matrix of the estimated first-differenced parameters (i.e. parameter(s) estimated for the lower regime, the difference between the parameter(s) estimated for the upper and the lower regime) and the associated p-values.

cov.

the sample version of covariance matrix of the estimated paramaters.

residuals.

the matrix of the first-differenced residuals.

test.lin.

the list of the linearity test results containing: the name of the test; the number of bootstrap iterations carried out; the p-value of the test.

Note

The method requires at least 6 times of observation: four lags of the dependent and independent variables are used as instruments, and two more are necessary to identify the regime switch (i.e., one per regime).

Author(s)

Francesca Marta Lilja Di Lascio <[email protected]>

Selene Perazzini <[email protected]>

References

Seo, M.H. and Shin, Y. (2016) Dynamic panels with threshold effect and endogeneity. Journal of Econometrics, 195(2), p.169-186.

Seo, M.H., Kim, S. and Kim Y.-J. (2019) Estimation of dynamic panel threshold model using Stata. The Stata Journal, 19(3), p.685-697.

See Also

See also ptm3 and simptm.

Examples

## Select data
data(banana)
data <- banana[which(banana$j==1),]

# Prepare input matrices for ptm2
bioimpedance <-  matrix(data$bioimpedance, ncol=length(unique(data$t)), 
                        byrow=TRUE)

weight <-  matrix(data$weight, ncol=length(unique(data$t)), byrow=TRUE)

## Estimation

# Model on bioimpedance y_{it} with transition variable y_{i(t-1)}
# y_{it}= (phi1_c)1(y_{it-1}<= gamma) + (phi2_c)1(y_{it-1}>gamma)
# Estimation and linear test
ptm2(Y=bioimpedance, TV=NULL, Xendo=NULL, Xexo=NULL, IV=NULL,  
     trimrate=0.4, ngrid=100, h0=1.5, Iweight=FALSE, test.lin=TRUE, 
     B=100)

## NOT RUN
## Model on bioimpedance y_{it} with transition variable y_{i(t-1)} and 
## weight as regressor x_{it}: 
## y_{it}= (phi1_c + phi1_X*x_{it})1(y_{it-1}<= gamma) + 
##         (phi2_c + phi2_X*x_{it})1(y_{it-1}>gamma)
#ptm2(Y=bioimpedance, TV=NULL, Xendo=weight, Xexo=NULL, IV=NULL,  
#     trimrate=0.4, ngrid=100, h0=1.5, Iweight=FALSE, test.lin=FALSE)
##

Class "ptm2"

Description

A class for ptm2 and its extensions

Objects from the Class

Objects can be created by calls of the form new("ptm2", ...).

Slots

threshold:

Object of class numeric. The estimated threshold and the associated p-value.

estimates:

Object of class numeric. The vector of the parameter(s) estimated for the lower regime, the difference between the parameter(s) estimated for the upper and the lower regime, and the associated p-values.

cov.:

Object of class matrix. The sample version of covariance matrix of the estimated paramaters.

residuals.:

Object of class matrix. A matrix of the first-differenced residuals.

test.lin.:

Object of class list. Result of the linearity test.

Methods

No methods defined with class "ptm2" in the signature.

Author(s)

Selene Perazzini <[email protected]>

Francesca Marta Lilja Di Lascio <[email protected]>

References

Seo, M.H. and Shin, Y. (2016) Dynamic panels with threshold effect and endogeneity. Journal of Econometrics, 195(2), p.169-186.

Seo, M.H., Kim, S. and Kim Y.-J. (2019) Estimation of dynamic panel threshold model using Stata. The Stata Journal, 19(3), p.685-697.

See Also

See also ptm2.

Examples

showClass("ptm2")

Three-way panel threshold regression model.

Description

Three-way panel threshold regression model and its estimation through the 2-step GMM estimator.

Usage

ptm3(data., nameI, nameT, nameJ, nameY, nameTV=NULL, nameXendo=NULL, 
    nameXexo=NULL, nameIV=NULL, trimrate=0.4, ngrid=100, h0=1.5,
    Iweight=FALSE, test.lin=TRUE, B=1000)

Arguments

data.

a data.frame with the following variables (by cols): II (statistical units ID), TT (time), JJ (third-level), YY (dependent variable), and if not null, TVTV (threshold variable), XendoXendo (endogenous regressor(s)), XexoXexo (exogenous regressor(s)), IVIV (instruments).

nameI

the name of the (numerical) variable that identifies the statistical units.

nameT

the name of the (numerical) time variable.

nameJ

the name of the (numerical) variable that indicates the third dimension.

nameY

the name of the (numerical) dependent variable.

nameTV

the name of the (numerical) transition variable. If not specified, the first lag of YY is taken.

nameXendo

the names of the (numerical) independent endogenous variables (if any).

nameXexo

the names of the (numerical) independent exogenous variables (if any).

nameIV

the names of the (numerical) instrumental variables (if any).

trimrate

the trim rate when constructing the grid for estimating the threshold. The default value is set to 0.4.

ngrid

the number of grid points to estimate the threshold. The default is set to 100.

h0

the parameter for Silverman's rule of thumb for kernel estimation. The default is set to 1.5.

Iweight

the 1-st step weight matrix. If TRUE, the identity matrix is used. If FALSE, the 1-st step weight matrix is constructed from the instrumental variables. The default is set to FALSE.

test.lin

if TRUE (default), the linearity test is performed; if FALSE, not.

B

if test.lin=TRUE, the number of bootstrap iterations for the linearity test.

Details

ptm3 performs the first-difference 2-step GMM estimation of the three-way panel threshold regression model in Di Lascio and Perazzini (202X).

Value

An object of S4 class "ptm3", which is a list with the following elements:

threshold

the matrix of the estimated thresholds and the associated p-values.

param

the matrix of the estimated first-differenced parameters of the model and the associated p-values.

cov.

the array containing the estimated covariance matrix per each value of the third way.

residuals.

the list containing the estimated first-differenced residuals per each value of the third way.

test.lin.

the list of the linearity test results containing: the name of the test; the number of bootstrap iterations carried out; the p-value of the test per each value of the third way.

Note

The estimation method requires at least t6t\geq6: four lags of the dependent and independent variables are used as instruments, and two more are necessary to identify the regime switch (i.e., one per regime). Note that the instant times in the nameT variable are automatically ordered increasingly.

Author(s)

Francesca Marta Lilja Di Lascio <[email protected]>

Selene Perazzini <[email protected]>

References

Di Lascio, F.M.L. and Perazzini, S. (202x) A three-way dynamic panel threshold regression model for change point detection in bioimpedance data. WP BEMPS <https://repec.unibz.it/bemps104.pdf>.

Di Lascio, F.M.L. and Perazzini, S. (2022) Change point detection in fruit bioimpedance using a three-way panel model. Book of short papers - SIS2022, p.1184-1189, Eds. A. Balzanella, M. Bini, C. Cavicchia, R. Verde. Pearson. ISBN: 978-88-9193-231-0.

See Also

See also ptm2 and simptm.

Examples

# Import data
data(banana)

## NOT RUN
## Model on bioimpedance y_{ijt} with transition variable y_{ij(t-1)}
## y_{ijt} = (phi1_{jc})1(y_{ijt-1}<=gamma_j) + 
##           (phi2_{jc})1(y_{ijt-1}>gamma_j)
#
#ptm3(data.=banana, nameI="i", nameT="t", nameJ="j", 
#    nameY="bioimpedance", nameTV=NULL, nameXendo=NULL, nameXexo=NULL, 
#    nameIV=NULL, trimrate=0.4, ngrid=100, h0=1.4, Iweight=FALSE, 
#    test.lin=FALSE)
##

# Model on bioimpedance y_{ijt} with transition variable y_{ij(t-1)} 
# and time-varying regressor x_{ijt}: 
# y_{it}=(phi1_{jc}+phi1_{jX}*x_{ijt})1(y_{ijt-1}<=gamma_j) + 
# (phi2_{jc}+phi2_{jX}*x_{ijt})1(y_{ijt-1}>gamma_j)

ptm3(data.=banana, nameI="i", nameT="t", nameJ="j",nameY="bioimpedance", 
    nameTV=NULL, nameXendo="weight", nameXexo=NULL, nameIV=NULL,
    trimrate=0.4, ngrid=100, h0=1.5, Iweight=FALSE, test.lin=FALSE)

Class "ptm3"

Description

A class for ptm3 and its extensions

Objects from the Class

Objects can be created by calls of the form new("ptm3", ...).

Slots

threshold:

Object of class numeric. A vector of the estimated thresholds and the associated p-values.

param:

Object of class matrix. A matrix of the estimated first-differenced parameters of the model and the associated p-values.

cov.:

Object of class array. The sample covariance matrix of the estimated parameters per each value of the third way.

residuals.:

Object of class list. The estimated first-differenced residuals per each value of the third way.

test.lin.:

Object of class list. Result of the linearity test.

Methods

No methods defined with class "ptm3" in the signature.

Author(s)

Selene Perazzini <[email protected]>

Francesca Marta Lilja Di Lascio <[email protected]>

References

Di Lascio, F.M.L. and Perazzini, S. (202x) A three-way dynamic panel threshold regression model for change point detection in bioimpedance data. WP BEMPS <https://repec.unibz.it/bemps104.pdf>.

Di Lascio, F.M.L. and Perazzini, S. (2022) Change point detection in fruit bioimpedance using a three-way panel model. Book of short papers - SIS2022, p.1184-1189, Eds. A. Balzanella, M. Bini, C. Cavicchia, R. Verde. Pearson. ISBN: 978-88-9193-231-0.

See Also

See also ptm3.

Examples

showClass("ptm3")

Data simulation from two- or three-way panel threshold regression model.

Description

Random generation of data from two- or three-way panel threshold regression model with or without a time-varying regressor.

Usage

simptm(n, T., J=2, CP, gamma.=c(0,0), 
        phi_c=matrix(c(-1,1,-0.7,1.8), nrow=2, byrow=TRUE), 
        phi_X=matrix(c(-0.2,0.2,-0.5,0.8), nrow=2, byrow=TRUE), 
        sigmau=1, parAR=c(0.7,0.5), B=200, seedstart=1)

Arguments

n

number of statistical units.

T.

number of times.

J

number of third way's values.

CP

vector of times of regime switch (one per each jj). If vector of length 1, the same change point is taken for all the jjs.

gamma.

vector of length J of threshold values.

phi_c

matrix J×2J\times 2 of the constant parameters of the two regimes; first column for lower (upper) regime and second column for upper (lower) regime.

phi_X

matrix J×2J\times 2 of the regressor parameter of the two regimes; first column for lower (upper) regime and second column for upper (lower) regime.

sigmau

possible constant to be applied to the error term distributed as a Gaussian white noise.

B

number of datasets to be drawn.

parAR

vector of autoregressive parameter(s) (one for each jj) to generate a (exogenous) time-varying regressor.

seedstart

number of the initial seed.

Details

simptm generates B datasets from a two- or three-way panel threshold regression model with n statistical units, T. times of observations and J values/levels for the third dimension. The data generating process is constituted by two regimes with a change point at time CP and a threshold value yt1=γjy_{t-1} = \gamma_j for each value/level jj of the third way. The two regimes are defined by the constant parameters phi_c or phi_c and parameters for the time-varying regressor phi_X. In the current version of the package, it is thus possible to generate data from a model without regressors or with a time-varying regressor. The (exogenous) time-varying regressor is assumed to be distributed as an autoregressive stochastic process with the jj-th parameter of the parAR. The error component is generated from a Gaussian white noise and can be rescaled through the constant sigmau.

Value

An object of S4 class "simptm", which is a list of simulated data matrices.

Note

The estimation method requires at least T.6T.\geq6: four lags of the dependent and independent variables are used as instruments, and two more are necessary to identify the regime switch (i.e., one per regime). The output is a list of B dataframes. Each dataframe contains columns: ii, jj, tt, YY and possibly XX.

Author(s)

Francesca Marta Lilja Di Lascio <[email protected]>

Selene Perazzini <[email protected]>

References

Di Lascio, F.M.L. and Perazzini, S. (202x) A three-way dynamic panel threshold regression model for change point detection in bioimpedance data. WP BEMPS <https://repec.unibz.it/bemps104.pdf>.

Di Lascio, F.M.L. and Perazzini, S. (2022) Change point detection in fruit bioimpedance using a three-way panel model. Book of short papers - SIS2022, p.1184-1189, Eds. A. Balzanella, M. Bini, C. Cavicchia, R. Verde. Pearson. ISBN: 978-88-9193-231-0.

Seo, M.H. and Shin, Y. (2016) Dynamic panels with threshold effect and endogeneity, Journal of Econometrics, 195(2), p.169-186.

See Also

See also ptm2 and ptm3.

Examples

## NOT RUN
#
## Simulation of 10 two-way panels  
## y_{it} = (-1-0.2*x_{it})1(y_{it-1}<=0) + (1+0.2*x_{it})1(y_{it-1}>0) 
## with 50 statistical units observed for 50 times with change point at 
## time 20, autoregressive parameter 0.7, and sigmau=1. 
#
DB1 <- simptm(n=50, T.=11, J=1, CP=8, gamma.=0, phi_c=matrix(c(-1,1), 
     nrow=1, byrow=TRUE), phi_X=matrix(c(-0.2,0.2), nrow=1, byrow=TRUE), 
     sigmau=1, parAR=0.7, B=10, seedstart=1)
#head(DB1@simulation)
#str(DB1@simulation)
    
## Simulation of 10 three-way panels 
## y_{i1t} = (-1-0.2*x_{i1t})1(y_{i1t-1}<=0) + 
##           (1+0.2*x_{i1t})1(y_{i1t-1}>0)
## y_{i2t} = (-0.7-0.5*x_{i2t})1(y_{i2t-1}<=0) + 
##           (1.8+0.8*x_{i2t})1(y_{i2t-1}>0)
## with 50 statistical units, 50 times, J=2, change point corresponding to 
## time 20, with autoregressive parameter 0.7, and sigmau=1. 
#
#DB2 <- simptm(n=50, T.=20, J=2, CP=10, gamma.=c(0,0), 
#    phi_c=matrix(c(-1,1,-0.7,1.8), nrow=2, byrow=TRUE), 
#    phi_X=matrix(c(-0.2,0.2,-0.5,0.8), nrow=2, byrow=TRUE), sigmau=1, 
#    parAR=rep(0.7,2), B=5, seedstart=1)
#head(DB2@simulation)
#str(DB2@simulation)
#
##

Class "simptm"

Description

A class for simptm and its extensions

Objects from the Class

Objects can be created by calls of the form new("simptm", ...).

Slots

simulation

Object of class "list". A list of dataframes of simulated data. The list contains B dataframes, one for each replication. Each dataframe contains columns: ii, jj, tt, YY and possibly XX.

Methods

No methods defined with class "simptm" in the signature.

Author(s)

Selene Perazzini <[email protected]>

Francesca Marta Lilja Di Lascio <[email protected]>

References

Di Lascio, F.M.L. and Perazzini, S. (202x) A three-way dynamic panel threshold regression model for change point detection in bioimpedance data. WP BEMPS <https://repec.unibz.it/bemps104.pdf>.

Di Lascio, F.M.L. and Perazzini, S. (2022) Change point detection in fruit bioimpedance using a three-way panel model. Book of short papers - SIS2022, p.1184-1189, Eds. A. Balzanella, M. Bini, C. Cavicchia, R. Verde. Pearson. ISBN: 978-88-9193-231-0.

Seo, M. and Shin, Y. (2016) Dynamic panels with threshold effect and endogeneity. Journal of Econometrics, 195(2), p.169-186.

See Also

See also simptm.

Examples

showClass("simptm")