【问题标题】:Is mean of rolling window R2 is the total R2 of regression?滚动窗口 R2 的平均值是回归的总 R2 吗?
【发布时间】:2021-04-30 11:51:03
【问题描述】:

在这里快速提问。

我必须计算 60 天滚动窗口 R2 时间序列的平均值。我的时间序列有 4680 个观测值。

我想知道,R2 系列的平均值是回归的总 R2 吗?

例子:

Mean(series of r2) = 所有样本数据回归的 R2

【问题讨论】:

    标签: python r statistics regression data-science


    【解决方案1】:

    试试吧。我们展示了在这种情况下定义 R 平方的两种等效方法:

    library(zoo)
    set.seed(123)
    n <- 4680
    w <- 60
    x <- rnorm(4680)
    
    r2 <- function(x) summary(lm(x ~ seq_along(x)))$r.squared
    # r2 <- function(x) cor(x, seq_along(x))^2  # this is equivalent
    
    mean(rollapplyr(x, w, r2))
    ## [1] 0.4992133
    
    r2(x)
    ## [1] 0.0001151601
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-12
      • 2018-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-11
      • 2018-05-23
      • 2019-09-24
      相关资源
      最近更新 更多