File: model.matrix.segmented.r

package info (click to toggle)
r-cran-segmented 2.1-4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,484 kB
  • sloc: makefile: 2
file content (16 lines) | stat: -rw-r--r-- 512 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
model.matrix.segmented<-function(object,...){
  #if(!inherits(object, "segmented")) stop("A 'segmented' fit is requested")
  if(inherits(object, "lm")) {
    X<- qr.X(object$qr, ...)
    if(inherits(object, "glm")) {
      #W<-chol(diag(object$weights))
      #X <- X/diag(W)
      X<- X/sqrt(object$weights)
    }
  } else {
    class(object)<-class(object)[-1]
    X<-try(model.matrix(object,...), silent=TRUE)
    if(!is.matrix(X)) X<- model.matrix(object, data=model.frame(object))
  }
  X
}