[Depmix-commits] r591 - pkg/depmixS4/man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Sep 17 09:28:08 CEST 2013


Author: ingmarvisser
Date: 2013-09-17 09:28:08 +0200 (Tue, 17 Sep 2013)
New Revision: 591

Modified:
   pkg/depmixS4/man/depmix.Rd
   pkg/depmixS4/man/depmix.fit.Rd
   pkg/depmixS4/man/em.control.Rd
   pkg/depmixS4/man/makeDepmix.Rd
   pkg/depmixS4/man/responses.Rd
Log:
Reduced line lengths to 100 characters.

Modified: pkg/depmixS4/man/depmix.Rd
===================================================================
--- pkg/depmixS4/man/depmix.Rd	2013-09-13 15:05:47 UTC (rev 590)
+++ pkg/depmixS4/man/depmix.Rd	2013-09-17 07:28:08 UTC (rev 591)
@@ -220,8 +220,8 @@
 # plot the BICs to select the proper model
 plot(1:3,c(BIC(fm1),BIC(fm2),BIC(fm3)),ty="b")
 
-# similar to the binomial model, data may also be entered in multi-column format where the n for each
-# row can be different
+# similar to the binomial model, data may also be entered in 
+# multi-column format where the n for each row can be different
 dt <- data.frame(y1=c(0,1,1,2,4,5),y2=c(1,0,1,0,1,0),y3=c(4,4,3,2,1,1))
 # specify a mixture model ...
 m2 <- mix(cbind(y1,y2,y3)~1,data=dt,ns=2,family=multinomial("identity"))
@@ -244,7 +244,8 @@
 fm2 <- fit(mod)	
 
 # plot posterior state sequence for the 2-state model
-plot(as.ts(posterior(fm2)[,2]),ylab="probability",main="Posterior probability of state 1 (volatile, negative markets).")
+plot(as.ts(posterior(fm2)[,2]),ylab="probability",
+main="Posterior probability of state 1 (volatile, negative markets).")
 
 # using "hard" assignment of observations to the states, we can maximise the
 # classification likelihood instead of the usual marginal likelihood

Modified: pkg/depmixS4/man/depmix.fit.Rd
===================================================================
--- pkg/depmixS4/man/depmix.fit.Rd	2013-09-13 15:05:47 UTC (rev 590)
+++ pkg/depmixS4/man/depmix.fit.Rd	2013-09-17 07:28:08 UTC (rev 591)
@@ -26,7 +26,8 @@
 \usage{
 	
 	\S4method{fit}{depmix}(object, fixed=NULL, equal=NULL, conrows=NULL,
-		conrows.upper=0, conrows.lower=0, method=NULL, emcontrol=em.control(), verbose=TRUE,...)
+		conrows.upper=0, conrows.lower=0, method=NULL, emcontrol=em.control(), 
+		verbose=TRUE,...)
 	
 	\S4method{summary}{depmix.fitted}(object,which="all")
 
@@ -34,7 +35,8 @@
 		conrows=NULL, conrows.upper=0, conrows.lower=0, 
 		method=NULL, verbose=TRUE,
 		emcontrol=em.control(),
-		solnpcntrl=list(rho = 1, outer.iter = 400, inner.iter = 800, delta = 1e-7, tol = 1e-8),
+		solnpcntrl=list(rho = 1, outer.iter = 400, inner.iter = 800, 
+		delta = 1e-7, tol = 1e-8),
 		donlpcntrl=donlp2Control(),
 		...)
 	
@@ -268,14 +270,16 @@
 data(balance)
 # four binary items on the balance scale task
 mod4 <- mix(list(d1~1,d2~1,d3~1,d4~1), data=balance, nstates=2,
-	family=list(multinomial("identity"),multinomial("identity"),multinomial("identity"),multinomial("identity")))
+	family=list(multinomial("identity"),multinomial("identity"),
+	multinomial("identity"),multinomial("identity")))
 
 set.seed(1)
 fmod4 <- fit(mod4)
 
 # add age as covariate on class membership by using the prior argument
 mod5 <- mix(list(d1~1,d2~1,d3~1,d4~1), data=balance, nstates=2,
-	family=list(multinomial("identity"),multinomial("identity"),multinomial("identity"),multinomial("identity")),
+	family=list(multinomial("identity"),multinomial("identity"),
+	multinomial("identity"),multinomial("identity")),
 	prior=~age, initdata=balance)
 
 set.seed(1)

Modified: pkg/depmixS4/man/em.control.Rd
===================================================================
--- pkg/depmixS4/man/em.control.Rd	2013-09-13 15:05:47 UTC (rev 590)
+++ pkg/depmixS4/man/em.control.Rd	2013-09-17 07:28:08 UTC (rev 591)
@@ -8,7 +8,8 @@
 
 \usage{
 	
-	em.control(maxit = 500, tol = 1e-08, crit = c("relative","absolute"), random.start = TRUE, classification = c("soft","hard"))
+	em.control(maxit = 500, tol = 1e-08, crit = c("relative","absolute"), 
+	random.start = TRUE, classification = c("soft","hard"))
 	
 }
 
