# Compute Confidence Intervals (CI) for test samples

### Description

Compute Confidence Intervals (CI) for test samples based on random subsamplings

### Usage

1 2 | ```
CI.prediction(object,X,Y,keepX.constraint,ncomp,many,
subsampling.matrix,ratio,X.test,level.CI,save.file)
``` |

### Arguments

`object` |
a ‘spls.constraint’ object, as one resulting from |

`X` |
Only used if |

`Y` |
Only used if |

`keepX.constraint` |
Only used if |

`ncomp` |
Only used if |

`many` |
How many subsamplings do you want to do? Default is 100 |

`subsampling.matrix` |
Optional matrix of |

`ratio` |
Number between 0 and 1. It is the proportion of the n samples that are put aside and considered as an internal testing set. The (1-ratio)*n samples are used as a training set and the |

`X.test` |
Test matrix. |

`level.CI` |
A 1- |

`save.file` |
Save the outputs of the functions in |

### Details

This function can work with a ‘spls.constraint’ object or with the input data (X, Y, keepX.constraint). See examples below to see the difference in use.

### Value

`CI` |
A (1- |

`Y.hat.test` |
A four dimensional array. The two first dimensions are an estimation of the dummy matrix obtained from Y (size n * number of sample types). The third dimension is relative to the number of components |

`ClassifResult` |
A 5-dimensional array. The two first dimensions consists in the confusion matrix. The third dimension is relative to the number of components |

`loadings.X` |
A 3-dimensional array. Loadings vector of X, for each component and each subsampling. |

`prediction.X` |
A 4-dimensional array of size n*many*ncomp*3. Gives the prediction for the chosen |

`prediction.X.test` |
A 4-dimensional array of size nrow(X.test)*many*ncomp*3. Gives the prediction for the chosen |

`learning.sample` |
Matrix of size n*many. Gives the samples that have been used in the internal training set over the |

`coeff` |
A list of means.X, sigma.X, means.Y and sigma.Y. Means and variances for the variables of X and the columns of the dummy matrix obtained from Y, each row is a subsampling. |

`data` |
A list of the input data X, Y and of keepX.constraint, which is a list containing the variables kept on each component. |

### See Also

`fit.model`

, `prediction`

### Examples

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 | ```
## Not run:
data(MSC)
X=MSC$X
Y=MSC$Y
# with a bootsPLS object
boot=bootsPLS(X=X,Y=Y,ncomp=3,many=5,kCV=5)
fit=fit.model(boot,ncomp=3)
CI=CI.prediction(fit)
CI=CI.prediction(fit,X.test=X)
lapply(CI$CI$'comp.1',head)
lapply(CI$CI$'comp.2',head)
lapply(CI$CI$'comp.3',head)
# without a spls.constraint object. X,Y and keepX.constraint are needed
# the results should be similar
#(not the same because of the random subsamplings,
# exactly the same if subsampling.matrix is an input)
keepX.constraint=fit$data$keepX.constraint
CI=CI.prediction(X=X,Y=Y,keepX.constraint=keepX.constraint)
CI=CI.prediction(X=X,Y=Y,keepX.constraint=keepX.constraint,X.test=X)
lapply(CI$CI$'comp.1',head)
lapply(CI$CI$'comp.2',head)
lapply(CI$CI$'comp.3',head)
## End(Not run)
``` |