• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

拓端tecdat|R语言代写面板平滑转移回归(PSTR)分析

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

建模过程包括三个阶段:规范,估计和评估。该软件包提供的工具可帮助用户进行模型规范测试,进行PSTR模型评估以及进行模型评估。

在程序包中实现了集群依赖性和异方差性一致性测试。

还实现了wild bootstrap和cluster wild bootstrap测试。

并行计算(作为选项)在某些函数中实现,尤其是引导测试。因此,该程序包适合在超级计算服务器上运行多个核心的任务。

  

数据

 “Hansen99”的数据集来提供示例。 

初始化

您可以通过执行创建PSTR类的新对象

 
 
#> Summary of the model:
#> ---------------------------------------------------------------------------
#>   time horizon sample size = 14,  number of individuals = 560
#> ---------------------------------------------------------------------------
#> Dependent variable:  inva
#> ---------------------------------------------------------------------------
#> Explanatory variables in the linear part:
#>   dt_75 dt_76 dt_77 dt_78 dt_79 dt_80 dt_81 dt_82 dt_83 dt_84 dt_85 dt_86 dt_87 vala debta cfa sales
#> ---------------------------------------------------------------------------
#> Explanatory variables in the non-linear part:
#>   vala debta cfa sales
#> ---------------------------------------------------------------------------
#> Potential transition variable(s) to be tested:
#>   vala
#> ###########################################################################
#> ***************************************************************************
#> Results of the linearity (homogeneity) tests:
#> ***************************************************************************
#> Sequence of homogeneity tests for selecting number of switches 'm':
#> ***************************************************************************
#> ###########################################################################

它说使用了数据集“Hansen99”,因变量是“inva”,第4列到第20列的数据中的变量是线性部分的解释变量(尽管你可以写下它们的名称),非线性部分中的解释变量是“indep_k”中的四个,潜在的转换变量是“vala”(Tobin的Q)。

 

 

以下代码执行线性测试

 
#> ###########################################################################
#> ***************************************************************************
#> Results of the linearity (homogeneity) tests:
#> ---------------------------------------------------------------------------
#> LM tests based on transition variable 'vala'
#>   m  LM_X PV  LM_F PV HAC_X        PV HAC_F        PV
#>   1 125.3  0 28.99  0 30.03 4.819e-06 6.952 1.396e-05
#> ***************************************************************************
#> Sequence of homogeneity tests for selecting number of switches 'm':
#> ---------------------------------------------------------------------------
#> LM tests based on transition variable 'vala'
#>   m  LM_X PV  LM_F PV HAC_X        PV HAC_F        PV
#>   1 125.3  0 28.99  0 30.03 4.819e-06 6.952 1.396e-05
#> ***************************************************************************
#> ###########################################################################

您可以看到函数“LinTest”获取PSTR对象“pstr”并在返回时覆盖它。这是我推荐的方式,因为处理包中PSTR对象的函数通过添加新的atrributes或成员来更新对象。但是,相同的函数将更改它添加的属性的值。您当然可以创建新的PSTR对象来获取返回值,以便保存模型的不同设置的结果。

 可以通过运行以下代码来执行wild bootstrap和wild cluster bootstrap。 

 

估计

当您确定要用于估计的转换变量时,在本例中为“inva”,您可以估计PSTR模型

默认情况下,使用“optim”方法“L-BFGS-B”,但您可以通过执行更改方法进行估算

 
#> ###########################################################################
 #> ###########################################################################
