【问题标题】:How to copy data displayed in summary of any analysis to a dataframe?如何将任何分析摘要中显示的数据复制到数据框中?
【发布时间】:2020-11-19 03:03:26
【问题描述】:

我正在尝试进行时间序列建模,并希望将我们从运行数据模型中获得的数据输入复制到数据帧中。例如,当我运行以下代码时:

a<-auto.arima(tt1[1:33,1])
summary(a)

我得到以下输出,我想将其复制到数据框以供将来分析 - 以查看不同模型中有多少实例有相似的值。

Series: tt1[1:33, 1] 
ARIMA(0,0,1) with non-zero mean 

Coefficients:
          ma1      mean
      -0.4421  219.4943
s.e.   0.2079   27.2563

sigma^2 estimated as 79580:  log likelihood=-232.1
AIC=470.19   AICc=471.02   BIC=474.68

Training set error measures:
                   ME     RMSE      MAE MPE MAPE      MASE       ACF1
Training set 3.103363 273.4178 233.6786 NaN  Inf 0.6599926 0.07472074

【问题讨论】:

  • 嗨@Akhilnandh Ramesh,欢迎来到SO!它已经作为列表存储在a 中。如果您执行str(a),您将看到可用于访问信息的各种列表。
  • sw_tidy() 在包sweep 中也可以用于将参数放入(整洁的)小标题中。

标签: r prediction forecasting arima


【解决方案1】:

您可以使用“broom”包来解决这个问题。 Check the package vignette for more information。这是一个可重现的示例:

library(broom)
library(forecast)
library(fpp2) # To get a data set to work on
# Fit a linear regression with AR errors
fit <- Arima(uschange[,"Consumption"], xreg = uschange[,"Income"], order = c(1,0,0))
# Use broom to convert summary output into a data.frame
tidy(fit) # coefficients and standard error
# Get main statistics
glance(fit)

【讨论】:

    猜你喜欢
    • 2011-10-23
    • 2011-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-10
    相关资源
    最近更新 更多