[Depmix-commits] r684 - in pkg/depmix: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jan 15 16:26:34 CET 2020


Author: ingmarvisser
Date: 2020-01-15 16:26:33 +0100 (Wed, 15 Jan 2020)
New Revision: 684

Modified:
   pkg/depmix/CHANGES
   pkg/depmix/DESCRIPTION
   pkg/depmix/NAMESPACE
   pkg/depmix/R/depmix-internal.R
   pkg/depmix/R/depmix.R
Log:
=updated to conform to development R version

Modified: pkg/depmix/CHANGES
===================================================================
--- pkg/depmix/CHANGES	2020-01-15 15:24:48 UTC (rev 683)
+++ pkg/depmix/CHANGES	2020-01-15 15:26:33 UTC (rev 684)
@@ -1,4 +1,8 @@
+Changes in 0.9.16
 
+1) Now using is(x,"classname") instead of class(x)=="classname" which 
+is errorprone in objects with multiple classes. 
+
 Changes in 0.9.15
 
 1) Removed NPSOL support in both C and R code (as it produced errors and no one seems to be using it anyway).

Modified: pkg/depmix/DESCRIPTION
===================================================================
--- pkg/depmix/DESCRIPTION	2020-01-15 15:24:48 UTC (rev 683)
+++ pkg/depmix/DESCRIPTION	2020-01-15 15:26:33 UTC (rev 684)
@@ -1,11 +1,11 @@
 Package: depmix
-Version: 0.9.15
-Date: 2018-12-08
+Version: 0.9.16
+Date: 2020-01-09
 Title: Dependent Mixture Models
 Author: Ingmar Visser <i.visser at uva.nl>
 Maintainer: Ingmar Visser <i.visser at uva.nl>
-Depends: R (>= 3.5.0), MASS
+Depends: R (>= 3.5.0), MASS, methods
 Suggests: Rdonlp2
 Additional_repositories: http://R-Forge.R-project.org
-Description: Fits (multigroup) mixtures of latent or hidden Markov models on mixed categorical and continuous (timeseries) data. The Rdonlp2 package can optionally be used for optimization of the log-likelihood and is available from R-forge. 
+Description: Fits (multigroup) mixtures of latent or hidden Markov models on mixed categorical and continuous (timeseries) data. The 'Rdonlp2' package can optionally be used for optimization of the log-likelihood and is available from R-forge. See Visser et al. (2009, <DOI:10.1007/978-0-387-95922-1_13>) for examples and applications. 
 License: GPL-3
\ No newline at end of file

Modified: pkg/depmix/NAMESPACE
===================================================================
--- pkg/depmix/NAMESPACE	2020-01-15 15:24:48 UTC (rev 683)
+++ pkg/depmix/NAMESPACE	2020-01-15 15:26:33 UTC (rev 684)
@@ -1,4 +1,5 @@
 import(MASS)
+import(methods)
 
 importFrom("graphics", "layout.show")
 importFrom("stats", "kmeans", "na.omit", "nlm", "optim", "plot.ts",

Modified: pkg/depmix/R/depmix-internal.R
===================================================================
--- pkg/depmix/R/depmix-internal.R	2020-01-15 15:24:48 UTC (rev 683)
+++ pkg/depmix/R/depmix-internal.R	2020-01-15 15:26:33 UTC (rev 684)
@@ -368,8 +368,8 @@
 kmstart <- function(dat,dmm) {
 	nst=dmm$nstates
 	kmc=try(kmeans(na.omit(dat[,1:(nitems(dat)-ncov(dat))]),nst)$cluster,silent=TRUE)
-	if(class(kmc)=="try-error") {
-		while(class(kmc)=="try-error") {
+	if(is(kmc,"try-error")) {
+		while(is(kmc,"try-error")) {
 			kmc=try(kmeans(dat[,1:(nitems(dat)-ncov(dat))],nst)$cluster,silent=TRUE)
 		}	
 	}
@@ -386,7 +386,7 @@
 cl2st <- function(cluster,dat,dmm) {
 	nst=dmm$nstates
 	stin=numeric(nst)
-	if("lcm"%in%class(dmm) || dmm$nst==1) {
+	if(is(dmm, "lcm") || dmm$nst==1) {
 		sttr=diag(nst)
 		for(i in 1:nst) {
 			stin[i]=length(cluster[which(cluster==i)]) 

Modified: pkg/depmix/R/depmix.R
===================================================================
--- pkg/depmix/R/depmix.R	2020-01-15 15:24:48 UTC (rev 683)
+++ pkg/depmix/R/depmix.R	2020-01-15 15:26:33 UTC (rev 684)
@@ -763,17 +763,17 @@
 		if(length(idx)>0) A=A[-idx,,drop=FALSE]
 		d=hs+t(A)%*%A
 		di=try(solve(d),silent=TRUE)
-		if(class(di)=="try-error") {
+		if(is(di,"try-error")) {
 			warning("Hessian singular, ses could not be computed.") 
 			val=list(se=0,hs=0)
 		} else {
 			ada=A%*%di%*%t(A)
 			adai=try(solve(ada),silent=TRUE)
-			if(class(adai)=="try-error") {
+			if(is(adai,"try-error")) {
 				warning("Near-singular hessian, ses may be bad.\n")
 				diag(ada)=diag(ada)*1.000001
 				adai=try(solve(ada))
-				if(class(adai)=="try-error") {
+				if(is(adai,"try-error")) {
 					warning("Corrected hessian also singular, ses computed without contraints.\n")
 					se[which(mod$fixed[1:mod$npars]==1)]=sqrt(diag(di))
 				} else {
@@ -795,7 +795,7 @@
 
 # compute bootstrap based standard errors + gof
 bootstrap <- function(object, dat, samples=100, pvalonly=0, ...) {
-	if(!class(object)=="fit") stop("Bootstrapping only possible on 'fit' objects.")
+	if(!is(object,"fit")) stop("Bootstrapping only possible on 'fit' objects.")
 	mod=object$mod
 	# compute only bootrapped pval, not ses
 	gof=matrix(0,samples,3)



More information about the depmix-commits mailing list