3 amended some code. replaced "sun$sunspot" with "sunspots".
source | link

Answer: One possible solution, although no claim to be the best, is as follows; it's a hack that I've come up with after looking at some source code.

npar <- length(model$coef) + 1
nstar <- length(model$residuals) - model$arma[6] - model$arma[7] * model$arma[5]

bic <- model$aic + npar * (log(nstar) - 2)
aicc <- model$aic + 2 * npar * (nstar/(nstar - npar - 1) - 1)

Now that the bic and aicc have been stored as objects - using, solely, output from the arima() function - we can now set them as attributes to the model object.

# Give model attributes for bic and aicc
attr(model,"bic") <- bic
attr(model,"aicc") <- aicc

> attributes(model)
$names
 [1] "coef"      "sigma2"    "var.coef"  "mask"      "loglik"   
 [6] "aic"       "arma"      "residuals" "call"      "series"   
[11] "code"      "n.cond"    "model"    

$class
[1] "Arima"

$bic
[1] 23599.05

$aicc
[1] 23563.42

Pass on these attributes to a new object (we don't want to overwrite model).

# Create new object with these attributes
model_2 <- attributes(model)

We can now access the BIC and AICc in a similar manner as to how we accessed the AIC value. The following code should make this clear:

> model$aic
[1] 23563.39
> model_2$bic
[1] 23599.05
> model_2$aicc
[1] 23563.42

Edit: Based on the very useful information provided by @Stat about the AIC() function, the following code may be useful as alternative ways of getting the AIC, BIC, AICc, and HQC. Attach them as attributes to the model object and work away.

# AIC
AIC(arima(x=sun$sunspot, order=c(2,0,2), method="ML"))
# BIC
AIC(arima(x=sun$sunspotx=sunspots, order=c(2,0,2), method="ML"))
# BIC
AIC(arima(x=sunspots, order=c(2,0,2), method="ML"),k=log(length(sun$sunspot)))
# AICc    
AIC(arima(x=sun$sunspotsunspots)))
# AICc    
AIC(arima(x=sunspots, order=c(2,0,2), method="ML")) + 2 * npar * (nstar/(nstar - npar - 1) - 1)
# HQC
AIC(arima(x=sun$sunspot, order=c(2,0,2), method="ML"), k=2*log(log(length(sun$sunspotx=sunspots, order=c(2,0,2), method="ML"), k=2*log(log(length(sunspots))))

Answer: One possible solution, although no claim to be the best, is as follows; it's a hack that I've come up with after looking at some source code.

npar <- length(model$coef) + 1
nstar <- length(model$residuals) - model$arma[6] - model$arma[7] * model$arma[5]

bic <- model$aic + npar * (log(nstar) - 2)
aicc <- model$aic + 2 * npar * (nstar/(nstar - npar - 1) - 1)

Now that the bic and aicc have been stored as objects - using, solely, output from the arima() function - we can now set them as attributes to the model object.

# Give model attributes for bic and aicc
attr(model,"bic") <- bic
attr(model,"aicc") <- aicc

> attributes(model)
$names
 [1] "coef"      "sigma2"    "var.coef"  "mask"      "loglik"   
 [6] "aic"       "arma"      "residuals" "call"      "series"   
[11] "code"      "n.cond"    "model"    

$class
[1] "Arima"

$bic
[1] 23599.05

$aicc
[1] 23563.42

Pass on these attributes to a new object (we don't want to overwrite model).

# Create new object with these attributes
model_2 <- attributes(model)

We can now access the BIC and AICc in a similar manner as to how we accessed the AIC value. The following code should make this clear:

> model$aic
[1] 23563.39
> model_2$bic
[1] 23599.05
> model_2$aicc
[1] 23563.42

Edit: Based on the very useful information provided by @Stat about the AIC() function, the following code may be useful as alternative ways of getting the AIC, BIC, AICc, and HQC. Attach them as attributes to the model object and work away.

# AIC
AIC(arima(x=sun$sunspot, order=c(2,0,2), method="ML"))
# BIC
AIC(arima(x=sun$sunspot, order=c(2,0,2), method="ML"),k=log(length(sun$sunspot)))
# AICc    
AIC(arima(x=sun$sunspot, order=c(2,0,2), method="ML")) + 2 * npar * (nstar/(nstar - npar - 1) - 1)
# HQC
AIC(arima(x=sun$sunspot, order=c(2,0,2), method="ML"), k=2*log(log(length(sun$sunspot))))

Answer: One possible solution, although no claim to be the best, is as follows; it's a hack that I've come up with after looking at some source code.

npar <- length(model$coef) + 1
nstar <- length(model$residuals) - model$arma[6] - model$arma[7] * model$arma[5]

bic <- model$aic + npar * (log(nstar) - 2)
aicc <- model$aic + 2 * npar * (nstar/(nstar - npar - 1) - 1)

Now that the bic and aicc have been stored as objects - using, solely, output from the arima() function - we can now set them as attributes to the model object.

# Give model attributes for bic and aicc
attr(model,"bic") <- bic
attr(model,"aicc") <- aicc

> attributes(model)
$names
 [1] "coef"      "sigma2"    "var.coef"  "mask"      "loglik"   
 [6] "aic"       "arma"      "residuals" "call"      "series"   
[11] "code"      "n.cond"    "model"    

$class
[1] "Arima"

$bic
[1] 23599.05

$aicc
[1] 23563.42

Pass on these attributes to a new object (we don't want to overwrite model).

# Create new object with these attributes
model_2 <- attributes(model)

We can now access the BIC and AICc in a similar manner as to how we accessed the AIC value. The following code should make this clear:

> model$aic
[1] 23563.39
> model_2$bic
[1] 23599.05
> model_2$aicc
[1] 23563.42

Edit: Based on the very useful information provided by @Stat about the AIC() function, the following code may be useful as alternative ways of getting the AIC, BIC, AICc, and HQC. Attach them as attributes to the model object and work away.

# AIC
AIC(arima(x=sunspots, order=c(2,0,2), method="ML"))
# BIC
AIC(arima(x=sunspots, order=c(2,0,2), method="ML"),k=log(length(sunspots)))
# AICc    
AIC(arima(x=sunspots, order=c(2,0,2), method="ML")) + 2 * npar * (nstar/(nstar - npar - 1) - 1)
# HQC
AIC(arima(x=sunspots, order=c(2,0,2), method="ML"), k=2*log(log(length(sunspots))))
2 Added some more useful code
source | link

Answer: One possible solution, although no claim to be the best, is as follows; it's a hack that I've come up with after looking at some source code.

npar <- length(model$coef) + 1
nstar <- length(model$residuals) - model$arma[6] - model$arma[7] * model$arma[5]

bic <- model$aic + npar * (log(nstar) - 2)
aicc <- model$aic + 2 * npar * (nstar/(nstar - npar - 1) - 1)

Now that the bic and aicc have been stored as objects - using, solely, output from the arima() function - we can now set them as attributes to the model object.

# Give model attributes for bic and aicc
attr(model,"bic") <- bic
attr(model,"aicc") <- aicc

> attributes(model)
$names
 [1] "coef"      "sigma2"    "var.coef"  "mask"      "loglik"   
 [6] "aic"       "arma"      "residuals" "call"      "series"   
[11] "code"      "n.cond"    "model"    

$class
[1] "Arima"

$bic
[1] 23599.05

$aicc
[1] 23563.42

Pass on these attributes to a new object (we don't want to overwrite model).

# Create new object with these attributes
model_2 <- attributes(model)

We can now access the BIC and AICc in a similar manner as to how we accessed the AIC value. The following code should make this clear:

> model$aic
[1] 23563.39
> model_2$bic
[1] 23599.05
> model_2$aicc
[1] 23563.42

Edit: Based on the very useful information provided by @Stat about the AIC() function, the following code may be useful as alternative ways of getting the AIC, BIC, AICc, and HQC. Attach them as attributes to the model object and work away.

# AIC
AIC(arima(x=sun$sunspot, order=c(2,0,2), method="ML"))
# BIC
AIC(arima(x=sun$sunspot, order=c(2,0,2), method="ML"),k=log(length(sun$sunspot)))
# AICc    
AIC(arima(x=sun$sunspot, order=c(2,0,2), method="ML")) + 2 * npar * (nstar/(nstar - npar - 1) - 1)
# HQC
AIC(arima(x=sun$sunspot, order=c(2,0,2), method="ML"), k=2*log(log(length(sun$sunspot))))

Answer: One possible solution, although no claim to be the best, is as follows; it's a hack that I've come up with after looking at some source code.

npar <- length(model$coef) + 1
nstar <- length(model$residuals) - model$arma[6] - model$arma[7] * model$arma[5]

bic <- model$aic + npar * (log(nstar) - 2)
aicc <- model$aic + 2 * npar * (nstar/(nstar - npar - 1) - 1)

Now that the bic and aicc have been stored as objects - using, solely, output from the arima() function - we can now set them as attributes to the model object.

# Give model attributes for bic and aicc
attr(model,"bic") <- bic
attr(model,"aicc") <- aicc

> attributes(model)
$names
 [1] "coef"      "sigma2"    "var.coef"  "mask"      "loglik"   
 [6] "aic"       "arma"      "residuals" "call"      "series"   
[11] "code"      "n.cond"    "model"    

$class
[1] "Arima"

$bic
[1] 23599.05

$aicc
[1] 23563.42

Pass on these attributes to a new object (we don't want to overwrite model).

# Create new object with these attributes
model_2 <- attributes(model)

We can now access the BIC and AICc in a similar manner as to how we accessed the AIC value. The following code should make this clear:

> model$aic
[1] 23563.39
> model_2$bic
[1] 23599.05
> model_2$aicc
[1] 23563.42

Answer: One possible solution, although no claim to be the best, is as follows; it's a hack that I've come up with after looking at some source code.

npar <- length(model$coef) + 1
nstar <- length(model$residuals) - model$arma[6] - model$arma[7] * model$arma[5]

bic <- model$aic + npar * (log(nstar) - 2)
aicc <- model$aic + 2 * npar * (nstar/(nstar - npar - 1) - 1)

Now that the bic and aicc have been stored as objects - using, solely, output from the arima() function - we can now set them as attributes to the model object.

# Give model attributes for bic and aicc
attr(model,"bic") <- bic
attr(model,"aicc") <- aicc

> attributes(model)
$names
 [1] "coef"      "sigma2"    "var.coef"  "mask"      "loglik"   
 [6] "aic"       "arma"      "residuals" "call"      "series"   
[11] "code"      "n.cond"    "model"    

$class
[1] "Arima"

$bic
[1] 23599.05

$aicc
[1] 23563.42

Pass on these attributes to a new object (we don't want to overwrite model).

# Create new object with these attributes
model_2 <- attributes(model)

We can now access the BIC and AICc in a similar manner as to how we accessed the AIC value. The following code should make this clear:

> model$aic
[1] 23563.39
> model_2$bic
[1] 23599.05
> model_2$aicc
[1] 23563.42

Edit: Based on the very useful information provided by @Stat about the AIC() function, the following code may be useful as alternative ways of getting the AIC, BIC, AICc, and HQC. Attach them as attributes to the model object and work away.

# AIC
AIC(arima(x=sun$sunspot, order=c(2,0,2), method="ML"))
# BIC
AIC(arima(x=sun$sunspot, order=c(2,0,2), method="ML"),k=log(length(sun$sunspot)))
# AICc    
AIC(arima(x=sun$sunspot, order=c(2,0,2), method="ML")) + 2 * npar * (nstar/(nstar - npar - 1) - 1)
# HQC
AIC(arima(x=sun$sunspot, order=c(2,0,2), method="ML"), k=2*log(log(length(sun$sunspot))))
1
source | link

Answer: One possible solution, although no claim to be the best, is as follows; it's a hack that I've come up with after looking at some source code.

npar <- length(model$coef) + 1
nstar <- length(model$residuals) - model$arma[6] - model$arma[7] * model$arma[5]

bic <- model$aic + npar * (log(nstar) - 2)
aicc <- model$aic + 2 * npar * (nstar/(nstar - npar - 1) - 1)

Now that the bic and aicc have been stored as objects - using, solely, output from the arima() function - we can now set them as attributes to the model object.

# Give model attributes for bic and aicc
attr(model,"bic") <- bic
attr(model,"aicc") <- aicc

> attributes(model)
$names
 [1] "coef"      "sigma2"    "var.coef"  "mask"      "loglik"   
 [6] "aic"       "arma"      "residuals" "call"      "series"   
[11] "code"      "n.cond"    "model"    

$class
[1] "Arima"

$bic
[1] 23599.05

$aicc
[1] 23563.42

Pass on these attributes to a new object (we don't want to overwrite model).

# Create new object with these attributes
model_2 <- attributes(model)

We can now access the BIC and AICc in a similar manner as to how we accessed the AIC value. The following code should make this clear:

> model$aic
[1] 23563.39
> model_2$bic
[1] 23599.05
> model_2$aicc
[1] 23563.42