[Depmix-commits] r659 - pkg/depmixS4/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Aug 23 13:56:10 CEST 2018


Author: maarten
Date: 2018-08-23 13:56:10 +0200 (Thu, 23 Aug 2018)
New Revision: 659

Modified:
   pkg/depmixS4/R/responseGLM.R
Log:
allow missing covariates in responseGLM as long as the DV is missing too

Modified: pkg/depmixS4/R/responseGLM.R
===================================================================
--- pkg/depmixS4/R/responseGLM.R	2018-07-25 16:11:37 UTC (rev 658)
+++ pkg/depmixS4/R/responseGLM.R	2018-08-23 11:56:10 UTC (rev 659)
@@ -27,9 +27,13 @@
 		mf[[1]] <- as.name("model.frame")
 		mf <- eval(mf, parent.frame())
 		x <- model.matrix(attr(mf, "terms"),mf)
-		if(any(is.na(x))) stop("'depmixS4' does not currently handle covariates with missing data.")
 		y <- model.response(mf)
 		if(!is.matrix(y)) y <- matrix(y,ncol=1)
+		if(any(is.na(x))) {
+		  # check whether the response is also missing
+		  y_na <- apply(y,1,function(x) all(is.na(x)))
+		  if(any(is.na(x[!y_na,]))) stop("'depmixS4' does not currently handle covariates with missing data.")
+		}
 		parameters <- list()
 		constr <- NULL
 		parameters$coefficients <- vector("numeric",length=ncol(x))



More information about the depmix-commits mailing list