我创建了一个函数,它是statsmodels包的统计回归函数的包装器。 我可以将一个因变量和一个自变量无误地传递给参数。当我试图传递多个列(自变量)时,就会出现问题,例如exog=['indvar1','indvar2'] 我已尝试将数据框列转换为列表
pred = df.columns.tolist()
pred = df.columns.values.tolist()
但我还是犯了同样的错误
The error is : KeyError: "None of [Index([('TARP', 'Lehman', 'Recovery_Act', 'T10Y2Y', 'DFF')], dtype='object')] are in the [columns]"
此功能:
Bob1 = sect_arma1.cv(model_data,endog ='Technology',exog = pred)
根据错误描述,此行出现内部故障:
280 --> exog = X[[exog]][1:Train_size]
注意,endog参数不会失败,因为一个引用的变量起作用,例如“Technology”
使用下面描述的适合您需要的任何方法。对于下面的所有示例,我将使用此解决方案结尾处生成的虚拟数据
输出:
输出:
输出:
虚拟数据
让我们先做一些虚拟数据来解释一些事情
输出:
相关问题 更多 >
编程相关推荐