Hi everybody,
I want to fit threshold model for the series "s" and check it.
First I use the package: "TSA" and use the function below:
 
> m=tar(s,p1=2,p2=2,d=0)
           s           time series
          p1        AR order of the lower regime
          p2        AR order of the upper regime
          d          delay parameter(threshold variable)
but before using this we should know: p1, p2, d.
I couldn't find function or script file that compute p1, p2 and especially d as an output.
[let us give an example:
In package:"forecast", the function "auto.arima", return p,d,q (and also P,D,Q) for univariate time series with using AIC or .... .]
I want to know if such a this functionhas bee written in R. 
later I use tsDyn, with this function:

>selectSETAR(s,m=2,thDelay=1:4)
             thDelay          Vector of possible ‘threshold delay’ values to check for
              m                     embedding parameters.

It take me:

> selectSETAR(s,m=2,d=1:4)
Using maximum autoregressive order for low regime: mL = 2 
Using maximum autoregressive order for high regime: mH = 2 
Searching on 1644 possible threshold values within regimes with sufficient ( 15% ) number of observations
Searching on  6576  combinations of thresholds ( 1644 ), thDelay ( 1 ), mL ( 2 ) and MM ( 2 ) 
Results of the grid search for 1 threshold
   thDelay mL mH         th pooled-AIC
1        0  1  1 0.08914057  -192164.2
2        0  1  1 0.11741867  -191949.4
3        0  1  1 0.07618140  -191925.4
4        0  1  1 0.08617770  -191912.9
5        0  1  1 0.07008706  -191891.3
6        0  1  1 0.08875000  -191881.1
7        0  1  1 0.08151686  -191871.3
8        0  1  1 0.11954515  -191852.8
9        0  1  1 0.10694656  -191843.4
10       0  1  1 0.05170137  -191816.2
Warning message:
In if ((m * d + steps) > n) stop("time series too small to handle these embedding parameters") :
  the condition has length > 1 and only the first element will be used


I don't know how could determine "tsDelay". Also I confused becuase I input "1:4" for tsDelay but function compute AIC just for tsDelay=0 and just for threshold 1.
 Also ,it has an error,this problem say fit this model. This is part of problem in Tsay's book: "Analysis of Financial Time Series" (Chapter:4/Exercise:6)(if you want to know exactly what it is. I can email it too)
----------------------------------------------
4.6. Because of the existence of inverted yield curves in the term structure of
interest rates, the spread of interest rates should be nonlinear. To verify this,
consider the weekly U.S. interest rates of (a) Treasury 1-year constant maturity
rate and (b) Treasury 3-year constant maturity rate. As in Chapter 2, denote
the two interest rates by r 1t and r 3t , respectively, and the data span is from
January 5, 1962, to April 10, 2009. The data are in ﬁles w-gs3yr.txt and
w-gs1yr.txt on the Web and can be obtained from the Federal Reserve
Bank of St. Louis.
(a) Let st = r 3t − r 1t be the spread in log interest rates. Is { st } linear? Perform
some nonlinearity tests and draw the conclusion using the 5% signiﬁcance
level.
(b) Let s∗t = (r 3t − r 3,t − 1 ) − (r 1t − r 1,t − 1 ) = st − st − 1 be the change in inter-
est rate spread. Is { s∗t } linear? Perform some nonlinearity tests and draw
the conclusion using the 5% signiﬁcance level.
(c) Build a threshold model for the st series and check the ﬁtted model.
(d) Build a threshold model for the s∗t series and check the ﬁtted model.
--------------------------------------------

then I found package: "apt", but it didn't have such a function that I want.
Please help me,
Thank you so much,
Best regards,
Elham
	[[alternative HTML version deleted]]

