Learn R Programming

BTLLasso (version 0.1-2)

cv.BTLLasso: Cross-validation function for BTLLasso

Description

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

Usage

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 BTLLasso.ctrl.
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.

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 return.design=FALSE in BTLLasso.ctrl
Y
Y matrix
q
q=K-1, K is the number of different categories in Y
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 BTLLasso.ctrl

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.

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

Run this code
## 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)

Run the code above in your browser using DataLab