【问题标题】:Extract AIC from FitARMA in R从 R 中的 FitARMA 中提取 AIC
【发布时间】:2020-04-02 17:11:34
【问题描述】:

我将 FitARMA 包中的 FitARMA 函数应用到某个时间序列,我得到以下结果:

> model <- FitARMA(ts, c(1,0,1))
> model
ARIMA(1,0,1)
length of series = 1593 ,  number of parameters = 3
loglikelihood = 5113 ,  aic = -10220 ,  bic =  -10203.9

我想将 aic 提取到一个变量中。但是,模型详细信息 (screen with model details) 中没有 aic,软件包文档中也没有任何关于它的信息。

有没有可能像model_aic &lt;- model$aic那样做某事,因为我想为ARMA的不同p,q顺序做for循环,因此我想将aic提取到一个变量而不是手动从控制台输入它?

【问题讨论】:

    标签: r


    【解决方案1】:

    一种方法是创建一个计算 FitARMA 模型的 AIC 的函数

    library(FitARMA)
    model <- FitARMA(AirPassengers, c(1,0,1))
    model
    ARIMA(1,0,1)
    length of series = 144 ,  number of parameters = 3
    loglikelihood = -496.55 ,  aic = 999.1 ,  bic =  1008
    
    AICFitARMA <- function(model){
      k <- nrow(coef.FitARMA(model))
      AIC <- 2 * k - 2 * model$loglikelihood
      return(AIC)
    }
    
    AICFitARMA(model)
    [1] 999.0944
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-16
      • 2019-05-29
      • 2020-05-18
      • 2020-04-09
      • 1970-01-01
      • 2020-11-20
      • 2017-02-21
      • 2020-01-01
      相关资源
      最近更新 更多