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 |
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).
A matrix containing three-way observations.
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.
A measure for computing the time at which a regime changes, i.e. the change point.
cpoint(data., nameI=NA, nameT=NA, nameJ=NA, nameY=NA, thresholds)
cpoint(data., nameI=NA, nameT=NA, nameJ=NA, nameY=NA, thresholds)
data. |
A (two-way or three-way) panel dataset. It can be either a |
nameI |
If data. is a |
nameT |
If data. is a |
nameJ |
If data. is a |
nameY |
If data. is a |
thresholds |
The vector of estimated threshold value(s). If data. is a |
cpoint
computes the change point on the dependent variable () for each statistical unit i given the time series of
and the estimated threshold value
.
If the observed value
is greater (lower) than the estimated threshold parameter,
belongs to the upper (lower) regime,
and the change point is identified as the time
after which the longest sequence of days in the lower (upper) regime is observed.
An object of S4 class "cpoint", which is a matrix
reporting the change point per each statistical unit and each
.
The change point is detected in 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).
Francesca Marta Lilja Di Lascio <[email protected]>
Selene Perazzini <[email protected]>
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 banana
, ptm2
, and ptm3
.
# 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]]) ##
# 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]]) ##
A class for cpoint
and its extensions
Objects can be created by calls of the form new("cpoint", ...)
.
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.
No methods defined with class "cpoint" in the signature.
Selene Perazzini <[email protected]>
Francesca Marta Lilja Di Lascio <[email protected]>
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.
showClass("cpoint")
showClass("cpoint")
Computes the relative bias, the bias, the root mean squared error, and the relative root mean squared error.
perfm(truepar,estpar)
perfm(truepar,estpar)
truepar |
True value of the parameter. |
estpar |
Vector of the estimated parameters (one value per each simulated dataset). |
perfm
computes the following performance measures: the relative bias, the bias, the root mean squared error, and the relative root mean squared error.
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.
The vector of the estimated parameters can contain missing values that are excluded from the computation of the performance mesaures.
Francesca Marta Lilja Di Lascio <[email protected]>
Selene Perazzini <[email protected]>
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 ptm2
, ptm3
and simptm
.
# 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
# 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
A class for perfm
and its extensions
Objects can be created by calls of the form new("perfm", ...)
.
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.
No methods defined with class "perfm" in the signature.
Selene Perazzini <[email protected]>
Francesca Marta Lilja Di Lascio <[email protected]>
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 perfm
.
showClass("perfm")
showClass("perfm")
Two-way panel threshold regression model with the 2-step GMM estimator.
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)
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)
Y |
a |
TV |
a |
Xendo |
a |
Xexo |
a |
IV |
a matrix of the additional instrumental variables to include in the analysis. The rows contain in order |
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 |
test.lin |
if |
B |
if |
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:
Computes the first differences of the dependent and independent variables.
Defines the instrumental variables matrix, which includes the lagged dependent and independent variables, and the additional instrumental variables in the IV matrix (if specified).
Constructs the 1-st step weight matrix according to the Iweight option.
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.
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.
Constructs the 2nd-step weight matrix from the residuals associated with the 1st-step estimator.
Repeats steps 4. and 5. and returns the 2nd-step estimator of the 1st-differenced parameters, the threshold, and the covariance matrix.
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 |
cov. |
the sample version of covariance matrix of the estimated paramaters. |
residuals. |
the |
test.lin. |
the |
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).
Francesca Marta Lilja Di Lascio <[email protected]>
Selene Perazzini <[email protected]>
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.
## 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) ##
## 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) ##
A class for ptm2
and its extensions
Objects can be created by calls of the form new("ptm2", ...)
.
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.
No methods defined with class "ptm2" in the signature.
Selene Perazzini <[email protected]>
Francesca Marta Lilja Di Lascio <[email protected]>
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 ptm2
.
showClass("ptm2")
showClass("ptm2")
Three-way panel threshold regression model and its estimation through the 2-step GMM estimator.
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)
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)
data. |
a |
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 |
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 |
test.lin |
if |
B |
if |
ptm3
performs the first-difference 2-step GMM estimation of the three-way panel threshold regression model in Di Lascio and Perazzini (202X).
An object of S4 class "ptm3", which is a list with the following elements:
threshold |
the |
param |
the |
cov. |
the |
residuals. |
the |
test.lin. |
the |
The estimation method requires at least : 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.
Francesca Marta Lilja Di Lascio <[email protected]>
Selene Perazzini <[email protected]>
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.
# 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)
# 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)
A class for ptm3
and its extensions
Objects can be created by calls of the form new("ptm3", ...)
.
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.
No methods defined with class "ptm3" in the signature.
Selene Perazzini <[email protected]>
Francesca Marta Lilja Di Lascio <[email protected]>
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 ptm3
.
showClass("ptm3")
showClass("ptm3")
Random generation of data from two- or three-way panel threshold regression model with or without a time-varying regressor.
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)
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)
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 |
gamma. |
vector of length J of threshold values. |
phi_c |
matrix |
phi_X |
matrix |
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 |
seedstart |
number of the initial seed. |
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 for each value/level
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 -th parameter of the
parAR
. The error component is generated from a Gaussian white noise and can be rescaled through the constant sigmau.
An object of S4 class "simptm", which is a list of simulated data matrices.
The estimation method requires at least : 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: ,
,
,
and possibly
.
Francesca Marta Lilja Di Lascio <[email protected]>
Selene Perazzini <[email protected]>
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.
## 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) # ##
## 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) # ##
A class for simptm
and its extensions
Objects can be created by calls of the form new("simptm", ...)
.
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: ,
,
,
and possibly
.
No methods defined with class "simptm" in the signature.
Selene Perazzini <[email protected]>
Francesca Marta Lilja Di Lascio <[email protected]>
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 simptm
.
showClass("simptm")
showClass("simptm")