File: num.intercepts.s

package info (click to toggle)
hmisc 5.2-5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,044 kB
  • sloc: asm: 28,907; f90: 590; ansic: 415; xml: 160; fortran: 75; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 677 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
num.intercepts <- function(fit, type=c('fit', 'var', 'coef'))
{
  type <- match.arg(type)
  nrp <- fit$non.slopes
  if(! length(nrp))  {
    nm1 <- names(fit$coef)[1]
    nrp <- 1 * (nm1 == "Intercept" | nm1 == "(Intercept)")
  }
  if(type == 'fit') return(nrp)

  w <- if(type == 'coef') fit$coefficients else {
    v <- fit[['var']]
    if(! length(v)) {
      v <- fit$info.matrix
      # If there is only one intercept for lrm or orm, info matrix may be non-partitioned
      if(length(v) && ('ab' %in% names(v))) attr(v, 'intercepts') <- nrow(v$ab)
    }
    v
  }
  i  <- attr(w, 'intercepts')
  li <- length(i)
  if(! li) return(nrp)
  if(li == 1 && i == 0) 0 else li
}