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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Oct 26 17:36:23 CEST 2011


Author: ingmarvisser
Date: 2011-10-26 17:36:23 +0200 (Wed, 26 Oct 2011)
New Revision: 498

Modified:
   pkg/depmixS4/R/depmix.R
Log:
Added error message about missing data.

Modified: pkg/depmixS4/R/depmix.R
===================================================================
--- pkg/depmixS4/R/depmix.R	2011-10-26 13:31:18 UTC (rev 497)
+++ pkg/depmixS4/R/depmix.R	2011-10-26 15:36:23 UTC (rev 498)
@@ -20,6 +20,8 @@
     data = NULL, nstates, family = gaussian(), prior = ~1, initdata = NULL, 
     respstart = NULL, instart = NULL, ...) {
     
+	if(!is.null(data) & any(is.na(data))) stop("'depmixS4' does not currently handle missing data.")
+	
     # make response models
     response <- makeResponseModels(response = response, data = data, 
         nstates = nstates, family = family, values = respstart)
@@ -29,6 +31,7 @@
     ntimes <- rep(1, nrow(data))
     
     # make prior model
+	if(is.null(initdata)) initdata=data
     prior <- makePriorModel(nstates = nstates, ncases = length(ntimes), 
         formula = prior, data = initdata, values = instart)
     
@@ -58,12 +61,12 @@
 	if(is.null(data)) {
 		if(is.null(ntimes)) stop("'ntimes' must be provided if not in the data")
 	} else {
+		if(any(is.na(data))) stop("'depmixS4' does not currently handle missing data.")
 		if(is.null(attr(data, "ntimes"))) {
 			if (is.null(ntimes)) ntimes <- nrow(data)
 		} else {
 			ntimes <- attr(data, "ntimes")
 		}
-		
 		if (sum(ntimes) != nrow(data)) stop("'ntimes' and data do not match")
 	}
 	



More information about the depmix-commits mailing list