Package ‘PSTR’
June 3, 2019
Type Package
Title Panel Smooth Transition Regression Modelling
Version 1.2.4
Description Provides the Panel Smooth Transition Regression (PSTR) modelling.
The modelling procedure consists of three stages: Specification, Estimation and Evaluation.
The package offers sharp tools helping the package user(s) to conduct model specification tests,
to do PSTR model estimation, and to do model evaluation.
The tests implemented in the package allow for cluster-dependency and are heteroskedasticity-
consistent.
The wild bootstrap and wild cluster bootstrap tests are also implemented.
Parallel computation (as an option) is implemented in some functions, especially the boot-
strap tests.
The package suits tasks running many cores on super-computation servers.
Depends R (>= 3.0.0)
License GPL-3
Encoding UTF-8
LazyData true
RoxygenNote 6.1.1
Imports tibble, snowfall, ggplot2, plotly, stats, magrittr
Suggests knitr, rmarkdown
URL https://github.com/yukai-yang/PSTR
BugReports https://github.com/yukai-yang/PSTR/issues
VignetteBuilder knitr
NeedsCompilation no
Author Yukai Yang [aut, cre] (<https://orcid.org/0000-0002-2623-8549>)
Maintainer Yukai Yang <yukai.yang@statistik.uu.se>
Repository CRAN
Date/Publication 2019-06-03 19:20:04 UTC
1
2 EstPSTR
R topics documented:
EstPSTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
EvalTest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Hansen99 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
LinTest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
NewPSTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
plot_coefficients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
plot_response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
plot_target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
plot_transition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
print.PSTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
PSTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
sunspot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Index 23
EstPSTR Estimate the PSTR model.
Description
This function implements the estimation of the PSTR model.
Usage
EstPSTR(use, im = 1, iq = NULL, par = NULL, useDelta = FALSE,
vLower = 2, vUpper = 2, method = "L-BFGS-B")
Arguments
use an object of the class PSTR, created by NewPSTR function.
im specifies the number of switches in the transtion function. The default value is
1.
iq a column number (in mQ) or variable name specifying the transition variable to
use.
par initial values for the parameters γ or δ, and c to be optimized over. It is a vector
of length im+1, where im is the number of switches. When missing, the function
will choose the initial values automatically, and useDelta=TRUE.
useDelta whether delta is used in par in the estimation. Note that if par is missing, this
argument will be ignored.
vLower a vector or number of the lower offsets determining the lower bounds of the
parameters. The lower bounds of the parameters are par - vLower.
vUpper a vector or number of the upper offsets determining the upper bounds of the
parameters. The upper bounds of the parameters are par + vUpper.
method the method to be used in optimization. See the function stats::optim.
EstPSTR 3
Details
The function needs the return value (an object of the class PSTR) from the NewPSTR. It copies the
object, reuses its contents to estimate the correspdonding PSTR model, and then returns a new
object of the class PSTR containing the results from the estimation. The user can choose to save the
return value to a new object or simply to overwrite the object returned from NewPSTR.
The PSTR model to be estimated takes the logistic form in nonlinearity. Remember the g function
in the model. It takes the form
g(q
it
; γ, c) =
1 + exp
−γ
m
Y
j=1
(q
it
− c
j
)
−1
with γ > 0 and c
1
< c
2
< ... < c
m
. γ can be reparametrized as γ = exp δ where δ is a real
number.
The user should have obtained the information about which transition variable (q
it
) to use (from
LinTest and/or WCB_LinTest) in estimation before running the function to estimate the model.
The estimation function never change the existing values in the input PSTR object. It adds more
values (attributes) into the input object and return.
Value
a new object of the class PSTR containing the results from the estimation.
The object is a list containing the components made in NewPSTR and the following new components:
iq specify which transition variable will be used in estimation. The default value
NULL implies a linear panel regression model.
delta the estimate of δ.
c the estimates of c.
vg the values of the transition function given the estimates of δ and c and the tran-
sition variables q
it
.
beta the estimates of the coefficient parameters.
vU the residuals.
vM a vector of the estimated time-invariant individual effect.
s2 the variance of the residuals.
cov the covariance matrix of the estimates which is cluster-dependency and het-
eroskedasticity consistent.
est a vector of all the estimates
se a vector of the standard errors of all the estimates which is cluster-dependency
and heteroskedasticity consistent.
mbeta a vector of the estimates of the parameters in the second extreme regime.
mse a vector of the standard errors of the estimates of the parameters in the second
extreme regime.
convergence an integer code showing the convergence, see optim.
par a vector of the initial values used in the optimization. Note that the first element
is always delta, no matter whether gamma is used as input.
4 EvalTest
Author(s)
Yukai Yang, <yukai.yang@statistik.uu.se>
See Also
NewPSTR, LinTest and WCB_LinTest
Examples
pstr = NewPSTR(Hansen99, dep='inva', indep=4:20, indep_k=c('vala','debta','cfa','sales'),
tvars=c('vala'), iT=14) # create a new PSTR object
# estimate a linear panel regression model
pstr = EstPSTR(use=pstr)
print(pstr, "estimates", digits=6)
# "L-BFGS-B" is used by default
pstr = EstPSTR(use=pstr, im=1, iq=1, useDelta=TRUE, par=c(.63,0), vLower=4, vUpper=4)
# You can also choose the method yourself.
pstr = EstPSTR(use=pstr, im=1, iq=1, useDelta=TRUE, par=c(.63,0), method='CG')
print(pstr, "estimates", digits=6)
# The estimation of a linear panel regression model with fix effects is also implemented.
pstr0 = EstPSTR(use=pstr)
print(pstr0,"estimates")
EvalTest Conduct the evaluation tests.
Description
These functions conduct the evaluation tests against two alternatives: 1. the parameters are time-
varying and 2. there is remaining nonlinearity (remaining heterogeneity).
Usage
EvalTest(use, type = c("time-varying", "heterogeneity"), vq = NULL)
WCB_TVTest(use, iB = 100, parallel = F, cpus = 4)
WCB_HETest(use, vq, iB = 100, parallel = F, cpus = 4)
EvalTest 5
Arguments
use an object of the class PSTR, created by EstPSTR function.
type a character vector specifying the types of the evaluation tests to be conducted.
The value can be taken either or both of "time-varying" "heterogeneity".
By default, do both.
vq a vector of a new transition variable for the no remaining nonlinearity test.
iB specify the number of repetitions in the bootstrap procedure. By default, it is
100.
parallel a boolean value showing if the parallel computation is applied.
cpus number of cores used in the parallel computation. The value will be ignored if
parallel=F.
Details
EvalTest implements the evaluation tests.
WCB_TVTest implements the wild bootstrap (WB) and the wild cluster bootstrap (WCB) evaluation
test of no time-varying parameters.
WCB_HETest implements the wild bootstrap (WB) and the wild cluster bootstrap (WCB) evaluation
test of no remaining nonlinearity (no remaining heterogeneity).
The functions need the return value (an object of the class PSTR) from the EstPSTR. Note that the
PSTR model should be estimated before conducting the evaluation tests. They copy the object,
reuse its contents, especially the estimates, to produce the evaluation test results, and then return
a new object of the class PSTR. The user can choose to save the return value to a new object or
simply to overwrite the object returned from EstPSTR. See the example below.
The functions conduct two kinds of evaluation tests. The first kind of tests does the time-varying
evaluation tests. The second kind of tests does the no remaining nonlinearity (no remaining hetero-
geneity) evaluation tests based on the vector of a new transition variable that the user input in the
arguments.
The results of the evaluation tests include four kinds of tests
• χ
2
-version LM test: the LM test with asymptotically χ
2
distribution under the null hypothesis.
• F-version LM test: the LM test with asymptotically F distribution under the null hypothesis.
The finite sample actual size is supposed to be improved.
• χ
2
-version HAC test: the HAC LM test with asymptotically χ
2
distribution under the null
hypothesis, which is heteroskedasticity and autocorrelation consistent.
• F-version HAC test: the HAC LM test with asymptotically F distribution under the null hy-
pothesis, which is heteroskedasticity and autocorrelation consistent. The finite sample actual
size is supposed to be improved.
The wild bootstrap (WB) evaluation tests are heteroskedasticity robust, while the wild cluster boot-
strap (WCB) ones are both cluster-dependency and heteroskedasticity robust. Cluster-dependency
implies that there can be dependency (autocorrelation) within individual, but no correlation across
individuals. The WB and WCB tests may take quite a long time to run which depends on the model
specification and the number of repetitions iB. It is strongly recommended to use super-computation
评论1