[Depmix-commits] r581 - pkg/depmixS4/tests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Sep 3 22:11:07 CEST 2013
Author: ingmarvisser
Date: 2013-09-03 22:11:07 +0200 (Tue, 03 Sep 2013)
New Revision: 581
Modified:
pkg/depmixS4/tests/test1speed.R
pkg/depmixS4/tests/test1speed.Rout.save
Log:
Added test for EM optimized logLikelihood of speed data model (so we can safely change around the EM function to optimize it for speed)
Modified: pkg/depmixS4/tests/test1speed.R
===================================================================
--- pkg/depmixS4/tests/test1speed.R 2013-09-03 20:10:02 UTC (rev 580)
+++ pkg/depmixS4/tests/test1speed.R 2013-09-03 20:11:07 UTC (rev 581)
@@ -98,7 +98,7 @@
cat("Test 3: ", all.equal(c(dev),acc$deviance),"(same but now with covariate) \n")
#
-# 2-state model with covariate
+# TEST 4: 2-state model with covariate
#
trstart=c(0.896,0.104,0.084,0.916)
@@ -112,3 +112,24 @@
cat("Test 4: ll is now larger than speedll, ie ll is better due to introduction of a covariate \n")
cat("Test 4: ", ll,"\t", logl, "\n")
cat("Test 4: ", ll > logl, "\n")
+
+
+#
+# TEST 5: use em to optimize the model
+#
+
+data(speed)
+
+# 2-state model on rt and corr from speed data set
+# with Pacc as covariate on the transition matrix
+# ntimes is used to specify the lengths of 3 separate series
+mod1 <- depmix(list(rt~1,corr~1),data=speed,transition=~Pacc,nstates=2,
+ family=list(gaussian(),multinomial("identity")),ntimes=c(168,134,137))
+# fit the model
+set.seed(3)
+fmod1 <- fit(mod1, verbose=FALSE)
+
+llEM <- logLik(fmod1)
+lltest <- -248.972219
+
+cat("Test 5: ", all.equal(c(lltest),c(llEM),check.att=FALSE), "(loglike EM optimized model for speed data) \n")
Modified: pkg/depmixS4/tests/test1speed.Rout.save
===================================================================
--- pkg/depmixS4/tests/test1speed.Rout.save 2013-09-03 20:10:02 UTC (rev 580)
+++ pkg/depmixS4/tests/test1speed.Rout.save 2013-09-03 20:11:07 UTC (rev 581)
@@ -1,7 +1,7 @@
-R version 2.7.1 (2008-06-23)
-Copyright (C) 2008 The R Foundation for Statistical Computing
-ISBN 3-900051-07-0
+R version 3.0.1 (2013-05-16) -- "Good Sport"
+Copyright (C) 2013 The R Foundation for Statistical Computing
+Platform: x86_64-apple-darwin10.8.0 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
@@ -121,7 +121,7 @@
Test 3: TRUE (same but now with covariate)
>
> #
-> # 2-state model with covariate
+> # TEST 4: 2-state model with covariate
> #
>
> trstart=c(0.896,0.104,0.084,0.916)
@@ -139,3 +139,26 @@
> cat("Test 4: ", ll > logl, "\n")
Test 4: TRUE
>
+>
+> #
+> # TEST 5: use em to optimize the model
+> #
+>
+> data(speed)
+>
+> # 2-state model on rt and corr from speed data set
+> # with Pacc as covariate on the transition matrix
+> # ntimes is used to specify the lengths of 3 separate series
+> mod1 <- depmix(list(rt~1,corr~1),data=speed,transition=~Pacc,nstates=2,
++ family=list(gaussian(),multinomial("identity")),ntimes=c(168,134,137))
+> # fit the model
+> set.seed(3)
+> fmod1 <- fit(mod1, verbose=FALSE)
+iteration 26 logLik: -248.9722
+>
+> llEM <- logLik(fmod1)
+> lltest <- -248.972219
+>
+> cat("Test 5: ", all.equal(c(lltest),c(llEM),check.att=FALSE), "(loglike EM optimized model for speed data) \n")
+Test 5: TRUE (loglike EM optimized model for speed data)
+>
More information about the depmix-commits
mailing list