# OMD: Objective Model Discrimination (OMD) in Follow-Up Experiments In OBsMD: Objective Bayesian Model Discrimination in Follow-Up Designs

## Description

Optimal follow-up experiments to discriminate between competing models. The extra-runs are derived from the maximization of the objective model discrimination criterion represented by a weighted average of Kullback-Leibler divergences between all possible pairs of rival models

## Usage

 `1` ```OMD(OBsProb, nFac, nBlk = 0, nMod, nFoll, Xcand, mIter, nStart, startDes, top = 20) ```

## Arguments

 `OBsProb` list. `OBsProb` class list. Output list of `OBsProb` function. `nFac` integer. Number of factors in the initial experiment. `nBlk` integer >=0. Number of blocking factors in the initial experiment. They are accommodated in the first columns of matrix `X`. `nMod` integer. Number of competing models considered to compute `OMD`. `nFoll` integer. Number of additional runs in the follow-up experiment. `Xcand` matrix. Matrix [`2^nFac x (nBlk + nFac)`] of candidate runs for the follow-up design. It generally rapresents the full `2^nFac` design. `mIter` integer >=0. Maximum number of iterations in the exchange algorithm. If `mIter = 0` exachange algorithm doesn't work. `nStart` integer. Number of different designs of dimension `nFoll` to be evaluated by `OMD` criterion. When exchange algorithm is used `nStart` represents the number of random starts to initialize the algorithm; otherwise `nStart = nrow(startDes)`. `startDes` matrix. Input matrix [`nStart x nFoll`] containing different `nStart` designs to be evaluated by `OMD` criterion. If the exchange algorithm is used `startDes = NULL`. `top` integer. Number of highest OMD follow-up designs recorded.

## Details

The OMD criterion, proposed by Consonni and Deldossi, is used to discriminate among competing models. Random starting runs chosen from `Xcand` are used for the Wynn search of best OMD follow-up designs. `nStart` starting points are tried in the search limited to `mIter` iterations. If `mIter=0` then `startDes` user-provided designs are used. Posterior probabilities and residual variances of the competing models are obtained from `OBsProb`. The function calls the FORTRAN subroutine ‘omd’ and captures summary results. The complete output of the FORTRAN code is save in the ‘MDPrint.out’ file in the working directory.

## Value

Below a list with all input and output parameters of the FORTRAN subroutine `OMD`. Most of the variable names kept to match FORTRAN code.

 `NSTART` integer. Number of different designs of dimension `nFoll` to be evaluated by `OMD` criterion. When exchange algorithm is used `nStart` represents the number of random starts to initialize the algorithm; otherwise `nStart = nrow(startDes)`. `NRUNS` integer. Number `nFoll` of runs used in follow-up designs. `ITMAX` integer. Maximum number `mIter` of iterations in the exchange algorithm. `INITDES` integer. Indicator variable. If `INITDES = 1` exachange alghoritm is used, otherwise `INITDES = 0` exachange alghoritm doesn't work. `N0` integer. Numbers of runs `nrow(X)` of the initial experiment before follow-up. `X` matrix. Matrix from initial experiment (`nrow(X)`; `ncol(X)=nBlk+nFac`). `Y` double. Response values from initial experiment (`length(Y)=nrow(X)`). `BL` integer >=0. The number of blocking factors in the initial experiment. They are accommodated in the first columns of matrix `X` and `Xcand`. `COLS` integer. Number of factors `nFac`. `N` integer. Number of candidate runs `nrow(Xcand)`. `Xcand` matrix. Matrix [`2^nFac x (nBlk + nFac)`] candidate runs for the follow-up design. It generally represents the full `2^nFac` design [`nrow(Xcand)=N`, `ncol(Xcand)=ncol(X)`]. `NM` integer. Number of competing models `nMod` considered to compute `OMD` . `P` double. Models posterior probability `optop`. It derives from the `OBsProb` output. `SIGMA2` double. Competing models residual variances `osigtop`. It derives from the `OBsProb` output. `NF` integer. Number of main factors in each competing models `onftop`. It derives from the `OBsProb` output. `MNF` integer. Maximum number of factor in models (`MNF=max(onftop)`). `JFAC` matrix. Matrix `ojtop` of dimension [`nMod x max(onftop)`] of the labels of the main factors present in each competing models. It derives from the `OBsProb` output. `CUT` integer. Maximum order of the interaction among factors in the models `mInt`. `MBEST` matrix. If `INITDES=0`, the first row of the `MBEST[1,]` matrix has the first user-supplied starting design. The last row the `NSTART`-th user-supplied starting design. `NTOP` integer. Number of the top best OMD designs `top`. `TOPD` double. The OMD value for the best top `NTOP` designs. `TOPDES` matrix. Top `NTOP` optimal OMD follow-up designs. `flag` integer. Indicator = 1, if the ‘md’ subroutine finished properly, -1 otherwise.

## Note

The function is a wrapper to call the modified FORTAN subroutine ‘omd’, ‘OMD.f’, part of the mdopt bundle for Bayesian model discrimination of multifactor experiments.

## Author(s)

Laura Deldossi. Adapted for R by Marta Nai Ruscone.

## References

Box, G. E. P. and Meyer, R. D. (1993) Finding the Active Factors in Fractionated Screening Experiments., Journal of Quality Technology 25(2), 94–105. doi: 10.1080/00224065.1993.11979432.

Consonni, G. and Deldossi, L. (2016) Objective Bayesian Model Discrimination in Follow-up design., Test 25(3), 397–412. doi: 10.1007/s11749-015-0461-3.

Meyer, R. D., Steinberg, D. M. and Box, G. E. P. (1996) Follow-Up Designs to Resolve Confounding in Multifactor Experiments (with discussion)., Technometrics 38(4), 303–332. doi: 10.2307/1271297.

`print.OMD`, `OBsProb`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42``` ```library(OBsMD) data(OBsMD.es5, package="OBsMD") X <- as.matrix(OBsMD.es5[,1:5]) y <- OBsMD.es5[,6] es5.OBsProb <- OBsProb(X=X,y=y,blk=0,mFac=5,mInt=2,nTop=32) nMod <- 26 Xcand <- matrix(c(-1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ),nrow=32,ncol=5,dimnames=list(1:32,c("A","B","C","D","E")),byrow=TRUE) p_omd <- OMD(OBsProb=es5.OBsProb,nFac=5,nBlk=0,nMod=26,nFoll=4,Xcand=Xcand, mIter=20,nStart=25,startDes=NULL,top=30) print(p_omd) ```