---
title: "ConfZIC: An R package based on Confidence Envelope for minimum ZIC"
author: "I.M.L. Nadeesha Jayaweera, A. Alex Trindade"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{ConfZIC: An R package based on Confidence Envelope for minimum ZIC}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```
## Overview

Package ConfZIC provides methods to narrow down the number of models to look at in model selection based on Generalized Information Criteria for regression and time-series data.


## Installation

Installation can be done for "ConfZIC" R package in three ways.

From the Comprehensive R Archive Network (CRAN): Use install.packages() function in R. Then, import ConfZIC package into working session using library() function. That is,

```{r}

library(ConfZIC)
```

## Usage
The primary functions in this package are \textbf{RankReg} and \textbf{RankTS}. these functions help us to narrow down the number of models to look at in model selection, uses the minimum ZIC (Generalized Information Criteria) 

More Details: Jayaweera I.M.L.N, Trindade A.A., ``How Certain are You in Your Minimum AIC and BIC Values?", Sankhya A (2023+)

## Regression Data

Rank the regression models which lie in the given confidence envelope:

```{r}
library("ConfZIC")
data(Concrete)
x=Concrete
Y=x[,9] #dependent variable
#independent variables
X1=x[,1];X2=x[,2];X3=x[,3];X4=x[,4];
X5=x[,5];X6=x[,6];X7=x[,7];X8=x[,8];
mydata=cbind(Y,X1,X2,X3,X4,X5,X6,X7,X8) #data matrix
RankReg(mydata,0.95,"BIC")
```

Testing two ZIC values in Regression 

```{r}
x=Concrete
Y=x[,9] #dependent variable
model1=lm(Y~X1)
model2=lm(Y~X1+X2)
regZIC.test(model1,model2,model_ZIC="BIC",data=mydata,alpha=0.05)


```

## Time series Data

Rank the time series models which lie in the given confidence envelope based on minimum ZIC:

```{r}
library("ConfZIC")
data(Sunspots)
x=Sunspots
RankTS(x,max.p=13,max.q=13,0.95,"AICc")

```
Testing two ZIC values:

```{r}
model1=try(arima(x,order=c(1,0,1),method="ML",include.mean=FALSE),silent = TRUE)
model2=try(arima(x,order=c(1,0,0),method="ML",include.mean=FALSE),silent = TRUE)
tsZIC.test(x,model1,model2,model_ZIC="AIC",alpha=0.05)
```

