View source: R/print.cv.npmr.R
print.cv.npmr | R Documentation |
Print (1) the call that produced the cv.npmr
object;
(2) the value of the regularization parameter lambda that led to the
minimum cross validation error; (3) the rank of the fitted regression
coefficient matrix; and (4) the per-observation cross validation error using
the optimal lambda.
## S3 method for class 'cv.npmr'
print(x, ...)
x |
an object of class |
... |
ignored |
Scott Powers, Trevor Hastie, Rob Tibshirani
Scott Powers, Trevor Hastie and Rob Tibshirani (2016). “Nuclear penalized multinomial regression with an application to predicting at bat outcomes in baseball.” In prep.
cv.npmr
, print.npmr
# Fit NPMR to simulated data
K = 5
n = 1000
m = 10000
p = 10
r = 2
# Simulated training data
set.seed(8369)
A = matrix(rnorm(p*r), p, r)
C = matrix(rnorm(K*r), K, r)
B = tcrossprod(A, C) # low-rank coefficient matrix
X = matrix(rnorm(n*p), n, p) # covariate matrix with iid Gaussian entries
eta = X
P = exp(eta)/rowSums(exp(eta))
Y = t(apply(P, 1, rmultinom, n = 1, size = 1))
fold = sample(rep(1:10, length = nrow(X)))
# Simulate test data
Xtest = matrix(rnorm(m*p), m, p)
etatest = Xtest
Ptest = exp(etatest)/rowSums(exp(etatest))
Ytest = t(apply(Ptest, 1, rmultinom, n = 1, size = 1))
# Fit NPMR for a sequence of lambda values without CV:
fit2 = cv.npmr(X, Y, lambda = exp(seq(7, -2)), foldid = fold)
# Print the NPMR fit:
fit2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.