VAR模型:R中的残留序列相关LM测试

如何解决VAR模型:R中的残留序列相关LM测试

我使用库 vars EViews 中然后在 R 中估计了VAR(具有2个滞后的4个变量):

mydata = data.frame(lgdp_gap = c(-0.002381761,-0.001469301,0.005679518,-0.004247939,-0.00231733,0.001857604,0.005075244,0.013618147,0.012049921,0.009615604,0.004972005,0.003765369,-0.00421267,0.008044466,0.000496629,0.012933087,0.002640515,-0.004286223,-0.001388365,0.003226258,-0.002323845,-0.013232112,-0.008539877,-0.005323075,0.005552265,0.004044421,0.012767601,-0.008186491,0.002275548,-0.002653862,-0.000690633,-0.001971521,0.002136573,0.004801953,0.000161,0.000502721,-0.005919601,-0.01306008,-0.007110793,-0.000471637,0.000755801,-0.006065214,-0.008792199,-0.009440825,-0.009171589,-0.010664884,-0.002541211,-0.00120617,-0.007827149,-0.011067886,-0.004393774,0.002575367,0.00968696,0.008187377,0.005453557,0.007601658,0.014670556,0.024576903,0.039962649,0.024783215,0.008140833,-0.021881732,-0.032456836,-0.025612942,-0.018497523,0.00301631,0.006110211,0.00836062,0.005633709,0.019668996,0.027426755,0.01604911,0.010212142,0.011884327,0.001278069,-0.006292959),infl = c(1.5,1.6,1.8,2.8,3.9,4.5,5.1,4.9,3.8,3.1,2.1,1.7,1.2,0.3,-0.3,-0.1,0.7,1.3,1.5,1,6.1,5.8,6,2.5,3,3.3,3.4,2.6,2.4,1.9,2.3,2.7,4,2,4.3,4.6,5,3.7,1.4,2.9,2.2),mpr = c(4.75,4.75,5.5,7.5,7,6.25,4.25,5.25,5.75,6.5,6.75,7.25,3.25,3.75,3.5,3),rer_gap = c(-1.193267933,-0.982377607,-1.16507208,0.166872782,-2.277590718,-9.589614572,-4.358927276,-1.66926382,0.498365138,5.463992228,5.347338604,6.964710424,8.129071757,6.949033732,4.628126805,4.965538287,9.057562911,3.197391946,0.072555687,-2.631413944,-0.029030369,5.066837621,4.643339379,2.284457488,2.171272439,-2.916563059,-3.300753344,-8.101179903,-6.83566125,-7.916952663,-8.553537131,-8.448949549,-6.00137885,-3.603733372,-7.945170595,-6.912595663,-4.287947989,0.851153387,2.52976939,7.272428978,12.00208,3.937125037,1.488465373,4.664541585,5.372863962,4.318027453,4.001268967,1.821126647,-1.026362158,-2.446298302,-1.743141166,-1.71982119,-0.978179354,3.781018252,4.357616899,6.849098722,5.550222345,8.951465706,2.939837855,-26.10324683,-25.89821136,-13.44916422,-5.744027517,2.237682369,2.12003908,-0.874282294,-1.423931689,5.592987384,6.499261376,11.01418112,6.552975397,3.523989148,9.33147169,3.377469848,8.15819828,6.167760723))
    
library(vars)
series = ts(mydata,start = c(1994,1),frequency = 4)
aus_var = vars::VAR(series,p = 2,type = "const")

我想在 R 测试中从 EViews 复制串行相关性(屏幕截图上最多延迟8个):

enter image description here

vars 库中有 serial.test 函数,其中有多个选项。但是,首先,据我所知,它仅计算直至h 的测试统计信息。其次,对于Portmanteau统计信息,第一次滞后为 NaN ,第二次滞后为零。第三,统计信息与 EViews 中的统计信息不一样。

lags = 8
pt.asympt = rep(0,lags)
pt.adj = rep(0,lags)
bg = rep(0,lags)
es = rep(0,lags)

for (i in 1:lags) {
  pt.asympt[i] = serial.test(aus_var,lags.pt = i,type = "PT.asymptotic")$serial$p.value
  pt.adj[i] = serial.test(aus_var,type = "PT.adjusted")$serial$p.value
  bg[i] = serial.test(aus_var,lags.bg = i,type = "BG")$serial$p.value
  es[i] = serial.test(aus_var,type = "ES")$serial$p.value
}

data.frame(pt.asymptotic = pt.asympt,pt.adjusted = pt.adj,BG = bg,ES = es)

  pt.asymptotic pt.adjusted          BG          ES
1           NaN         NaN 0.083314280 0.159025580
2    0.00000000  0.00000000 0.138813143 0.306500237
3    0.09510772  0.07944269 0.003196113 0.010428448
4    0.12728542  0.09344425 0.004318649 0.008500867
5    0.21895439  0.15218608 0.004489465 0.010337834
6    0.44895391  0.33098567 0.008988688 0.009493331
7    0.67479803  0.53307474 0.010123216 0.017716077
8    0.80533752  0.66137826 0.034200469 0.074598073

尽管我了解它不能完全匹配 EViews 中的统计信息,因为 EViews 中的估算系数略有不同:

enter image description here

R

Bcoef(aus_var)
          lgdp_gap.l1       infl.l1       mpr.l1    rer_gap.l1 lgdp_gap.l2
lgdp_gap    0.6275981  0.0005702115  0.002759424  0.0002051417  -0.1079489
infl       -8.6267873  0.8956820060  0.792584922 -0.0376095335   1.4939984
mpr        -0.1193365  0.0153054356  1.221406077 -0.0109692777 -13.4334698
rer_gap  -109.6728810 -1.2116055972 -0.464282280  0.9191737000  35.6408681
              infl.l2       mpr.l2    rer_gap.l2        const
lgdp_gap  0.001343102 -0.001841198  0.0004001956 -0.009601307
infl     -0.128581108 -0.740624425  0.0290570535  0.393845308
mpr      -0.138700889 -0.231426372 -0.0104303177  0.396731869
rer_gap   0.503573295  0.558785715 -0.2446383887  1.727912585

所以,我的问题是:如何在R测试中实现EViews中的残差。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 <select id="xxx"> SELECT di.id, di.name, di.work_type, di.updated... <where> <if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 <property name="dynamic.classpath" value="tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-