regression - 滚动回归和多重共线性
问题描述
艾迪特!!数据结构是
> str(ALLX)
'data.frame': 240 obs. of 21 variables:
$ Date : Factor w/ 240 levels "1998-01-01","1998-02-01",..: 1 2 3 4 5 6 7 8 9 10 ...
$ IM : num 0.00289 0.00992 -0.00424 0.07958 -0.035 ...
$ rmrf_local: num -0.1418 -0.0546 -0.0946 0.0304 -0.1025 ...
$ SMB_L : num -0.0465 -0.0698 0.0274 -0.0741 0.0317 ...
$ HML_L : num -0.1266 -0.191 -0.1408 -0.0122 -0.064 ...
$ MOM_L : num 0.0518 0.0127 0.0448 0.0163 0.0151 ...
$ bond_L : num -0.116 -0.128 -0.126 -0.117 -0.123 ...
按照下面的代码,我可以估计一个滚动的 gmm 函数。
> gmm_list_IM <- lapply(1:(length(ALLX$IM)-24), function(i) {
+ tmp <- ALLX[i:(i+23),]
+ IM <- as.matrix(as.numeric(tmp$IM))
+ p <- nrow(IM)
+ rmrf_local <- as.matrix(as.numeric(tmp$rmrf_local))
+ SMB_L <- as.matrix(as.numeric(tmp$SMB_L))
+ HML_L <- as.matrix(as.numeric(tmp$HML_L))
+ MOM_L <- as.matrix(as.numeric(tmp$MOM_L))
+ bond_L <- as.matrix(as.numeric(tmp$bond_L))
+ h <- cbind(rmrf_local,SMB_L,HML_L,MOM_L,bond_L)
+ gmm(IM ~ rmrf_local+SMB_L+HML_L+MOM_L+bond_L, x=h)
+ })
需要计算 VIF 以检测具有以下误差的多重共线性。
> vif(gmm_list_IM)
Error in vcov.default(mod) :
there is no vcov() method for models of class list
In addition: Warning message:
In is.na(coef(mod)) :
is.na() applied to non-(list or vector) of type 'NULL'
在滚动回归下,VIF(方差膨胀因子)的代码不起作用,我无法测试多重共线性。有人可以对如何有另一种想法吗?
解决方案
推荐阅读
- algorithm - Root 方法在 Quick-Union 中如何工作?
- github - 我忘了'git push'
- arrays - 满 BUFFER 容量的循环队列
- c# - 显示 RabbitMQ 消息而不使用它们
- pgadmin-4 - 在mac上首次安装PG Admin 4错误
- python - Bert 使用 Transformer 的管道和 encode_plus 函数
- python - GroupBy 一个数据框记录并使用 PySpark 显示所有列
- amazon-web-services - 通过乘以 s3 Bucket 触发的 aws sqs 的策略是什么
- c++ - 在 Windows 上使用 C++ 访问最大输入延迟
- javascript - 单击后如何将链接添加到谷歌饼图切片并将该变量发送到新页面