Learn R Programming

PSTR (version 2.0.0)

EstPSTR: Estimate a PSTR model by nonlinear least squares

Description

EstPSTR estimates either a nonlinear PSTR model (when iq is provided) or a linear fixed-effects panel regression (when iq = NULL).

Usage

EstPSTR(
  use,
  im = 1,
  iq = NULL,
  par = NULL,
  useDelta = FALSE,
  vLower = 2,
  vUpper = 2,
  method = "L-BFGS-B"
)

Value

Invisibly returns use with estimation results added. In particular, for a nonlinear PSTR model (iq not NULL), the object contains (among others):

delta

Estimate of \(\delta\).

gamma

Estimate of \(\gamma = \exp(\delta)\).

c

Estimates of \(c_1,\ldots,c_m\).

vg

Estimated transition-function values \(g_{it}\).

beta

Estimated coefficients (named as var_0 for linear-part coefficients and var_1 for nonlinear-part coefficients).

vU

Residuals.

vM

Estimated individual effects.

s2

Estimated residual variance.

cov

Cluster-robust and heteroskedasticity-consistent covariance matrix of all estimates.

se

Standard errors corresponding to est.

est

Vector of all estimates (coefficients followed by nonlinear parameters).

mbeta

Estimates of coefficients in the second extreme regime (when available).

mse

Standard errors for mbeta (when available).

For a linear fixed-effects model (iq = NULL), the object contains beta, vU, vM, s2, cov, se, and est.

Arguments

use

An object of class "PSTR" created by NewPSTR.

im

Integer. Number of switches \(m\) in the transition function. Default is 1.

iq

Either an integer index (column number in the transition-variable matrix) or a character string (transition-variable name) specifying which transition variable to use. If NULL, a linear fixed-effects panel regression is estimated.

par

Numeric vector of length im + 1 giving initial values for the nonlinear parameters. The expected order is c(delta, c_1, ..., c_m) if useDelta = TRUE, or c(gamma, c_1, ..., c_m) if useDelta = FALSE. If NULL, defaults are constructed automatically and useDelta is ignored.

useDelta

Logical. If TRUE, the first element of par is interpreted as \(\delta\). If FALSE, it is interpreted as \(\gamma\) and internally converted to \(\delta = \log(\gamma)\) before optimisation.

vLower

Numeric scalar or vector. Lower offsets defining the lower bounds in the optimiser. Bounds are applied to the internal parameter vector used in optimisation (with the first element being \(\delta\)).

vUpper

Numeric scalar or vector. Upper offsets defining the upper bounds in the optimiser. Bounds are applied to the internal parameter vector used in optimisation (with the first element being \(\delta\)).

method

Character. Optimisation method passed to stats::optim. Default is "L-BFGS-B" (bounded optimisation).

Details

Two equivalent interfaces are available:

  1. Wrapper function: EstPSTR(use = obj, ...).

  2. R6 method: obj$EstPSTR(...).

The wrapper calls the corresponding R6 method and returns use invisibly.

The transition function is logistic and depends on a transition variable \(q_{it}\) and nonlinear parameters \(\gamma > 0\) and switching locations \(c_1 < \cdots < c_m\): $$g(q_{it}; \gamma, c_1,\ldots,c_m) = \left(1 + \exp\left[-\gamma \prod_{j=1}^{m}(q_{it}-c_j)\right]\right)^{-1}.$$ The smoothness parameter is internally reparametrised as \(\gamma = \exp(\delta)\), where \(\delta \in \mathbb{R}\). The optimisation is always carried out in \(\delta\) and \(c\).

If par = NULL, the function constructs default initial values from quantiles of the selected transition variable and treats the first element as \(\delta\).

See Also

NewPSTR, LinTest, WCB_LinTest, EvalTest, stats::optim.

Examples

Run this code
# \donttest{
pstr <- NewPSTR(Hansen99, dep = "inva", indep = 4:20,
               indep_k = c("vala","debta","cfa","sales"),
               tvars = c("vala"), iT = 14)

# 1) Linear fixed-effects model
pstr <- EstPSTR(use = pstr)
print(pstr, mode = "estimates", digits = 6)

# 2) Nonlinear PSTR model
pstr <- EstPSTR(use = pstr, im = 1, iq = 1, useDelta = TRUE,
               par = c(.63, 0), vLower = 4, vUpper = 4)
print(pstr, mode = "estimates", digits = 6)

# R6 method interface (equivalent)
pstr$EstPSTR(im = 1, iq = 1, useDelta = TRUE, par = c(.63, 0), method = "CG")
# }

Run the code above in your browser using DataLab