[Depmix-commits] r461 - in pkg/depmixS4: data man tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 15 14:33:00 CEST 2011


Author: ingmarvisser
Date: 2011-06-15 14:33:00 +0200 (Wed, 15 Jun 2011)
New Revision: 461

Modified:
   pkg/depmixS4/data/speed.rda
   pkg/depmixS4/man/depmix.Rd
   pkg/depmixS4/man/depmix.fit.Rd
   pkg/depmixS4/man/makeDepmix.Rd
   pkg/depmixS4/man/responses.Rd
   pkg/depmixS4/man/speed.Rd
   pkg/depmixS4/tests/test1speed.R
   pkg/depmixS4/tests/test1speed.Rout.save
   pkg/depmixS4/tests/test2getsetpars.R
   pkg/depmixS4/tests/test2getsetpars.Rout.save
Log:
Removed ntimes attribute from speed data (and adapted examples and tests accordingly), updated reference on speed data help page to Dutilh et al. (2011).

Modified: pkg/depmixS4/data/speed.rda
===================================================================
(Binary files differ)

Modified: pkg/depmixS4/man/depmix.Rd
===================================================================
--- pkg/depmixS4/man/depmix.Rd	2011-06-15 10:26:59 UTC (rev 460)
+++ pkg/depmixS4/man/depmix.Rd	2011-06-15 12:33:00 UTC (rev 461)
@@ -33,10 +33,10 @@
 \arguments{
 	
 	\item{response}{The response to be modeled; either a formula or a list 
-		of formulae in the multivariate case; this interfaces to the glm
-		distributions. See 'Details'.}
+		of formulae (in the multivariate case); this interfaces to the glm
+		and other distributions. See 'Details'.}
 	
-	\item{data}{An optional data.frame to interpret the variables in
+	\item{data}{An optional \code{data.frame} to interpret the variables in
 		the response and transition arguments.}
 	
 	\item{nstates}{The number of states of the model.}
@@ -67,8 +67,8 @@
 	\item{ntimes}{A vector specifying the lengths of individual, i.e.
 		independent, time series. If not specified, the responses are
 		assumed to form a single time series, i.e. \code{ntimes=nrow(data)}.
-		If the \code{data} argument has an attribute ntimes, then this 
-		is used.}
+		If the \code{data} argument has an attribute \code{ntimes}, then this 
+		is used. The first example in \code{\link{fit}} uses this argument.}
 		
 	\item{...}{Not used currently.}
 		
@@ -139,8 +139,7 @@
 		time-dependent or not; for internal use.}
 	
 	\item{ntimes}{A vector containing the lengths of independent time
-		series; if data is provided, sum(ntimes) must be equal to
-		nrow(data).}
+		series.}
 	
 	\item{nstates}{The number of states of the model.}
 	
