指数时间序列回归不收敛

问题描述

我正在尝试估计时间序列数据的指数回归模型。这个想法是通过使用流动性减少和测试数量作为预测指标来解释每天确诊的 COVID-19 病例数。我们想看看流动性的变化(从基线减少的百分比)是否能够解释病例的指数增长。

我们最初拟合了一个简单的回归模型,当然,该模型几乎违反了所有假设。残差不是正态分布的,自相关持续存在,残差是异方差的。但是,当我尝试运行指数回归时,我收到了我不太明白的错误消息。有谁知道会发生什么?也许,您对如何处理这个问题有什么建议吗?

非常感谢您的帮助!

library(forecast)
library(lubridate)
library(tidyverse)

ds <- ds %>% 
  rowwise() %>% 
  mutate(avrg_mobility=mean(c(parks,retail,grocery,station,workplaces,residential))) 
## Due to multicollinearity problem,we average % reduction of mobility in varIoUs areas. 
## Contains negative values and negative values mean reduction from baseline.

ds <- ts(ds,start=decimal_date(as.Date("2020-02-15")),frequency = 365)
#> Warning in data.matrix(data): NAs introduced by coercion

autoplot(ds[,"daily_cases"]) +
  ylab("COVID-19 Daily Confirmed Cases") + xlab("Days")


autoplot(ds[,"testing"]) +
  ylab("Number of Tests Daily") + xlab("Days") 


autoplot(ds[,"avrg_mobility"]) +
  ylab("Average mobility") + xlab("Days")


reg <- tslm(daily_cases ~
              avrg_mobility + testing,data=ds) ## We're fitting the model using time series linear regression
summary(reg)
#> 
#> Call:
#> tslm(formula = daily_cases ~ avrg_mobility + testing,data = ds)
#> 
#> Residuals:
#>     Min      1Q  Median      3Q     Max 
#> -2390.0  -384.5    26.0   333.0  4744.5 
#> 
#> Coefficients:
#>                 Estimate Std. Error t value Pr(>|t|)    
#> (Intercept)   -1.108e+02  1.149e+02  -0.964    0.336    
#> avrg_mobility -2.343e+01  5.883e+00  -3.982 8.34e-05 ***
#> testing        1.631e-03  2.756e-05  59.177  < 2e-16 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Residual standard error: 889.7 on 343 degrees of freedom
#>   (6 observations deleted due to missingness)
#> Multiple R-squared:  0.9121,Adjusted R-squared:  0.9116 
#> F-statistic:  1779 on 2 and 343 DF,p-value: < 2.2e-16
checkresiduals(reg) ## residuals are positively skewed,there's significant autocorrelations

#> 
#>  Breusch-Godfrey test for serial correlation of order up to 70
#> 
#> data:  Residuals from Linear regression model
#> LM test = 303.02,df = 70,p-value < 2.2e-16

reg.exp <- tslm(daily_cases ~
                  avrg_mobility + testing,data=ds,lambda=0) ## We're fitting exponential regressions
#> Warning in log(x): NaNs produced
summary(reg.exp) ## But gets this error
#> Error in if (is.finite(resvar) && resvar < (mean(f)^2 + var(c(f))) * 1e-30) warning("essentially perfect fit: summary may be unreliable"): missing value where TRUE/FALSE needed

fcasts.exp <- forecast(reg.exp,h=3) ## Forecast doesn't work
#> Error in eval(predvars,data,env): object 'avrg_mobility' not found

reprex package (v1.0.0) 于 2021 年 2 月 3 日创建

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)