[Depmix-commits] r678 - in pkg/depmixS4: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Feb 28 15:14:58 CET 2019


Author: ingmarvisser
Date: 2019-02-28 15:14:58 +0100 (Thu, 28 Feb 2019)
New Revision: 678

Added:
   pkg/depmixS4/man/stationary.Rd
Modified:
   pkg/depmixS4/DESCRIPTION
   pkg/depmixS4/NAMESPACE
   pkg/depmixS4/NEWS
   pkg/depmixS4/R/depmix-class.R
   pkg/depmixS4/R/depmixsim-class.R
   pkg/depmixS4/R/standardError.R
   pkg/depmixS4/R/stationary.R
Log:
=Added function 'stationary' to export and added help file for it

Modified: pkg/depmixS4/DESCRIPTION
===================================================================
--- pkg/depmixS4/DESCRIPTION	2018-12-08 14:38:37 UTC (rev 677)
+++ pkg/depmixS4/DESCRIPTION	2019-02-28 14:14:58 UTC (rev 678)
@@ -1,6 +1,6 @@
 Package: depmixS4
 Version: 1.4-0
-Date: 2018-09-20
+Date: 2019-03-20
 Title: Dependent Mixture Models - Hidden Markov Models of GLMs and Other Distributions in S4
 Author: Ingmar Visser <i.visser at uva.nl>, Maarten Speekenbrink <m.speekenbrink at ucl.ac.uk>
 Maintainer: Ingmar Visser <i.visser at uva.nl>

Modified: pkg/depmixS4/NAMESPACE
===================================================================
--- pkg/depmixS4/NAMESPACE	2018-12-08 14:38:37 UTC (rev 677)
+++ pkg/depmixS4/NAMESPACE	2019-02-28 14:14:58 UTC (rev 678)
@@ -23,7 +23,8 @@
 	em.control,
 	viterbi,
 	mlogit,
-	logLik
+	logLik,
+	stationary
 )
 
 exportClasses(

Modified: pkg/depmixS4/NEWS
===================================================================
--- pkg/depmixS4/NEWS	2018-12-08 14:38:37 UTC (rev 677)
+++ pkg/depmixS4/NEWS	2019-02-28 14:14:58 UTC (rev 678)
@@ -8,8 +8,15 @@
 Minor changes
 
   o Multivariate normal distribution models now use ML estimates (instead of the 
-    unbiased version that was hitherto used). 	
-
+    unbiased version that was hitherto used).
+	
+  o Fixed a bug in the simulate class where a depmix.fitted object used
+  	to simulate data was cast to mix.sim object rather than the correct
+	depmix.sim object.
+	
+  o Added function 'stationary' that computes the stationary distribution of 
+    a transition probability matrix. 
+	
 Changes in depmixS4 version 1.3-5
 
   o GLM responses now allow missing values in covariates, as long as the

Modified: pkg/depmixS4/R/depmix-class.R
===================================================================
--- pkg/depmixS4/R/depmix-class.R	2018-12-08 14:38:37 UTC (rev 677)
+++ pkg/depmixS4/R/depmix-class.R	2019-02-28 14:14:58 UTC (rev 678)
@@ -310,7 +310,7 @@
 		}
 		
 		# generate new depmix.sim object
-		object <- as(object,"depmix.sim") 
+		object <- as(object,"depmix.sim", strict=FALSE) 
 		object at states <- as.matrix(states)
 		
 		object at prior@x <- as.matrix(apply(object at prior@x,2,rep,nsim))

Modified: pkg/depmixS4/R/depmixsim-class.R
===================================================================
--- pkg/depmixS4/R/depmixsim-class.R	2018-12-08 14:38:37 UTC (rev 677)
+++ pkg/depmixS4/R/depmixsim-class.R	2019-02-28 14:14:58 UTC (rev 678)
@@ -19,5 +19,5 @@
 })
 
 setAs("depmix.fitted","depmix.sim",def=function(from) {
-  as(as(from,"mix"),"mix.sim")
-})
\ No newline at end of file
+  as(as(from,"depmix"),"depmix.sim")
+})

Modified: pkg/depmixS4/R/standardError.R
===================================================================
--- pkg/depmixS4/R/standardError.R	2018-12-08 14:38:37 UTC (rev 677)
+++ pkg/depmixS4/R/standardError.R	2019-02-28 14:14:58 UTC (rev 678)
@@ -38,7 +38,7 @@
 		
 	ret <- data.frame(par=pars, constr=elements, se=NA)
 	
-	ret$ses[which(elements=="inc")] <- ses
+	ret$se[which(elements=="inc")] <- ses
 	
 	return(ret)
 }

Modified: pkg/depmixS4/R/stationary.R
===================================================================
--- pkg/depmixS4/R/stationary.R	2018-12-08 14:38:37 UTC (rev 677)
+++ pkg/depmixS4/R/stationary.R	2019-02-28 14:14:58 UTC (rev 678)
@@ -5,10 +5,10 @@
 # 
 
 stationary <- function(tpm) {
-	if(!(nrow(tpm)==ncol(tpm))) stop("stationary distribution only defined for square matrices.")
+	if(!(nrow(tpm)==ncol(tpm))) stop("Stationary distribution only defined for square matrices.")
 	nr <- nrow(tpm)
 	rs <- all.equal(rowSums(tpm),rep(1,nr))
-	if(!(rs==TRUE)) stop("rows of the transition matrix should sum to unity")
+	if(!(rs==TRUE)) stop("Rows of the transition probability matrix should sum to unity.")
 	e1 <- as.double(eigen(t(tpm))$vectors[,1])
 	e1 <- e1/sum(e1)
 	return(e1)

Added: pkg/depmixS4/man/stationary.Rd
===================================================================
--- pkg/depmixS4/man/stationary.Rd	                        (rev 0)
+++ pkg/depmixS4/man/stationary.Rd	2019-02-28 14:14:58 UTC (rev 678)
@@ -0,0 +1,15 @@
+\name{stationary}
+
+\alias{stationary}
+
+\title{Compute the stationary distribution of a transition probability matrix.}
+
+\description{See title.}
+
+\usage{stationary(tpm)}
+
+\arguments{
+	\item{tpm}{a transition probability matrix.}
+}
+
+\value{A vector with the stationary distribution such that p=tpm*p.}
\ No newline at end of file



More information about the depmix-commits mailing list