@@ -187,8 +186,10 @@
 \examples{
 
 # create a 2 state model with one continuous and one binary response
-data(speed)
-mod <- depmix(list(rt~1,corr~1),data=speed,nstates=2,family=list(gaussian(),multinomial()))
+# ntimes is used to specify the lengths of 3 separate series
+data(speed)	
+mod <- depmix(list(rt~1,corr~1),data=speed,nstates=2,
+    family=list(gaussian(),multinomial("identity")),ntimes=c(168,134,137))
 # print the model, formulae and parameter values
 mod
 

Modified: pkg/depmixS4/man/depmix.fit.Rd
===================================================================
--- pkg/depmixS4/man/depmix.fit.Rd	2011-06-15 10:26:59 UTC (rev 460)
+++ pkg/depmixS4/man/depmix.fit.Rd	2011-06-15 12:33:00 UTC (rev 461)
@@ -164,6 +164,7 @@
 
 # 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

Modified: pkg/depmixS4/man/makeDepmix.Rd
===================================================================
--- pkg/depmixS4/man/makeDepmix.Rd	2011-06-15 10:26:59 UTC (rev 460)
+++ pkg/depmixS4/man/makeDepmix.Rd	2011-06-15 12:33:00 UTC (rev 461)
@@ -287,7 +287,7 @@
 instart=c(0.5,0.5)
 inMod <- transInit(~1,ns=2,ps=instart,data=data.frame(rep(1,3)))
 
-mod <- makeDepmix(response=rModels,transition=transition,prior=inMod,ntimes=attr(speed,"ntimes"),stat=FALSE)
+mod <- makeDepmix(response=rModels,transition=transition,prior=inMod,ntimes=c(168,134,137),stat=FALSE)
 
 fm3 <- fit(mod,emc=em.control(rand=FALSE))
 summary(fm3)

Modified: pkg/depmixS4/man/responses.Rd
===================================================================
--- pkg/depmixS4/man/responses.Rd	2011-06-15 10:26:59 UTC (rev 460)
+++ pkg/depmixS4/man/responses.Rd	2011-06-15 12:33:00 UTC (rev 461)
@@ -109,8 +109,7 @@
 	
 	# binomial response model
 	x <- rnorm(1000)
-	library(boot)
-	p <- inv.logit(x)
+	p <- plogis(x)
 	ss <- rbinom(1000,1,p)
 	mod <- GLMresponse(cbind(ss,1-ss)~x,family=binomial())
 	fit(mod)

Modified: pkg/depmixS4/man/speed.Rd
===================================================================
--- pkg/depmixS4/man/speed.Rd	2011-06-15 10:26:59 UTC (rev 460)
+++ pkg/depmixS4/man/speed.Rd	2011-06-15 12:33:00 UTC (rev 461)
@@ -17,7 +17,7 @@
 	pay-off for accurate responding, which is on a scale of zero to one.
 	The value of Pacc was varied during the experiment to induce the
 	switching.  This data set is a from participant A in experiment 
-	1a from Dutilh et al (2010). 
+	1a from Dutilh et al (2011). 
 	
 }
 
