Description Usage Arguments Details Value Author(s) Examples

Calculate a specified information criterion (IC) for an estimate or a group of estimates. The choices of IC include AIC, BIC, AICc, BICc, GCV and Mallows' Cp.

1 2 3 4 5 6 7 |

`y_hat` |
A vector of fitted values with |

`y` |
A vector of response variable, with |

`ic` |
A specified IC to calculate. Default is AICc ('aicc'). Other choices include AIC ('aic'), BIC ('bic'), BICc ('bicc'), GCV ('gcv') and Mallows' Cp ('cp'). |

`df` |
A number if y_hat is a vector, or a vector with |

`sigma` |
Standard deviation of the error term. It only needs to be specified if the argument |

This function enables the computation of various common IC for model fits, which can further be used to choose the optimal fit. This allows user comparing the effect of different IC. In order to calculate an IC, degrees of freedoms (df) needs to be specified. To be more specific, here are the formulas used to calculate each IC:

*AIC = log(RSS/n) + 2*df/n*

*BIC = log(RSS/n) + log(n)*df/n*

*AICc = log(RSS/n) + 2*(df+1)/(n-df-2)*

*BICc = log(RSS/n) + log(n)*(df+1)/(n-df-2)*

*GCV = RSS/(n-df)^2*

*AIC = RSS + 2*σ^2*df*

The value(s) of the specified IC for each fit.

Sen Tian

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
## Generate a trivial dataset, X has mean 0 and norm 1, y has mean 0
set.seed(11)
n = 20
p = 5
x = matrix(rnorm(n*p), nrow=n, ncol=p)
x = scale(x, center = colMeans(x))
x = scale(x, scale = sqrt(colSums(x^2)))
beta = c(1, 1, 0, 0, 0)
y = x%*%beta + scale(rnorm(20, sd=0.01), center = TRUE, scale = FALSE)
## Fit the model
boss_result = boss(x, y)
## Print the values of AICc-hdf for all subsets given by BOSS
print(boss_result$IC_boss$aicc)
## calculate them manually using the calc.ic function
y_hat = cbind(rep(1,n),x)%*%boss_result$beta_boss
print(calc.ic(y_hat, y, df=boss_result$hdf_boss))
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.