cable.ar.p.iter: Bent-Cable Regression for Independent or AR Data, With...

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

View source: R/code.r

Description

This function is the main engine for bentcable.ar. It performs bent-cable (including broken-stick) regression to AR(p) time-series data or independent data (time-series or otherwise). However, it cannot fit broken sticks to independent data (see stick.ar.0).

Usage

1
2
cable.ar.p.iter(init, y.vect, t.vect = NULL, n = NA, tol,
	method0 = "css", method1 = "yw", stick = FALSE)

Arguments

init

A numeric vector of initial values, in the form of c(b0,b1,b2,tau,gamma,phi.1,...,phi.p) when stick=FALSE, and c(b0,b1,b2,tau,phi.1,...,phi.p) when stick=TRUE. phi values correspond to AR(p) coefficients - if not included, then independent data are assumed.

y.vect

A numeric vector of response data.

t.vect

A numeric vector of design points, which MUST be equidistant with unit increments if AR(p) is assumed. They need not be equidistant for independent data. Specifying t.vect=NULL is equivalent to specifying the default time points c(0,1,2,...).

n

Length of response vector (optional).

tol

Tolerance for determining convergence.

method0, method1

The fitting method when p>0. "css" stands for conditional sum-of-squares and corresponds to conditional maximum likelihood. "yw" stands for Yule-Walker, and "mle" for (full) maximum likelihood estimation. If method0 fails to converge, then method1 is attempted.

stick

A logical value; if TRUE, a broken-stick regression is performed.

Details

The bent cable has the form f(t) = b_0 + b_1 t + b_2 q(t), where q(t) is the basic bent cable

q(t)=\frac{(t-τ+γ)^2}{4γ} I\{|t-τ|≤γ\} + (t-τ) I\{t>τ+γ\}

for γ≥ 0.

For independent data (time series or otherwise), bent-cable regression by maximum likelihood is performed via nonlinear least-squares estimation of θ=(b_0,b_1,b_2,τ,γ) through the built-in R function nls. For AR(p) data, conditional maximum likelihood (CML) estimation of (θ,φ) (conditioned on the first p data points) is performed through the built-in R function optim with the "BFGS" algorithm, where φ=(φ_1,…,φ_p) are the AR coefficients. In either case, the estimation relies on the user-supplied initial values in init. A Gaussian model is assumed, so that CML estimation is equivalent to minimizing the conditional sum-of-squares error, specified as "css" by default for method0. However, "css" sometimes fails to converge, or the resulting φ estimate sometimes corresponds to non-stationarity. In this case, the alternative estimation approach specified for method1 is attempted. "mle" specifies the CML-ML hybrid algorithm, and "yw" the CML-ML-MM hybrid algorithm (MM stands for method of moments; see References.) Both "yw" and "mle" guarantee stationarity, but often take much longer than "css" to converge.

The bent-cable likelihood / deviance often has multiple peaks. Thus, the user should be aware of different local maxima on which the optimization algorithm can converge despite initial values for θ that are very similar. The user is advised to combine several exploratory analyses as well as model diagnoses before settling on a best fit. See Details on the bentcable.ar help page for a detailed description.

Value

fit

An nls object, returned if independent data are assumed. It is the maximum likelihood bent-cable fit.

estimate

A numeric vector, returned if AR(p>0) is assumed. It is the estimated value of (θ,φ).

ar.p.fit

Returned if AR(p>0) is assumed. If "css" is used, converges, and yields a φ estimate that corresponds to stationarity, then $ar.p.fit is an optim object containing the CML fit. If "yw" or "mle" is used and converges, then $ar.p.fit is an ar object containing the CML-ML(-MM) fit.

y, t, n, p, stick

As supplied by the user; always returned.

method

A character string, returned if AR(p>0) is assumed. It indicates the method that yielded the returned fit.

Note

This function is intended for internal use by bentcable.ar.

For several fits that assume a common p, their (conditional) likelihood values should be compared to screen out those that result from local maxima. Equivalently, the (conditional) sum-of-squares error (SSE) can be compared and only the smallest kept. See Examples below. Also see Details on the bentcable.ar help page.

Author(s)

Grace Chiu

References

See the bentcableAR package references.

See Also

stick.ar.0, fullcable.t, bentcable.dev.plot, nls, optim, ar.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
data(stagnant)
data(sockeye)

# 'stagnant': independent data cable fit
fit0 <- cable.ar.p.iter( c(.6,-.4,-.7,0,.5),
	stagnant$loght, stagnant$logflow )    # 'nls' fit
	# compare to this:
	# bentcable.ar( stagnant$loght, t.vect=stagnant$logflow,
	#	init.cable=c(.6,-.4,-.7,0,.5) )

fit0$fit   # 'fit0' SSE=0.005


# 'sockeye': AR(2) cable fit
fit1 <- cable.ar.p.iter( c(13,.1,-.5,11,4,.5,-.5),
	sockeye$logReturns, tol=1e-4 )    # "css" successful
	# compare to this:
	# fit1 <- bentcable.ar( sockeye$logReturns, 
	#	init.cable=c(13,.1,-.5,11,4), p=2 )

fit1$ar.p.fit$value     # 'fit1' SSE=4.9


# 'sockeye': AR(2) cable fit
fit2 <- cable.ar.p.iter( c(10,0,0,5,.1,.5,-.5), sockeye$logReturns, 
	tol=1e-4 )    # "css" unsuccessful, switched to "yw"
	# compare to this:
	# fit2 <- bentcable.ar(sockeye$logReturns, 
	#	init.cable=c(10,0,0,5,.1), p=2 )

cable.ar.p.iter( fit2$est, sockeye$logReturns, 
	tol=1e-4 )   # 'fit2' SSE=13.8 (from first line of screen output)


# 'sockeye': AR(4) stick fit
cable.ar.p.iter( c(13,.1,-.5,11,.5,-.5,.5,-.5),
	sockeye$logReturns, tol=1e-4, stick=TRUE )
	# compare to this:
	# bentcable.ar( sockeye$logReturns,
	#	init.cable=c(13,.1,-.5,11), p=4, stick=TRUE )

bentcableAR documentation built on May 30, 2017, 2:11 a.m.