全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
1923 1
2017-11-08
在Hui Zou和Yi Yang编写的gcdnet包中的主函数gcdnet源代码中看不到其所运用的算法,这个函数的代码为:
gcd=function (x, y, nlambda = 100, method = c("hhsvm", "logit", "sqsvm",
    "ls"), lambda.factor = ifelse(nobs < nvars, 0.01, 1e-04),
    lambda = NULL, lambda2 = 0, pf = rep(1, nvars), pf2 = rep(1,
        nvars), exclude, dfmax = nvars + 1, pmax = min(dfmax *
        1.2, nvars), standardize = TRUE, eps = 1e-08, maxit = 1e+06,
    delta = 2)
{
    method <- match.arg(method)
    this.call <- match.call()
    y <- drop(y)
    x <- as.matrix(x)
    np <- dim(x)
    nobs <- as.integer(np[1])
    nvars <- as.integer(np[2])
    vnames <- colnames(x)
    if (is.null(vnames))
        vnames <- paste("V", seq(nvars), sep = "")
    if (length(y) != nobs)
        stop("x and y have different number of observations")
    if (length(pf) != nvars)
        stop("The size of L1 penalty factor must be same as the number of input variables")
    if (lengt
h(pf2) != nvars)
        stop("The size of L2 penalty factor must be same as the number of input variables")
    if (lambda2 < 0)
        stop("lambda2 must be non-negative")
    maxit <- as.integer(maxit)
    lam2 <- as.double(lambda2)
    pf <- as.double(pf)
    pf2 <- as.double(pf2)
    isd <- as.integer(standardize)
    eps <- as.double(eps)
    dfmax <- as.integer(dfmax)
    pmax <- as.integer(pmax)
    if (!missing(exclude)) {
        jd <- match(exclude, seq(nvars), 0)
        if (!all(jd > 0))
            stop("Some excluded variables out of range")
        jd <- as.integer(c(length(jd), jd))
    }
    else jd <- as.integer(0)
    nlam <- as.integer(nlambda)
    if (is.null(lambda)) {
        if (lambda.factor >= 1)
            stop("lambda.factor should be less than 1")
        flmin <- as.double(lambda.factor)
        ulam <- double(1)
    }
    else {
        flmin <- as.double(1)
        if (any(lambda < 0))
            stop("lambdas should be non-negative")
        ulam <- as.double(rev(sort(lambda)))
        nlam <- as.integer(length(lambda))
    }
    fit <- switch(method, hhsvm = hsvmpath(x, y, nlam, flmin,
        ulam, isd, eps, dfmax, pmax, jd, pf, pf2, maxit, lam2,
        delta, nobs, nvars, vnames), logit = logitpath(x, y,
        nlam, flmin, ulam, isd, eps, dfmax, pmax, jd, pf, pf2,
        maxit, lam2, nobs, nvars, vnames), sqsvm = sqsvmpath(x,
        y, nlam, flmin, ulam, isd, eps, dfmax, pmax, jd, pf,
        pf2, maxit, lam2, nobs, nvars, vnames), ls = lspath(x,
        y, nlam, flmin, ulam, isd, eps, dfmax, pmax, jd, pf,
        pf2, maxit, lam2, nobs, nvars, vnames))
    if (is.null(lambda))
        fit$lambda <- lamfix(fit$lambda)
    fit$call <- this.call
    class(fit) <- c("gcdnet", class(fit))
    fit
}

    我怀疑算法在hsvmpath、 logitpath等函数中体现,但这些函数在R以及他们编写的包中根本找不到,所以想问下大侠们如何才能这个所依据的算法。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2017-12-10 11:05:03
已解决
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群