[Vars-commits] r64 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Dec 12 17:02:43 CET 2009


Author: matthieu
Date: 2009-12-12 17:02:43 +0100 (Sat, 12 Dec 2009)
New Revision: 64

Modified:
   pkg/R/toMlm.R
Log:
Patch: correct toMlm


Modified: pkg/R/toMlm.R
===================================================================
--- pkg/R/toMlm.R	2009-12-12 16:02:41 UTC (rev 63)
+++ pkg/R/toMlm.R	2009-12-12 16:02:43 UTC (rev 64)
@@ -9,11 +9,17 @@
 toMlm.varest<-function(x){
   ix <- 1:x$K
   X<-x$datamat
+  type<-x$type
+  is.const<-type%in%c("const", "both")
   #remove constant in datamat
-  if(x$type%in%c("const", "both")) X<-X[, -grep("const", colnames(X))]
+  if(is.const) X<-X[, -grep("const", colnames(X))]
   #construct formula
   left <- paste(names(X)[ix], collapse = ",")
-  fo <- as.formula(paste("cbind(", left, ") ~ ."))
+  if(is.const) {
+    fo <- as.formula(paste("cbind(", left, ") ~ ."))
+  } else {
+    fo <- as.formula(paste("cbind(", left, ") ~ .-1")) #remove automatical constant
+  }
   #apply lm
   res<-eval(substitute(lm(fo, X), list(fo = fo))) #code suggested by Gabor Groothendick
   return(res)



More information about the Vars-commits mailing list