R/glpls1a.predict.R

Defines functions glpls1a.mlogit.predict glpls1a.predict

#replaced by the predict method for gpls
glpls1a.predict <- function(X, beta, family="binomial", link="logit")
{
  if(all(X[,1] == rep(1,nrow(X))))
   {
     eta <- X%*%beta
   }else{
     eta <- cbind(rep(1,nrow(X)),X)%*%beta
  }
  return(h(eta,family,link))
}

glpls1a.mlogit.predict <- function(X,beta)
  {
    ## prediction for multinomial logit model
    ## beta is the p by J-1 matrix where J is the levels of categories of the outcomoe
    
    if(all(X[,1] == rep(1,nrow(X))))
      {
        eta <- X%*%beta
      }else
      {
        eta <- cbind(rep(1,nrow(X)),X)%*% beta
      }

    p <- exp(eta)
    p.denom <- apply(p,1,function(x) 1+sum(x))
      
    return(p/p.denom)
  }

Try the gpls package in your browser

Any scripts or data that you put into this service are public.

gpls documentation built on Nov. 8, 2020, 6:50 p.m.