plot_target: Plot the surface of the target function for the nonlinear...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/utils.R

Description

This function plots the surface of the target function for the nonlinear least square estimation. It is useful for finding the suitable initial value for the estimation.

Usage

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

Arguments

obj

an object of the class PSTR returned from some functions in the package.

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

a vector of the values of the parameters. NULL by default, then it will be made automatically.

basedon

an integer vector of length 2 specify which two parameters to use to build the grid.

from

a vector of length 2 of the starting (minimal) values of the parameters.

to

a vector of length 2 of the end (maximal) values of the parameters.

length.out

a 2-dim vector or scalar of desired length (number of points) for the parameters. 40 by default.

Details

The funciton uses the plotly package to plot the 3-D surface of the target function for the nonlinear least square estimation.

The function takes the PSTR object as one of the inputs. The user needs to give the number of switches im, and the transition variable iq, such that the target function values can be computed.

The number of parameters to estimate in the nonlinear least square estimation is 1+im, that is, one smoothness parameter and the im switching locations. However, the 3-D plot is based on only two changing parameters with the others (if more than two parameters) constant. Thus, the user needs to input a vector par, which gives the values of the other parameters. Note that par should still be of length 1+im with the order δ (always use delta in this function), c_1, ..., c_m.

The user should give the vector basedon of length two, that shows which two parameters will be used to build the grid. basedon gives the positions of the two parameters in par. Thus, the values in the positions basedon in par will not be used.

from, to and length.out serve to build the grid for the two parameters. These arguments must be of length two for the two parameters, respectively. See the seq function for the details.

Value

A plottable object from the plotly package.

Author(s)

Yukai Yang, yukai.yang@statistik.uu.se

See Also

Functions which return an object of the class PSTR and can be input into this function

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

Examples

1
2
3
4
5
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

# build the grid based on the first two parameters
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))

lxylky1688/PSTRM documentation built on May 19, 2019, 1:47 a.m.