Skip to content

Initialization of stackingPredictiveFamily #4

Description

@mfasiolo

Currently, all the coefficients are initialized at 0, which means that every expert gets the same weight.

One important point is that family$initialize is used in initial.spg, so getting a good initialization is important for getting decent initial parameter estimates.

One possible initialization function that works only when discrete = FALSE can be found below. The idea is to do something similar to what is done in the multinomial family. The code would need to be adapted to work when discrete = TRUE, for example by looking at what Simon did in the gaulss family.

 initialize <- expression({

       if (is.null(start)){

       logP <- family$getLogP()
       ybest <- as.numeric(apply(logP, 1, which.max)) - 1

       ## should E be used unscaled or not?..
       use.unscaled <- if (!is.null(attr(E,"use.unscaled"))) TRUE else FALSE
      if (is.null(start)) {

        jj <- attr(x,"lpi")
        start <- rep(0,ncol(x))
        for (k in 1:length(jj)) { ## loop over the linear predictors
          yt1 <- 6 * as.numeric(ybest == k) - 3 
          x1 <- x[,jj[[k]],drop=FALSE]
          e1 <- E[,jj[[k]],drop=FALSE] ## square root of total penalty
          if (use.unscaled) {
            qrx <- qr(rbind(x1,e1))
            x1 <- rbind(x1,e1)
            startji <- qr.coef(qr(x1),c(yt1,rep(0,nrow(E))))
            startji[!is.finite(startji)] <- 0
          } else startji <- penReg(x1,e1,yt1)
          start[jj[[k]]] <- startji ## copy coefficients back into overall start coef vector
        } ## lp loop
      }
    }

  }) ## initialize

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions