cv.cdlm | R Documentation |
Chooses tuning parameter M in the penalized version of cdlm
, using cross validation.
cv.cdlm( Y, s2, C, CY, CN = NULL, N = NULL, Lp = 1, nfolds = 2, M.min = 0, M.max = 5, nM = 11, verbose = FALSE )
Y |
observed data (n x 1) |
s2 |
unbiased estimate of variance of Y (n x 1) |
C |
main effects in the linear regression (n x p_C) |
CY |
terms in the linear regression that interact with Y (n x p_Y) |
CN |
terms in the linear regression that interact with Y_i_k for i_k in the ith row of N. This should be a list of length q, where the kth item in the list is an n x p_k matrix. |
N |
neighbors of each index (n x q). This encodes structural information, where the ith row of N contains indices that are expected to be similar to the ith parameter of interest. |
Lp |
p norm |
nfolds |
number of folds of CV |
M.min |
minimum value of M to consider |
M.max |
largest value of M to consider |
nM |
number of M to fit, equally spaced between M.min and M.max inclusive |
verbose |
if TRUE, prints a message every time a fold is fit |
Ms |
list of M values that were tried |
M.opt |
optimal M value |
b |
estimated regression coefficients |
est |
estimated parameters of interest |
n = 10 set.seed(1) theta = sort(rnorm(n)) s2 = abs(theta) + runif(n) Y = theta + rnorm(n, sd = sqrt(s2)) C = cbind(1, s2) CY = cbind(1, 1 / s2) N = cbind(c(n, 1:(n - 1)), c(2:n, 1)) CN = rep(list(matrix(1, n, 1)), ncol(N)) fit = cv.cdlm(Y, s2, C, CY, CN, N, Lp = 1, nfolds = 5) mean((theta - fit$est)^2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.