R/makeXBeta.R

Defines functions makeXBeta

Documented in makeXBeta

makeXBeta <- function(cformula, 
                      dados, 
                      mu, 
                      fe, 
                      blke,
                      rowe, 
                      cole, 
                      inte, 
                      contrasts)
{
  X <- model.matrix(eval(parse(text = cformula)),
                    dados,
                    contrasts.arg = contrasts)

  if(length(mu) == 1){#univariado
    betas <- as.matrix(c(mu,
                         blke,
                         rowe,
                         cole,
                         unlist(fe),
                         inte))
  } else {#multivariado
    betas <- rbind(mu,
                   blke,
                   rowe,
                   cole,
                   do.call('rbind', 
                           fe),
                   inte)
  } 
  XB <- list(X = X,
             B = betas,
             XB = X%*%betas)
  return(XB)
}

Try the gexp package in your browser

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

gexp documentation built on July 9, 2023, 5:42 p.m.