# Select a carx model by the AIC

### Description

This function selects the `carx`

model which minimizes the AIC among a set of `carx`

models
defined by a set of formulas or a list of regression formulas with a maximal AR order.
The model specification is supplied by `formulas`

which can be either a formula or a list of formulas.
For each formula, the function will estimate the `carx`

models with the AR order
from 1 to `max.ar`

inclusive.
If `detect.outlier=TRUE`

, outlier detection will be performed for each combination of model
formula and AR order.
The function returns a `list`

which consists of: 1) `aicMat`

which is a matrix of AIC
values where
each row contains the AICs of the model given by a specific regression formula with the AR order
ranging from 1 to `mar.ar`

(after incorporation of any found outlier if outlier detection if enabled), and
2) `fitted`

which is the fitted object of the selected model.

### Usage

1 | ```
carxSelect(formulas, max.ar, data = list(), detect.outlier = F, ...)
``` |

### Arguments

`formulas` |
a regression formula or a list of regression formulas. |

`max.ar` |
the maximal AR order. |

`data` |
a |

`detect.outlier` |
logical to specify whether outlier detection is performed (and incorporating in
the |

`...` |
other arguments to be supplied, if not null, it will be called with the selected model and data.
Examples include |

### Value

a list consisting of:

`fitted`

the fitted CARX object of the model with the smallest AIC.`aicMat`

the matrix of AIC where rows correspond to the model formulas and columns correspond to the AR orders.

### Examples

1 2 3 4 5 6 7 8 9 | ```
dataSim <- carxSimCenTS(nObs=100)
fmls <- list(M1=y~X1,M2=y~X1+X2,M3=y~X1+X2-1)
## Not run: cs = carxSelect(y~X1,max.ar=3,data=dataSim)
## Not run: cs = carxSelect(formulas=fmls,max.ar=3,data=dataSim)
## Not run:
#To compute confidence intervals for the selected model, call with CI.compute=TRUE.
cs = carxSelect(formulas=fmls,max.ar=3,data=dataSim,CI.compute=TRUE)
## End(Not run)
``` |

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker. Vote for new features on Trello.