R/redmod.r

Defines functions redmod

Documented in redmod

#   
#   Reduced model design matrix.
#
#   This function is called by the routine droptest.
#   Obtains the reduced model design matrix
#   for full model design matrix xmat and 
#   hypothesis matrix amat.  Checks to see
#   if amat has full row rank.
#   Uses Theorem 3.7.2 of H&M (1998, p. 186)
#
redmod<-function(xmat,amat){
  xmat=as.matrix(xmat)
  amat=rbind(amat)
  q<-length(amat[,1])
  p<-length(xmat[1,])
  temp<-qr(t(amat))
  if(temp$rank != q) {
    stop("redmod:  The hypothesis matrix is not full row rank.")
  } else {
    zed<-qr.qty(temp,t(xmat))
    redmod<-rbind(zed[(q+1):p,])
  }
  t(redmod)
}

Try the Rfit package in your browser

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

Rfit documentation built on Sept. 8, 2023, 5:59 p.m.