# R成精系列-R语言与门限自回归模型（TAR）

--百度百科

• pdR
• TSA
• tsDyn
• TAR
• BAYSTAR
• Hansen提供的函数

## pdR

pdR包中进行面板门限回归的主函数为

``````ptm(dep, ind1, ind2, d, bootn, trimn, qn, conf_lev, t, n)
``````

• `dep`:被解释变量,1列单变量，只能以；
• `d`:门限变量，1列单变量；
• `ind1`:受门限变量影响的解释变量，多列变量组；
• `ind2`不受门限变量影响的解释变量，多列变量组；
• `bootn`:Boostrap重复次数,门限数量通过bootn和trimn参数控制，如bootn=10、bootn=c(10,10)以及bootn=c(10,10,10)分别表示单门限、双门限和三门限模型；
• `trimn`:数据剪切比例；
• `qn`:待检验分位数个数；
• `conf_lev`:置信水平，比如0.95；
• `t`:时间跨度；
• `n`:横截面的个体数。

`dep``d``ind1``ind2`只能以矩阵形式存储，不能以向量形式存储，否者程序会报错。
`ptm()`函数的运行结果最终保存为list形式，list中元素的个数等于门限数量。

## TSA

TSA包中可以通过`tar`函数进行门限回归：

``````tar(y, p1, p2, d, is.constant1 = TRUE, is.constant2 = TRUE, transform = "no",
center = FALSE, standard = FALSE, estimate.thd = TRUE, threshold,
method = c("MAIC", "CLS")[1], a = 0.05, b = 0.95, order.select = TRUE, print = FALSE)
``````

`y`
time series
`p1`
AR order of the lower regime
`p2`
AR order of the upper regime
`d`
delay parameter
`is.constant1`
if True, intercept included in the lower regime, otherwise the intercept is fixed at zero
`is.constant2`
similar to is.constant1 but for the upper regime
`transform`
available transformations: "no" (i.e. use raw data), "log", "log10" and "sqrt"
`center`
if set to be True, data are centered before analysis
`standard`
if set to be True, data are standardized before analysis
`estimate.thd`
if True, threshold parameter is estimated, otherwise it is fixed at the value supplied by threshold
`threshold`
known threshold value, only needed to be supplied if estimate.thd is set to be False.
`method`
"MAIC": estimate the TAR model by minimizing the AIC; "CLS": estimate the TAR model by the method of Conditional Least Squares.
`a`
lower percent; the threshold is searched over the interval defined by the a100 percentile to the b100 percentile of the time-series variable
`b` :upper percent
`order.select`:If method is "MAIC", setting order.select to True will enable the function to further select the AR order in each regime by minimizing AIC
`print`: if True, the estimated model will be printed

## Hansen提供的函数

### 推荐阅读更多精彩内容

• rljs by sennchi Timeline of History Part One The Cognitiv...
sennchi阅读 4,843评论 0 10
• 闺女前日要交作文，写自己小时候最搞笑的事，班主任下令，写的一定要让她笑，闺女冥思苦想了半天，跑来问我，我也是愧疚的...
老麦2018阅读 173评论 4 3
• 北马路的灯还亮着吗 猫的天空之城记得吗 看不见的客人还在吗 压缩饼干法式面包进口奶油没有啦 红旗中路却依旧奔跑着的...
一秒山城阅读 26评论 0 0
• 重磅消息！近日，瑞麟集团海外项目方与新浪海外分期强强联合！为海外投资移民者提供一站式金融解决方案——丫丫邦。 随着...
欧汇文化阅读 70评论 0 0