【发布时间】:2016-12-21 05:39:19
【问题描述】:
我有一个TimeArray 类型的数据集,我想执行线性回归。但是,julia 目前似乎不支持TimeArray 类型的回归方法。
我可以将数据下载为DataFrame 而不是TimeArray 并使用GLM 包,但TimeArray 时间戳对于以后的其他分析非常有用。我想直接对TimeArray 数据集执行线性回归。
编辑1:下面给出一个简单的例子:
julia> using TimeSeries
dates = collect(Date(1999,1,1):Date(1999,1,31))
# Dependent variable
y = TimeArray(dates, rand(length(dates)))
# Explanatory variables
x1 = TimeArray(dates, rand(length(dates))) # Explanatory variable 1
x2 = TimeArray(dates, rand(length(dates))) # Explanatory variable 2
x = rename(merge(x1,x2), ["x1", "x2"]) # Merge x1 and x2 into a single TimeArray
# Linear regression
coefs = linreg(x, y) # Yields a method error since linreg does not support the TimeArray type.
有没有人找到解决此问题的解决方案或解决方法?
【问题讨论】:
-
只是我的 2 美分:如果您发布一个包含数据的最小示例以及您所设想的/您尝试过的代码不起作用,那么您更有可能得到可能想要修补的人并弄清楚。就像现在一样,有人将这个问题作为一般性问题来回答的唯一方法是,如果某人在最近的过去遇到并解决了确切相同的问题,这种可能性要小得多.
-
另外,为什么你不能在 DataFrame 版本上进行分析,并简单地保存时间戳以供以后分析?
-
有关实施 Tasos 建议的更多详细信息,请参见此处:stackoverflow.com/help/mcve
-
线性回归只使用值,而不是时间戳,对吧?
-
我不确定这是否不是您想要的,但
coefs = linreg(x.values,y.values)似乎对我有用
标签: statistics time-series regression julia linear-regression