Learn R Programming

PSTR (version 2.0.0)

plot_target: Plot the surface of the target function for nonlinear least squares estimation

Description

This function plots a 3-D surface of the nonlinear least squares (NLS) target function used in estimating a PSTR model. It is mainly intended as a diagnostic tool for choosing reasonable initial values for the nonlinear parameters.

Usage

plot_target(
  obj,
  im = 1,
  iq = NULL,
  par = NULL,
  basedon = c(1, 2),
  from,
  to,
  length.out = 40
)

Value

A plotly object representing a 3-D surface plot of the target function values evaluated on the specified parameter grid.

Arguments

obj

An object of class "PSTR".

im

Integer. The number of switches \(m\) in the transition function used to construct the target function surface. Default is 1.

iq

Either an integer index (a column number in the transition-variable matrix) or a character string (a transition-variable name) specifying which transition variable is used when computing the target function.

par

Numeric vector of length 1 + im giving fixed values of the nonlinear parameters in the order c(delta, c_1, ..., c_m). If NULL, the function constructs a default initial vector from quantiles of the chosen transition variable.

basedon

Integer vector of length 2. Positions in par indicating the two parameters to vary on the grid. The values at these positions in par are ignored and replaced by grid values. Use 1 for \(\delta\), and 2:(im+1) for \(c_1, \ldots, c_m\).

from

Numeric vector of length 2. Lower bounds (start values) for the two grid parameters specified by basedon.

to

Numeric vector of length 2. Upper bounds (end values) for the two grid parameters specified by basedon.

length.out

Either a scalar or a numeric vector of length 2. If scalar, the same number of grid points is used for both dimensions. If length 2, the first element controls the grid resolution for the first parameter in basedon, and the second for the second parameter.

Details

The target function is evaluated on a two-dimensional grid over two selected parameters, while all other nonlinear parameters are held fixed at values provided by par. The nonlinear parameter vector is always ordered as \(\delta, c_1, \ldots, c_m\), where \(\gamma = \exp(\delta)\) and \(m = im\).

In addition to the exported function plot_target(obj = ...), the same functionality is available as an R6 method via obj$plot_target(...).

See Also

NewPSTR, LinTest, WCB_LinTest, EstPSTR, EvalTest, WCB_TVTest, WCB_HETest

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) Exported function interface
ret <- plot_target(obj = pstr, iq = 1, basedon = c(1, 2),
                   from = c(log(1), 6), to = c(log(18), 10),
                   length.out = c(40, 40))

# 2) R6 method interface
ret2 <- pstr$plot_target(iq = 1, basedon = c(1, 2),
                         from = c(log(1), 6), to = c(log(18), 10),
                         length.out = c(40, 40))
# }

Run the code above in your browser using DataLab