【发布时间】:2017-11-12 11:44:22
【问题描述】:
我有两个名为 lagcolmean 和 Dropcolmax 的数据框,其中行名是公司,列名是每月日期。
00-02 00-03 00-04
TENAGA NASIONAL 0.39 0.07 -0.08
SIME DARBY -0.09 -0.12 -0.53
DIGI.COM 0.79 0.96 -1.14
GENTING -0.11 -0.27 -0.16
PETRONAS GAS -0.30 -0.09 -0.98
and
00-01 00-02 00-03
TENAGA NASIONAL 5.61 3.95 4.12
SIME DARBY 10.87 1.97 6.78
DIGI.COM 21.21 9.61 25.40
GENTING 11.55 2.87 4.34
PETRONAS GAS 1.79 1.27 4.75
当我想运行横截面回归来找到每个时期的斜率系数时,我会使用这些公式
library(broom)
fit4 <- lapply(names(Dropcolmax), function(x){
dd = tidy(lm(lagcolmean[[x]] ~ Dropcolmax[[x]]))
data.frame(name = x, dd)})
但它会产生以下错误消息:model.frame.default(formula = lagcolmean[[x]] ~ Dropcolmax[[x]], 中的错误: 变量“lagcolmean[[x]]”的类型无效(NULL)
【问题讨论】:
标签: r