@@ -40,7 +41,8 @@
 \eqn{i}{i} when \eqn{\log L(i) - \log L(i-1) < tol}{(log L(i) - log L(i-1)) < tol}.  
 Use \code{crit="absolute"} to invoke the latter
 convergence criterion.  Note that in that case, optimal values of the 
-tolerance parameter \code{tol} scale with the value of the log-likelihood (and these are not changed automagically). 
+tolerance parameter \code{tol} scale with the value of the log-likelihood
+(and these are not changed automagically). 
 
 Argument \code{random.start} This is used for a (limited) random
 initialization of the parameters.  In particular, if

Modified: pkg/depmixS4/man/makeDepmix.Rd
===================================================================
--- pkg/depmixS4/man/makeDepmix.Rd	2013-09-13 15:05:47 UTC (rev 590)
+++ pkg/depmixS4/man/makeDepmix.Rd	2013-09-17 07:28:08 UTC (rev 591)
@@ -119,7 +119,8 @@
 transition[[2]] <- transInit(~Pacc,nstates=2,data=speed)
 
 inMod <- transInit(~1,ns=2,data=data.frame(rep(1,3)),family=multinomial("identity"))
-mod <- makeDepmix(response=rModels,transition=transition,prior=inMod,ntimes=c(168,134,137),homogeneous=FALSE)
+mod <- makeDepmix(response=rModels,transition=transition,prior=inMod,
+ntimes=c(168,134,137),homogeneous=FALSE)
 
 set.seed(3)
 fm1 <- fit(mod)
@@ -213,7 +214,8 @@
 
 setMethod("dens","exgaus",
     function(object,log=FALSE) {
-        dexGAUS(object at y, mu = predict(object), sigma = exp(object at parameters$sigma), nu = exp(object at parameters$nu), log = log)
+        dexGAUS(object at y, mu = predict(object), 
+				sigma = exp(object at parameters$sigma), nu = exp(object at parameters$nu), log = log)
     }
 )
 
@@ -295,7 +297,8 @@
 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=c(168,134,137),homogeneous=FALSE)
+mod <- makeDepmix(response=rModels,transition=transition,prior=inMod,ntimes=c(168,134,137), 
+homogeneous=FALSE)
 
 fm3 <- fit(mod,emc=em.control(rand=FALSE))
 summary(fm3,compact=FALSE)

