# 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
Run the code above in your browser using DataLab