#> ***************************************************************************
#> Results of the PSTR estimation:
#> ---------------------------------------------------------------------------
#> Transition variable 'vala' is used in the estimation.
#> ---------------------------------------------------------------------------
#> Parameter estimates in the linear part (first extreme regime) are
#>        dt_75_0   dt_76_0   dt_77_0   dt_78_0  dt_79_0  dt_80_0   dt_81_0
#> Est  -0.002827 -0.007512 -0.005812 0.0003951 0.002464 0.006085 0.0004164
#> s.e.  0.002431  0.002577  0.002649 0.0027950 0.002708 0.002910 0.0029220
#>        dt_82_0   dt_83_0    dt_84_0  dt_85_0   dt_86_0   dt_87_0  vala_0
#> Est  -0.007802 -0.014410 -0.0009146 0.003467 -0.001591 -0.008606 0.11500
#> s.e.  0.002609  0.002701  0.0030910 0.003232  0.003202  0.003133 0.04073
#>       debta_0   cfa_0  sales_0
#> Est  -0.03392 0.10980 0.002978
#> s.e.  0.03319 0.04458 0.008221
#> ---------------------------------------------------------------------------
#> Parameter estimates in the non-linear part are
#>        vala_1 debta_1    cfa_1  sales_1
#> Est  -0.10370 0.02892 -0.08801 0.005945
#> s.e.  0.03981 0.04891  0.05672 0.012140
#> ---------------------------------------------------------------------------
#> Parameter estimates in the second extreme regime are
#>      vala_{0+1} debta_{0+1} cfa_{0+1} sales_{0+1}
#> Est    0.011300    -0.00500   0.02183    0.008923
#> s.e.   0.001976     0.01739   0.01885    0.004957
#> ---------------------------------------------------------------------------
#> Non-linear parameter estimates are
#>       gamma        c_1
#> Est  0.6299 -0.0002008
#> s.e. 0.1032  0.7252000
#> ---------------------------------------------------------------------------
#> Estimated standard deviation of the residuals is 0.04301
#> ***************************************************************************
#> ###########################################################################

 

 还实现了线性面板回归模型的估计。 

 
#> ###########################################################################
#> ## PSTR 1.2.4 (Orange Panel)
#> ###########################################################################
#> ***************************************************************************
#> A linear panel regression with fixed effects is estimated.
#> ---------------------------------------------------------------------------
#> Parameter estimates are
#>          dt_75     dt_76     dt_77    dt_78    dt_79    dt_80    dt_81
#> Est  -0.007759 -0.008248 -0.004296 0.002356 0.004370 0.008246 0.004164
#> s.e.  0.002306  0.002544  0.002718 0.002820 0.002753 0.002959 0.002992
#>          dt_82     dt_83    dt_84    dt_85    dt_86     dt_87     vala
#> Est  -0.005294 -0.010040 0.006864 0.009740 0.007027 0.0004091 0.008334
#> s.e.  0.002664  0.002678 0.003092 0.003207 0.003069 0.0030080 0.001259
#>          debta     cfa    sales
#> Est  -0.016380 0.06506 0.007957
#> s.e.  0.005725 0.01079 0.002412
#> ---------------------------------------------------------------------------
#> Estimated standard deviation of the residuals is 0.04375
#> ***************************************************************************
#> ###########################################################################

绘制

估算PSTR模型后,您可以通过运行绘制估计的过渡函数

 

 

您还可以根据转换变量绘制系数曲线,标准误差和p值。

 

绘图功能plot_response,描述了其中我称为响应,一些解释性变量和过渡可变在PSTR模型。

 

 我们可以看到,如果没有非线性,对变量的响应是一条直线。如果变量和转换变量是不同的,我们可以绘制曲面,z轴为响应,x轴和y轴为两个变量。如果变量和转换变量相同,则变为曲线。qit

我们通过运行来制作图表

 

x轴上的数字看起来不太好,因为很难找到转折点的位置。

ggplot2软件包允许我们手动绘制数字(PSTR包与一些预先包装的软件包很好地协作),甚至是x轴上的标签(以及更多)。

 

现在我们非常清楚地看到,大约0.5的转折点将曲线切割成两种状态,并且两种状态的行为完全不同。该图表是关于托宾Q对预期投资的贡献滞后。低Q值公司(其潜力被金融市场评估为低)看起来不太愿意改变他们未来的投资计划,或者可能会改变。

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
R语言用法笔记誊写发布时间:2022-07-18
下一篇:
在R语言中无法设置CRAN镜像问题发布时间:2022-07-18
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap