# Cross-validation function for BTLLasso

### Description

Performs crossvalidation of BTLLasso, including the BTLLasso algorithm for the whole data set.

### Usage

1 2 | ```
cv.BTLLasso(Y, X, folds = 10, lambda, control = BTLLasso.ctrl(),
cores = folds, trace = TRUE, trace.cv = TRUE)
``` |

### Arguments

`Y` |
Matrix containing paired comparisons, ordered or binary. For K categories, the colmuns have to be ordered as follows: 1 vs. 2, 1 vs.3, ..., 1 vs. K, 2 vs. 3, 2 vs. 4, ..., 2 vs. K, ..., K-1 vs. K. One row represents one subject. |

`X` |
Matrix containing all subject-specific covariates. One row represents one subject, one column represents one covariate. Has to be standardized. |

`folds` |
Number of folds for the crossvalidation. Default is 10. |

`lambda` |
Vector of tuning parameters. |

`control` |
Function for control arguments, mostly for internal use. See also |

`cores` |
Number of cores used for (parallelized) cross-validation. By default, equal to the number of folds. |

`trace` |
Should the trace of the BTLLasso algorithm be printed? |

`trace.cv` |
Should the trace fo the cross-validation be printed? If parallelized, the trace is not working on Windows machines. |

### Details

Cross validation can be performed parallel, default is 10-fold cross validation on 10 cores. Output is a cv.BTLLasso object which can then be used for bootstrap confidence intervalls using `boot.BTLLasso`

and `ci.BTLLasso`

.

### Value

`coefs` |
Matrix containing all (original) coefficients, one row per tuning parameter, one column per coefficient. |

`coefs.repar` |
Matrix containing all reparameterized (for symmetric side constraint) coefficients, one row per tuning parameter, one column per coefficient. |

`logLik` |
Vector of log-likelihoods, one per tuning parameter. |

`design` |
Design matrix, NULL if |

`Y` |
Y matrix |

`q` |
q=K-1, K is the number of different categories in |

`acoefs` |
Matrix containing penalties, for internal use. |

`response` |
Vector containing 0-1 coded response. |

`n` |
Number of persons/subjects |

`I` |
Number of paired comparisons |

`m` |
Number of objects |

`p` |
Number of covariates |

`X` |
X matrix |

`n.theta` |
Number of estimated threshold parameters |

`lambda` |
Vector of tuning parameters |

`deviances` |
Vector of cross-validation deviances, one value per tuning parameter. |

`folds` |
Number of folds in cross validation. |

`labels` |
Labels of objects, only correct if Y specified correctly by "1 vs. 2","1 vs. 3",... |

`epsilon` |
Threshold value for convergence of the algorithm, specified in |

### Author(s)

Gunther Schauberger

gunther@stat.uni-muenchen.de

http://www.statistik.lmu.de/~schauberger/

### References

Schauberger, Gunther and Tutz, Gerhard (2015): Modelling Heterogeneity in Paired Comparison Data - an L1 Penalty Approach with an Application to Party Preference Data, *Department of Statistics, LMU Munich*, Technical Report 183

### See Also

`BTLLasso`

, `boot.BTLLasso`

, `singlepaths`

, `paths`

### 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | ```
## Not run:
# load data set
data(GLESsmall)
# define response and covariate matrix
X <- scale(GLESsmall[, 11:14])
Y <- as.matrix(GLESsmall[, 1:10])
# vector of subtitles, containing the coding of the single covariates
subs <- c("(in years)","female (1); male (0)",
"East Germany (1); West Germany (0)","(very) good (1); else (0)")
# vector of tuning parameters
lambda <- exp(seq(log(31),log(1),length=50))-1
# compute BTLLasso model
m <- BTLLasso(Y = Y, X = X, lambda = lambda)
op <- par(no.readonly = TRUE)
par(mar=c(5,4,4,8))
# plot covariate paths
paths(m)
# plot parameter paths
singlepaths(m, subs = subs)
# compute 10-fold cross-validation
set.seed(5)
m.cv <- cv.BTLLasso(Y = Y, X = X, folds = 10, lambda = lambda, cores = 10)
# plot covariate paths, together with cv-optimal model
paths(m.cv)
# plot parameter paths, together with cv-optimal model
singlepaths(m.cv, subs = subs)
# compute bootstrap confidence intervals
m.boot <- boot.BTLLasso(m.cv, B = 100, cores = 25)
# plot bootstrap confidence intervals
par(mar=c(5,5,4,3))
ci.BTLLasso(m.boot, subs = subs)
par(op)
## End(Not run)
``` |