@@ -26,7 +26,7 @@
 \format{
   A data frame with 439 observations on the following 3 variables.
   \describe{
-	\item{\code{rt}}{a numeric vector of response times}
+	\item{\code{rt}}{a numeric vector of response times (log ms)}
 	\item{\code{corr}}{a numeric vector of accuracy scores (0/1)}
 	\item{\code{Pacc}}{a numeric vector of the pay-off for accuracy}
   }
@@ -34,12 +34,12 @@
 
 \source{
 	
-	Gilles Dutilh, Ingmar Visser, Eric-Jan Wagenmakers, & Han L. J. van der Maas.
-	A Phase Transition Model for the Speed-Accuracy Trade-Off in 
-	Response Time Experiments. \emph{2010, submitted for publication.}
-
-	Please contact g.dutilh at uva.nl for preprints and more information. 
+	Gilles Dutilh, Eric-Jan Wagenmakers, Ingmar Visser, & Han L. J. van der Maas (2011).
+	A phase transition model for the speed-accuracy trade-off in response time experiments.
+	\emph{Cognitive Science}, 35:211-250.
 	
+	Corresponding author: g.dutilh at uva.nl 
+	
 }
 
 \examples{

Modified: pkg/depmixS4/tests/test1speed.R
===================================================================
--- pkg/depmixS4/tests/test1speed.R	2011-06-15 10:26:59 UTC (rev 460)
+++ pkg/depmixS4/tests/test1speed.R	2011-06-15 12:33:00 UTC (rev 461)
@@ -28,7 +28,7 @@
 instart=c(0,1)
 inMod <- transInit(~1,ns=2,ps=instart,data=data.frame(rep(1,3)))
 
-mod <- makeDepmix(response=rModels,transition=transition,prior=inMod,ntimes=attr(speed,"ntimes"))
+mod <- makeDepmix(response=rModels,transition=transition,prior=inMod,ntimes=c(168,134,137))
 
 ll <- logLik(mod)
 ll.fb <- logLik(mod,method="fb")
@@ -47,7 +47,7 @@
 resp <- c(5.52,0.202,0.472,0.528,6.39,0.24,0.098,0.902)
 trstart=c(0.899,0.101,0.084,0.916)
 instart=c(0,1)
-mod <- depmix(list(rt~1,corr~1),data=speed,nstates=2,family=list(gaussian(),multinomial()),respstart=resp,trstart=trstart,instart=instart,prob=T)
+mod <- depmix(list(rt~1,corr~1),data=speed,nstates=2,family=list(gaussian(),multinomial()),respstart=resp,trstart=trstart,instart=instart,prob=T,ntimes=c(168,134,137))
 
 ll2 <- logLik(mod)
 
@@ -68,7 +68,7 @@
 p1 <- invlogit(coef(acc)[1])
 p0 <- 1-p1
 
-mod <- depmix(corr~1,data=speed,nst=1,family=multinomial(),trstart=1,instart=c(1),respstart=c(p0,p1))
+mod <- depmix(corr~1,data=speed,nst=1,family=multinomial(),trstart=1,instart=c(1),respstart=c(p0,p1),ntimes=c(168,134,137))
 
 ll <- logLik(mod)
 
@@ -90,7 +90,7 @@
 
 pstart=c(p0,p1,0,coef(acc)[2])
 
-mod <- depmix(corr~Pacc,data=speed,family=multinomial(),trstart=1,instart=1,respst=pstart,nstate=1)
+mod <- depmix(corr~Pacc,data=speed,family=multinomial(),trstart=1,instart=1,respst=pstart,nstate=1,ntimes=c(168,134,137))
 
 ll <- logLik(mod)
 dev <- -2*ll
@@ -106,7 +106,7 @@
 instart=c(0,1)
 resp <- c(5.52,0.202,0.472,0.528,6.39,0.24,0.098,0.902)
 
-mod <- depmix(list(rt~1,corr~1),data=speed,family=list(gaussian(),multinomial()),transition=~Pacc,trstart=trstart,instart=instart,respst=resp,nst=2)
+mod <- depmix(list(rt~1,corr~1),data=speed,family=list(gaussian(),multinomial()),transition=~Pacc,trstart=trstart,instart=instart,respst=resp,nst=2,ntimes=c(168,134,137))
 ll <- logLik(mod)
 
 cat("Test 4: ll is now larger than speedll, ie ll is better due to introduction of a covariate \n")

Modified: pkg/depmixS4/tests/test1speed.Rout.save
===================================================================
--- pkg/depmixS4/tests/test1speed.Rout.save	2011-06-15 10:26:59 UTC (rev 460)
+++ pkg/depmixS4/tests/test1speed.Rout.save	2011-06-15 12:33:00 UTC (rev 461)
@@ -47,7 +47,7 @@
 > instart=c(0,1)
 > inMod <- transInit(~1,ns=2,ps=instart,data=data.frame(rep(1,3)))
 > 
-> mod <- makeDepmix(response=rModels,transition=transition,prior=inMod,ntimes=attr(speed,"ntimes"))
+> mod <- makeDepmix(response=rModels,transition=transition,prior=inMod,ntimes=c(168,134,137))
 > 
 > ll <- logLik(mod)
 > ll.fb <- logLik(mod,method="fb")
@@ -67,7 +67,7 @@
 > resp <- c(5.52,0.202,0.472,0.528,6.39,0.24,0.098,0.902)
 > trstart=c(0.899,0.101,0.084,0.916)
 > instart=c(0,1)
-> mod <- depmix(list(rt~1,corr~1),data=speed,nstates=2,family=list(gaussian(),multinomial()),respstart=resp,trstart=trstart,instart=instart,prob=T)
+> mod <- depmix(list(rt~1,corr~1),data=speed,nstates=2,family=list(gaussian(),multinomial()),respstart=resp,trstart=trstart,instart=instart,prob=T,ntimes=c(168,134,137))
 > 
 > ll2 <- logLik(mod)
 > 
@@ -89,7 +89,7 @@
 > p1 <- invlogit(coef(acc)[1])
 > p0 <- 1-p1
 > 
-> mod <- depmix(corr~1,data=speed,nst=1,family=multinomial(),trstart=1,instart=c(1),respstart=c(p0,p1))
+> mod <- depmix(corr~1,data=speed,nst=1,family=multinomial(),trstart=1,instart=c(1),respstart=c(p0,p1),ntimes=c(168,134,137))
 > 
 > ll <- logLik(mod)
 > 
@@ -112,7 +112,7 @@
 > 
 > pstart=c(p0,p1,0,coef(acc)[2])
 > 
-> mod <- depmix(corr~Pacc,data=speed,family=multinomial(),trstart=1,instart=1,respst=pstart,nstate=1)
+> mod <- depmix(corr~Pacc,data=speed,family=multinomial(),trstart=1,instart=1,respst=pstart,nstate=1,ntimes=c(168,134,137))
 > 
 > ll <- logLik(mod)
 > dev <- -2*ll
@@ -129,7 +129,7 @@
 > instart=c(0,1)
 > resp <- c(5.52,0.202,0.472,0.528,6.39,0.24,0.098,0.902)
 > 
-> mod <- depmix(list(rt~1,corr~1),data=speed,family=list(gaussian(),multinomial()),transition=~Pacc,trstart=trstart,instart=instart,respst=resp,nst=2)
+> mod <- depmix(list(rt~1,corr~1),data=speed,family=list(gaussian(),multinomial()),transition=~Pacc,trstart=trstart,instart=instart,respst=resp,nst=2,ntimes=c(168,134,137))
 > ll <- logLik(mod)
 > 
 > cat("Test 4: ll is now larger than speedll, ie ll is better due to introduction of a covariate \n")

Modified: pkg/depmixS4/tests/test2getsetpars.R
===================================================================
--- pkg/depmixS4/tests/test2getsetpars.R	2011-06-15 10:26:59 UTC (rev 460)
+++ pkg/depmixS4/tests/test2getsetpars.R	2011-06-15 12:33:00 UTC (rev 461)
@@ -11,7 +11,7 @@
 instart=c(0,1)
 resp <- c(5.52,0.202,0.472,0.528,6.39,0.24,0.098,0.902)
 
-mod <- depmix(list(rt~1,corr~1),data=speed,family=list(gaussian(),multinomial()),transition=~Pacc,trstart=trstart,instart=instart,respst=resp,nst=2)
+mod <- depmix(list(rt~1,corr~1),data=speed,family=list(gaussian(),multinomial()),transition=~Pacc,trstart=trstart,instart=instart,respst=resp,nst=2,ntimes=c(168,134,137))
 
 mod1 <- setpars(mod,getpars(mod))
 

Modified: pkg/depmixS4/tests/test2getsetpars.Rout.save
===================================================================
--- pkg/depmixS4/tests/test2getsetpars.Rout.save	2011-06-15 10:26:59 UTC (rev 460)
+++ pkg/depmixS4/tests/test2getsetpars.Rout.save	2011-06-15 12:33:00 UTC (rev 461)
@@ -30,7 +30,7 @@
 > instart=c(0,1)
 > resp <- c(5.52,0.202,0.472,0.528,6.39,0.24,0.098,0.902)
 > 
-> mod <- depmix(list(rt~1,corr~1),data=speed,family=list(gaussian(),multinomial()),transition=~Pacc,trstart=trstart,instart=instart,respst=resp,nst=2)
+> mod <- depmix(list(rt~1,corr~1),data=speed,family=list(gaussian(),multinomial()),transition=~Pacc,trstart=trstart,instart=instart,respst=resp,nst=2,ntimes=c(168,134,137))
 > 
 > mod1 <- setpars(mod,getpars(mod))
 > 



More information about the depmix-commits mailing list