Modified: pkg/depmixS4/man/responses.Rd
===================================================================
--- pkg/depmixS4/man/responses.Rd	2013-09-13 15:05:47 UTC (rev 590)
+++ pkg/depmixS4/man/responses.Rd	2013-09-17 07:28:08 UTC (rev 591)
@@ -107,77 +107,79 @@
 
 \examples{
 	
-	# binomial response model
-	x <- rnorm(1000)
-	p <- plogis(x)
-	ss <- rbinom(1000,1,p)
-	mod <- GLMresponse(cbind(ss,1-ss)~x,family=binomial())
-	fit(mod)
-	glm(cbind(ss,1-ss)~x, family=binomial)
-	
-	# gamma response model
-	x=runif(1000,1,5)
-	res <- rgamma(1000,x)
-	## note that gamma needs proper starting values which are not
-	## provided by depmixS4 (even with them, this may produce warnings)
-	mod <- GLMresponse(res~x,family=Gamma(),pst=c(0.8,1/0.8))
-	fit(mod)
-	glm(res~x,family=Gamma)
-	
-	# multinomial response model
-	x <- sample(0:1,1000,rep=TRUE)
-	mod <- GLMresponse(sample(1:3,1000,rep=TRUE)~x,family=multinomial(),pstart=c(0.33,0.33,0.33,0,0,1))
-	mod at y <- simulate(mod)
-	fit(mod)
-	colSums(mod at y[which(x==0),])/length(which(x==0))
-	colSums(mod at y[which(x==1),])/length(which(x==1))
-	# note that the response is treated as factor here, internal representation is in dummy coded format:
-	head(mod at y)
-	# similar to the binomial model, data may also be entered in multi-column format where the n for each
-	# row can be different
-	dt <- data.frame(y1=c(0,1,1,2,4,5),y2=c(1,0,1,0,1,0),y3=c(4,4,3,2,1,1))
-	m2 <- mix(cbind(y1,y2,y3)~1,data=dt,ns=2,family=multinomial("identity"))
-	fm2 <- fit(m2)
-	summary(fm2)
-	
-	# multivariate normal response model
-	mn <- c(1,2,3)
-	sig <- matrix(c(1,.5,0,.5,1,0,0,0,2),3,3)
-	y <- mvrnorm(1000,mn,sig)
-	mod <- MVNresponse(y~1)
-	fit(mod)
-	colMeans(y)
-	var(y)
-	
-	# normal (gaussian) response model
-	y <- rnorm(1000)
-	mod <- GLMresponse(y~1)
-	fm <- fit(mod)
-	cat("Test gaussian fit: ", all.equal(getpars(fm),c(mean(y),sd(y)),check=FALSE))
-	
-	# poisson response model
-	x <- abs(rnorm(1000,2))
-	res <- rpois(1000,x)
-	mod <- GLMresponse(res~x,family=poisson())
-	fit(mod)
-	glm(res~x, family=poisson)
-	
-	# this creates data with a single change point with Poisson distributed data
-	set.seed(3)
-	y1 <- rpois(50,1)
-	y2 <- rpois(50,2)
-	ydf <- data.frame(y=c(y1,y2))
-	
-	# fit models with 1 to 3 states
-	m1 <- depmix(y~1,ns=1,family=poisson(),data=ydf)
-	fm1 <- fit(m1)
-	m2 <- depmix(y~1,ns=2,family=poisson(),data=ydf)
-	fm2 <- fit(m2)
-	m3 <- depmix(y~1,ns=3,family=poisson(),data=ydf)
-	fm3 <- fit(m3,em=em.control(maxit=500))
-	
-	# plot the BICs to select the proper model
-	plot(1:3,c(BIC(fm1),BIC(fm2),BIC(fm3)),ty="b")
+# binomial response model
+x <- rnorm(1000)
+p <- plogis(x)
+ss <- rbinom(1000,1,p)
+mod <- GLMresponse(cbind(ss,1-ss)~x,family=binomial())
+fit(mod)
+glm(cbind(ss,1-ss)~x, family=binomial)
+
+# gamma response model
+x=runif(1000,1,5)
+res <- rgamma(1000,x)
+## note that gamma needs proper starting values which are not
+## provided by depmixS4 (even with them, this may produce warnings)
+mod <- GLMresponse(res~x,family=Gamma(),pst=c(0.8,1/0.8))
+fit(mod)
+glm(res~x,family=Gamma)
+
+# multinomial response model
+x <- sample(0:1,1000,rep=TRUE)
+mod <- GLMresponse(sample(1:3,1000,rep=TRUE)~x,family=multinomial(),pstart=c(0.33,0.33,0.33,0,0,1))
+mod at y <- simulate(mod)
+fit(mod)
+colSums(mod at y[which(x==0),])/length(which(x==0))
+colSums(mod at y[which(x==1),])/length(which(x==1))
+# note that the response is treated as factor here, internal representation is in 
+# dummy coded format:
+head(mod at y)
+# similar to the binomial model, data may also be entered in multi-column format 
+# where the n for each row can be different
+dt <- data.frame(y1=c(0,1,1,2,4,5),y2=c(1,0,1,0,1,0),y3=c(4,4,3,2,1,1))
+m2 <- mix(cbind(y1,y2,y3)~1,data=dt,ns=2,family=multinomial("identity"))
+fm2 <- fit(m2)
+summary(fm2)
+
+# multivariate normal response model
+mn <- c(1,2,3)
+sig <- matrix(c(1,.5,0,.5,1,0,0,0,2),3,3)
+y <- mvrnorm(1000,mn,sig)
+mod <- MVNresponse(y~1)
+fit(mod)
+colMeans(y)
+var(y)
+
+# normal (gaussian) response model
+y <- rnorm(1000)
+mod <- GLMresponse(y~1)
+fm <- fit(mod)
+cat("Test gaussian fit: ", all.equal(getpars(fm),c(mean(y),sd(y)),check=FALSE))
+
+# poisson response model
+x <- abs(rnorm(1000,2))
+res <- rpois(1000,x)
+mod <- GLMresponse(res~x,family=poisson())
+fit(mod)
+glm(res~x, family=poisson)
+
+# this creates data with a single change point with Poisson distributed data
+set.seed(3)
+y1 <- rpois(50,1)
+y2 <- rpois(50,2)
+ydf <- data.frame(y=c(y1,y2))
+
+# fit models with 1 to 3 states
+m1 <- depmix(y~1,ns=1,family=poisson(),data=ydf)
+fm1 <- fit(m1)
+m2 <- depmix(y~1,ns=2,family=poisson(),data=ydf)
+fm2 <- fit(m2)
+m3 <- depmix(y~1,ns=3,family=poisson(),data=ydf)
+fm3 <- fit(m3,em=em.control(maxit=500))
+
+# plot the BICs to select the proper model
+plot(1:3,c(BIC(fm1),BIC(fm2),BIC(fm3)),ty="b")
+
 }
 	
 \author{Maarten Speekenbrink & Ingmar Visser}



More information about the depmix-commits mailing list