Run_simulation/junk2.R

n <- 100
p <- 20
x=matrix(rnorm(n*p),n,p)
y=rnorm(n)
fit1=glmnet(x = x,  y = y,
            weights = rep(1, times = n), penalty.factor = rep(1, times = p),
            alpha = 1,
            nlambda = 100, lambda.min.ratio = 0.001,
            standardize = FALSE,
            intercept = FALSE,
            thresh = 1e-8,
            type.gaussian = "naive")

w <- rep(1, times = n)
v <- w / sum(w)
v <- sqrt(v)
y <- Comp_data$y
y1 <- v * y
ys <- as.numeric(sqrt(crossprod(y1) - crossprod(v, y1)^2))
y1 <- y1 / ys
crossprod(y1 - mean(y1))

comp <- classo(y = drop(y1 * sqrt(n)), Z = x, Zc = NULL, intercept = FALSE,
               pf = rep(1, times = p),
               lam = fit1$lambda,
               nlam = 100, lambda.factor = 0.001,
               dfmax = p,
               mu_ratio = 0, tol = 0,
               outer_maxiter = 1e8, outer_eps = 1e-10, inner_maxiter = 1e8, inner_eps = 1e-10)


comp$beta[, 50]
fit1$beta[, 50]
jiji6454/Rpac_compReg documentation built on May 31, 2019, 5:01 a.m.