[Depmix-commits] r184 - trunk/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jun 24 17:35:27 CEST 2008


Author: maarten
Date: 2008-06-24 17:35:27 +0200 (Tue, 24 Jun 2008)
New Revision: 184

Modified:
   trunk/R/responseNORM.R
Log:
- fixed bug in NORMresponse (now also works without weights)

Modified: trunk/R/responseNORM.R
===================================================================
--- trunk/R/responseNORM.R	2008-06-24 14:23:39 UTC (rev 183)
+++ trunk/R/responseNORM.R	2008-06-24 15:35:27 UTC (rev 184)
@@ -6,11 +6,20 @@
 # returns: (fitted) response with (new) estimates of parameters
 
 setMethod("fit","NORMresponse",
-	function(object,w=NULL) {
+	function(object,w) {
+    if(missing(w)) w <- NULL
 		pars <- object at parameters
-		fit <- lm.wfit(x=object at x,y=object at y,w=w)
+		if(!is.null(w)) {
+      fit <- lm.wfit(x=object at x,y=object at y,w=w)
+    } else {
+      fit <- lm.fit(x=object at x,y=object at y)
+    }
 		pars$coefficients <- fit$coefficients
-		pars$sd <- sqrt(sum(w*fit$residuals^2/sum(w)))
+		if(!is.null(w)) {
+      pars$sd <- sqrt(sum(w*fit$residuals^2/sum(w)))
+    } else {
+      pars$sd <- sd(fit$residuals)
+    }
 		object <- setpars(object,unlist(pars))
 		object
 	}


More information about the depmix-commits mailing list