[Depmix-commits] r109 - in trunk: . man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Mar 23 16:18:12 CET 2008


Author: ingmarvisser
Date: 2008-03-23 16:18:12 +0100 (Sun, 23 Mar 2008)
New Revision: 109

Added:
   trunk/man/
   trunk/man/balance.Rd
   trunk/man/depmix-class.Rd
   trunk/man/depmix-internal.Rd
   trunk/man/depmix.Rd
   trunk/man/depmix.fit.Rd
   trunk/man/depmix.fitted-class.Rd
   trunk/man/llratio.Rd
   trunk/man/response-class.Rd
   trunk/man/response-classes.Rd
   trunk/man/response.Rd
   trunk/man/speed.Rd
Log:
Fighting with svn

Added: trunk/man/balance.Rd
===================================================================
--- trunk/man/balance.Rd	                        (rev 0)
+++ trunk/man/balance.Rd	2008-03-23 15:18:12 UTC (rev 109)
@@ -0,0 +1,24 @@
+\name{balance}
+
+\docType{data}
+
+\alias{balance}
+
+\title{Balance Scale Data}
+
+\description{Balance scale data of four distance items from 779 subjects;
+participants' ages are included.}
+
+\usage{data(balance)}
+
+\format{Data.frame.}
+
+\source{
+
+	Brenda Jansen (2001),\emph{Development of reasoning on the balance
+	scale task: Psychometric assessment of cognitive strategies}.  PhD
+	thesis, University of Amsterdam, Department of Psychology.
+
+}
+
+\keyword{datasets}

Added: trunk/man/depmix-class.Rd
===================================================================
--- trunk/man/depmix-class.Rd	                        (rev 0)
+++ trunk/man/depmix-class.Rd	2008-03-23 15:18:12 UTC (rev 109)
@@ -0,0 +1,69 @@
+\name{depmix-class}
+
+\docType{class}
+
+\alias{depmix-class}
+
+\alias{nresp}
+\alias{nresp,depmix-method}
+
+\alias{ntimes}
+\alias{ntimes,depmix-method}
+
+\title{Class "depmix"}
+
+\description{A \code{\link{depmix}} model.}
+
+\section{Slots}{
+
+	\describe{
+
+	\item{\code{response}:}{List of list of \code{response} objects.}
+
+	\item{\code{transition}}{List of \code{\link{transInit}} objects.}
+	
+	\item{\code{prior}:}{\code{\link{transInit}} object.}
+	
+	\item{\code{dens}:}{Array of dimension sum(ntimes)*nresp*nstates
+		providing the densities of the observed responses for each state.}
+	
+	\item{\code{trDens}:}{Array of dimension \code{sum(ntimes)}*nstates
+		providing the probability of a state transition depending on the
+		predictors.}
+	
+	\item{\code{init}:}{Array of dimension \code{length(ntimes)}*nstates with 
+		the current predictions for the initial state probabilities.}
+	
+	\item{\code{stationary}:}{Logical indicating whether the transitions are
+		time-dependent or not; for internal use.}
+	
+	\item{\code{ntimes}:}{A vector containing the lengths of independent time
+		series; if data is provided, sum(ntimes) must be equal to
+		nrow(data).}
+
+	\item{\code{nstates}:}{The number of states of the model.}
+
+	\item{\code{nresp}:}{The number of independent responses.}
+
+	\item{\code{npars}:}{The total number of parameters of the model. This is not
+		the degrees of freedom, ie there are redundancies in the
+		parameters, in particular in the multinomial models for the
+		transitions and prior.}
+
+	}
+}
+
+\section{Accessor Functions}{
+	The following functions should be used for accessing the corresponding
+	slots:
+	\describe{
+		\item{\code{npar}:}{The number of parameters of the model.}
+		\item{\code{nresp}:}{The number of responses.}
+		\item{\code{nstates}:}{The number of states.}
+		\item{\code{ntimes}:}{The vector of independent time series lengths.}
+	}
+}
+
+\author{Ingmar Visser}
+
+\keyword{classes}


Property changes on: trunk/man/depmix-class.Rd
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/man/depmix-internal.Rd
===================================================================
--- trunk/man/depmix-internal.Rd	                        (rev 0)
+++ trunk/man/depmix-internal.Rd	2008-03-23 15:18:12 UTC (rev 109)
@@ -0,0 +1,59 @@
+\name{depmix-internal}
+
+\alias{dens}
+\alias{em}
+\alias{fb}
+\alias{logDens}
+\alias{lystig}
+
+\alias{makeDepmix}
+\alias{makePriorModel}
+\alias{makeResponseModels}
+\alias{makeTransModels}
+
+\alias{mlogit}
+\alias{multinomial}
+\alias{nstates}
+\alias{pa2conr}
+\alias{viterbi}
+\alias{viterbi.fb}
+
+\alias{dens,GLMresponse-method}
+\alias{dens,BINOMresponse-method}
+\alias{dens,NORMresponse-method}
+\alias{dens,MULTINOMresponse-method}
+\alias{dens,transInit-method}
+
+\alias{fit,GLMresponse-method}
+\alias{fit,BINOMresponse-method}
+\alias{fit,NORMresponse-method}w
+\alias{fit,MULTINOMresponse-method}
+\alias{fit,MVNresponse-method}
+\alias{fit,transInit-method}
+
+\alias{logLik,GLMresponse-method}
+
+\alias{predict,GLMresponse-method}
+\alias{predict,BINOMresponse-method}
+\alias{predict,NORMresponse-method}
+\alias{predict,MULTINOMresponse-method}
+\alias{predict,transInit-method}
+
+\alias{getpars,GLMresponse-method}
+\alias{setpars,GLMresponse-method}
+
+\alias{npar,response-method}
+
+\title{Depmix internal functions}
+
+\description{
+  Internal depmix functions, methods and classes.
+}
+
+\details{
+  These are not to be called by the user.
+}
+
+\author{Ingmar Visser}
+
+\keyword{methods}


Property changes on: trunk/man/depmix-internal.Rd
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/man/depmix.Rd
===================================================================
--- trunk/man/depmix.Rd	                        (rev 0)
+++ trunk/man/depmix.Rd	2008-03-23 15:18:12 UTC (rev 109)
@@ -0,0 +1,235 @@
+
+\name{depmix}
+
+\docType{methods}
+
+\alias{depmixS4}
+\alias{depmix}
+\alias{depmix,ANY-method}
+
+\alias{logLik}
+\alias{logLik,depmix-method}
+
+\alias{AIC}
+\alias{AIC,depmix-method}
+
+\alias{BIC}
+\alias{BIC,depmix-method}
+
+\alias{nobs}
+\alias{nobs,depmix-method}
+
+\alias{npar}
+\alias{npar,depmix-method}
+
+\alias{freepars}
+\alias{freepars,depmix-method}
+
+\alias{setpars}
+\alias{setpars,depmix-method}
+
+\alias{getpars}
+\alias{getpars,depmix-method}
+
+\alias{show,depmix-method}
+\alias{summary,depmix-method}
+
+\title{Dependent Mixture Model Specifiction}
+
+\description{
+		
+	depmixS4 is a framework for specifying and fitting dependent mixture
+	models, otherwise known as hidden or latent Markov models.
+	Optimization is done with the EM algorithm or optionally with Rdonlp2
+	when constraints on parameters are imposed.  Models for different
+	distributions can easily be added.
+	
+	\code{depmix} creates an object of class \code{depmix}, a
+	dependent mixture model, otherwise known as hidden Markov 
+	model.
+	
+}
+
+\usage{
+	
+	depmix(response, data=NULL, nstates, transition=~1, family=gaussian(), 
+		prior=~1, initdata=NULL, respstart=NULL, trstart=NULL, instart=NULL,
+		ntimes=NULL,...)
+	
+	\S4method{summary}{depmix}(object)
+	\S4method{logLik}{depmix}(object)
+	\S4method{AIC}{depmix}(object)
+	\S4method{BIC}{depmix}(object)
+	\S4method{nobs}{depmix}(object)
+	
+	\S4method{npar}{depmix}(object)
+	\S4method{freepars}{depmix}(object)
+	\S4method{setpars}{depmix}(object,which="pars",...)
+	\S4method{getpars}{depmix}(object,which="pars",...)	
+	
+}
+
+\arguments{
+	\item{object}{An object with class \code{depmix}.}
+	
+	\item{response}{The response to be modeled; either a formula or a list 
+		of formulae in the multivariate case. See details.}
+	
+	\item{data}{An optional data.frame to interpret the variables in
+		response and transition.}
+	
+	\item{nstates}{The number of states of the model.}
+
+	\item{transition}{A one-sided formula specifying the model for the 
+		transitions. See details.}
+	
+	\item{family}{A family argument for the response. This must be a list
+		of family's if the response is multivariate.}
+	
+	\item{prior}{A one-sided formula specifying the density for the prior
+		or initial state probabilities.}
+	
+	\item{initdata}{An optional data.frame to interpret the variables
+		occuring in prior. The number of rows of this data.frame must be
+		equal to the number of cases being modeled. See details.}
+	
+	\item{respstart}{Starting values for the parameters of the response
+		models.}
+	
+	\item{trstart}{Starting values for the parameters of the transition
+		models.}
+	
+	\item{instart}{Starting values for the parameters of the prior or
+		initial state probability model.}
+
+	\item{ntimes}{A vector specifying the lengths of individual, ie
+		independent, time series. If not specified, the responses are
+		assumed to form a single time series. If the data argument has an
+		attribute ntimes, then this is used.}
+	
+	\item{which}{The default "pars" returns a vector of all parameters of a
+		\code{depmix} object; the alternative value "fixed" return a
+		logical vector of the same length indicating which parameters are
+		fixed. The setpars functions sets parameters (or the logical fixed 
+		vector) to new values; \code{setpars} also recomputes the dens,
+		trans and init slots of \code{depmix} objects. Note that the 
+		\code{getpars} and \code{setpars} functions for \code{depmix} 
+		objects simply call the functions of the same name for the response
+		and transition models.}
+		
+	\item{...}{Not used currently.}
+	
+}
+
+\details{ 
+
+	The function \code{depmix} creates an S4 object of class \code{depmix},
+	which needs to be fitted using \code{\link[depmixS4]{depmix.fit}} to
+	optimize the parameters.
+	
+	The response model(s) are created by call(s) to
+	\code{\link[depmixS4]{response}} providing the family and optional
+	predictors.  If response is a list of formulae, the response's are
+	assumed to be independent conditional on the latent state.
+	
+	The transitions are modeled as a multinomial logistic model for each
+	state.  Hence, the transition matrix can be modeled as time-dependent,
+	depending on predictors.  The prior density is also modeled as a
+	multinomial logistic.  Both are created by calls to
+	\code{\link[depmixS4]{transInit}}.
+	
+	Starting values may be provided by the respective arguments.  The order
+	in which parameters must be provided can be easily studied by using the
+	\code{setpars} function (see example).
+	
+	Linear constraints on parameters can be provided as argument to the
+	\code{\link[depmixS4]{depmix.fit}} function.
+	
+}
+
+\value{
+	
+\code{depmix} returns an object of class \code{depmix} which has the
+following slots:
+
+	\item{response}{A list of a list of response models; the first
+		index runs over states; the second index runs over the independent 
+		responses in case a multivariate response is provided.}
+	
+	\item{transition}{A list of \code{transInit} models, ie multinomial
+		logistic models with length the number of states.}
+
+	\item{prior}{A multinomial logistic model for the initial state
+		probabilities.}
+
+	\item{dens,trDens,init}{See depmix-class help for details. For internal
+		use.}
+	
+	\item{stationary}{Logical indicating whether the transitions are
+		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).}
+	
+	\item{nstates}{The number of states of the model.}
+	
+	\item{nresp}{The number of independent responses.}
+
+	\item{npars}{The total number of parameters of the model. This is not
+		the degrees of freedom, ie there are redundancies in the
+		parameters, in particular in the multinomial models for the
+		transitions and prior.}
+
+\code{logLik}, \code{AIC}, and \code{BIC} return the respective values
+associated with the current parameter values.  \code{nobs} returns the
+number of observations, ie \code{sum(ntimes)} that is used in computing the
+\code{BIC}.  \code{npar} returns the number of paramters of a model;
+\code{freepars} returns the number of non-fixed parameters.
+
+}
+
+\author{Ingmar Visser \email{i.visser at uva.nl}} 
+
+\seealso{
+
+	\code{\link[depmixS4]{depmix.fit}}, \code{\link{transInit}},
+	\code{\link{response}}.
+
+}
+
+\references{
+	
+	On hidden Markov models: Lawrence R. Rabiner (1989).  A tutorial on
+	hidden Markov models and selected applications in speech recognition.
+	\emph{Proceedings of IEEE}, 77-2, p.  267-295.
+	
+	On latent class models: A. L. McCutcheon (1987).  \emph{Latent class
+	analysis}.  Sage Publications.
+	
+}
+
+\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()))
+# print the model, formulae and parameter values
+mod
+
+# to see the ordering of parameters to use in setpars
+mod <- setpars(mod, value=1:npar(mod))
+mod
+
+# to see which parameters are fixed (by default only baseline parameters in
+# the multinomial logistic models for the transition models and the initial
+# state probabilities model
+mod <- setpars(mod, getpars(mod,which="fixed"))
+mod
+
+
+}
+
+\keyword{methods}
+
+


Property changes on: trunk/man/depmix.Rd
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/man/depmix.fit.Rd
===================================================================
--- trunk/man/depmix.fit.Rd	                        (rev 0)
+++ trunk/man/depmix.fit.Rd	2008-03-23 15:18:12 UTC (rev 109)
@@ -0,0 +1,165 @@
+\name{fit}
+
+\docType{method}
+
+\alias{fit}
+\alias{depmix.fit}
+\alias{fit,depmix-method}
+
+\alias{posterior}
+\alias{posterior,depmix.fitted-method}
+
+\alias{show,depmix.fitted-method}
+\alias{summary,depmix.fitted-method}
+
+\title{Fit depmix models}
+
+\description{
+
+	\code{fit} optimizes parameters of \code{\link{depmix}} models, optionally
+	subject to general linear (in)equality constraints.}
+
+\usage{
+	
+	\S4method{fit}{depmix}(object, fixed=NULL, equal=NULL, conrows=NULL,
+		conrows.upper=0, conrows.lower=0, method=NULL,...)
+	
+	\S4method{posterior}{depmix.fitted}(object,...)
+	\S4method{summary}{depmix.fitted}(object)
+	
+}
+
+\arguments{
+
+	\item{object}{An object of class \code{depmix}.}
+	
+	\item{fixed}{Vector of mode logical indicating which parameters should 
+		be fixed.}
+
+	\item{equal}{Vector indicating equality constraints; see details.}
+
+	\item{conrows}{Rows of a general linear constraint matrix; see details.}
+
+	\item{conrows.upper, conrows.lower}{Upper and lower bounds for the
+		linear constraints; see details.}
+
+	\item{method}{The optimization method; mostly determined by
+		constraints.}
+
+	\item{...}{Further arguments passed on to the optimization methods.}
+
+}
+
+\details{
+	The method fits depmix models by the EM algorithm if there are no
+	linear constraints on the parameters and if the transition model has
+	no covariates. Otherwise the general optimizer donlp is used which 
+	handles general linear (in-)equality constraints. 
+	
+	Three types of constraints can be specified on the parameters: fixed,
+	equality, and general constraints. Constraint vectors should be of
+	length npar(object). See help on getpars and setpars about the
+	ordering of parameters. 
+	
+	The \code{equal} argument is used to specify equality constraints:
+	parameters that get the same integer number in this vector are
+	estimated to be equal. Any integers can be used in the vector except 0
+	and 1, which indicate fixed and free parameters respectively. 
+
+	Using the donlp optimizer a Newton-Raphson scheme is employed to
+	estimate parameters subject to linear constraints by imposing: 
+	
+			bl <= A*x <= bu,
+	
+	where x is the parameter vector, bl is a vector of lower bounds, bu
+	is a vector of upper bounds, and A is the constraint matrix. 
+
+	The \code{conrows} argument is used to specify rows of A directly, and 
+	the conrows.lower and conrows.upper arguments to specify the bounds on 
+	the constraints. \code{conrows} is a matrix of npar(object) columns and
+	one row for each constraint (ie a vector in the case of a single
+	constraint). 
+	
+	\code{llratio} performs a log-likelihood ratio test on two
+	\code{fit}ted models; the first object should have the largest degrees 
+	of freedom. 
+	
+}
+
+\value{
+	
+	\code{fit} returns an object of class \code{\link[depmix.fitted-class]{depmix.fitted}} which contains 
+	the original depmix object, and further has slots: 
+	
+	\item{message}{: Convergence information.}
+	
+	\item{conMat}{: The constraint matrix A, see details.}
+
+	\item{posterior}{: Returns a data.frame with nstates(object) + 1
+	columns; the first column has the viterbi states, the other columns
+	have the delta probabilities, see Rabiner (1989).}
+	
+	The print method shows the \code{message} and the summary method
+	shows the parameter estimates.
+	
+}
+
+\references{
+	
+	Lawrence R. Rabiner (1989).  A tutorial on hidden Markov models and
+	selected applications in speech recognition.  \emph{Proceedings of
+	IEEE}, 77-2, p.  267-295.
+	
+}
+
+\examples{
+
+data(speed)
+# 2-state model on the RTs of the speed data with random 
+# starting values for the transition pars (without those EM does not get off the ground)
+set.seed(1)
+mod <- depmix(rt~1,data=speed,nstates=2,trstart=runif(4))
+# fit the model
+mod1 <- fit(mod)
+mod1 # to see the logLik and optimization information
+# to see the parameters
+summary(mod1)
+
+
+data(balance)
+# four binary items on the balance scale task
+
+# now fit some latent class models
+trstart=c(1,0,0,1) # as this is a latent class model, the transition are not optimized
+instart=c(0.5,0.5)
+set.seed(1)
+respstart=runif(16)
+# note that ntimes argument is used to make this a mixture model
+mod <- depmix(list(d1~1,d2~1,d3~1,d4~1), data=balance, nstates=2,
+	family=list(multinomial(),multinomial(),multinomial(),multinomial()),
+	respstart=respstart,trstart=trstart,instart=instart,
+	ntimes=rep(1,nrow(balance)))
+
+mod1 <- fit(mod)
+
+# add age as covariate on class membership by using the prior argument
+trstart=c(1,0,0,1) # as this is a latent class model, the transition are not optimized
+instart=c(0.5,0.5,0,0) # we need the initial probs and the coefficients of age 
+set.seed(2)
+respstart=c(runif(16))
+trstart=c(1,0,0,1)
+mod2 <- depmix(list(d1~1,d2~1,d3~1,d4~1), data=balance, nstates=2,
+	family=list(multinomial(),multinomial(),multinomial(),multinomial()),
+	trstart=trstart, instart=instart, respstart=respstart,
+	ntimes=rep(1,nrow(balance)), prior=~age, initdata=balance)
+
+mod3 <- fit(mod2)
+
+# check the likelihood ratio; adding age significantly improves the goodness-of-fit
+llratio(mod3,mod1)
+
+}
+
+\author{Ingmar Visser}
+
+\keyword{methods}


Property changes on: trunk/man/depmix.fit.Rd
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/man/depmix.fitted-class.Rd
===================================================================
--- trunk/man/depmix.fitted-class.Rd	                        (rev 0)
+++ trunk/man/depmix.fitted-class.Rd	2008-03-23 15:18:12 UTC (rev 109)
@@ -0,0 +1,74 @@
+\name{depmix.fitted-class}
+
+\docType{class}
+
+\alias{depmix.fitted-class}
+
+\title{Class "depmix.fitted"}
+
+\description{A fitted \code{\link{depmix}} model.}
+
+\section{Slots}{
+	
+	A \code{depmix.fitted} object is a \code{depmix} object with three 
+	additional slots, here is the complete list:
+	
+	\describe{
+
+		\item{\code{response}:}{List of list of \code{response} objects.}
+
+		\item{\code{transition}}{List of \code{transInit} objects.}
+		
+		\item{\code{prior}:}{\code{transInit} object.}
+		
+		\item{\code{dens}:}{Array of dimension sum(ntimes)*nresp*nstates
+			providing the densities of the observed responses for each state.}
+		
+		\item{\code{trDens}:}{Array of dimension \code{sum(ntimes)}*nstates
+			providing the probability of a state transition depending on the
+			predictors.}
+		
+		\item{\code{init}:}{Array of dimension \code{length(ntimes)}*nstates with 
+			the current predictions for the initial state probabilities.}
+		
+		\item{\code{stationary}:}{Logical indicating whether the transitions are
+			time-dependent or not; for internal use.}
+		
+		\item{\code{ntimes}:}{A vector containing the lengths of independent time
+			series; if data is provided, sum(ntimes) must be equal to
+			nrow(data).}
+	
+		\item{\code{nstates}:}{The number of states of the model.}
+	
+		\item{\code{nresp}:}{The number of independent responses.}
+	
+		\item{\code{npars}:}{The total number of parameters of the model. This is not
+			the degrees of freedom, ie there are redundancies in the
+			parameters, in particular in the multinomial models for the
+			transitions and prior.}
+			
+		\item{\code{message}:}{This provides some information on convergence,
+			either from the EM algorithm or from Rdonlp2.}
+		
+		\item{\code{conMat}:}{The linear constraint matrix, which has zero rows
+			if there were no constraints.}
+		
+		\item{\code{posterior}:}{Posterior (Viterbi) state sequence (not
+			implemented currently).}
+	}
+}
+
+\section{Details}{
+	
+	The print function shows some convergence information, and the summary
+	method shows the parameter estimates.
+	
+}
+
+\section{Extends}{
+	\code{depmix.fitted} extends the \code{depmix} class.
+}
+
+\author{Ingmar Visser}
+
+\keyword{classes}


Property changes on: trunk/man/depmix.fitted-class.Rd
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/man/llratio.Rd
===================================================================
--- trunk/man/llratio.Rd	                        (rev 0)
+++ trunk/man/llratio.Rd	2008-03-23 15:18:12 UTC (rev 109)
@@ -0,0 +1,49 @@
+
+\name{llratio}
+
+\docType{methods}
+
+\alias{llratio}
+
+\alias{loglikelihoodratio}
+
+\alias{show,llratio-method}
+
+\title{Log likelihood ratio test on two fitted models}
+
+\description{Performs a log likelihood ratio test on two fitted
+\code{depmix} models.}
+
+\usage{
+	
+	llratio(basemodel, constrainedmodel, ...)
+	
+}
+
+\arguments{ 
+	
+	\item{basemodel}{Fitted model with a \code{logLik} method.}
+	
+	\item{constrainedmodel}{Fitted model with a \code{logLik} method.}
+	
+	\item{...}{Not currently used.}
+	
+}
+
+\value{
+	
+	\code{llratio} returns an object of class \code{llratio} which has slots: 
+	
+	\item{value}{: Minus twice the loglikelihood difference.}
+	
+	\item{df}{: The degrees of freedom, ie the difference in number of freely
+	estimated paraemters between the models.}
+	
+	The print method shows the value, the degrees of freedom and the
+	corresponding p-value under the chisquared distribution. 
+	
+}
+
+\author{Ingmar Visser}
+
+\keyword{methods}
\ No newline at end of file

Added: trunk/man/response-class.Rd
===================================================================
--- trunk/man/response-class.Rd	                        (rev 0)
+++ trunk/man/response-class.Rd	2008-03-23 15:18:12 UTC (rev 109)
@@ -0,0 +1,58 @@
+\name{response-class}
+
+\docType{class}
+
+\alias{response-class}
+
+\title{Class "response"}
+
+\description{
+
+A generic \code{\link{response}} model for \code{\link{depmix}} models.
+
+}
+
+\arguments{
+	\item{object}{An object of class "response".}
+}
+
+\section{Slots}{
+
+	\describe{
+    	\item{\code{parameters}:}{A (named) list of parameters.}
+
+		\item{\code{fixed}:}{A logical vector indicating which parameters
+			are fixed.}
+
+		\item{\code{y}:}{A matrix with the actual response; possibly
+			multivariate.}
+
+		\item{\code{x}:}{A design matrix; possibly only an intercept term.}
+
+		\item{\code{npar}:}{The number of parameters.}
+	}
+	
+}
+
+\details{
+
+	This class offers a framework from which to build specific response
+	models such as glm based responses or multinomial responses.  For
+	extensibility, objects with class \code{response} should have at least
+	methods: \code{dens} to return the \code{dens}'ity of responses, and
+	\code{getpars} and \code{setpars} methods to get and set parameters.
+	
+}
+
+\section{Accessor Functions}{
+	The following functions should be used for accessing the corresponding
+	slots:
+	\describe{
+		\item{\code{npar}:}{The number of parameters of the model.}
+		\item{\code{getdf}:}{The number of non-fixed parameters.}
+	}
+}
+
+\author{Ingmar Visser}
+
+\keyword{classes}


Property changes on: trunk/man/response-class.Rd
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/man/response-classes.Rd
===================================================================
--- trunk/man/response-classes.Rd	                        (rev 0)
+++ trunk/man/response-classes.Rd	2008-03-23 15:18:12 UTC (rev 109)
@@ -0,0 +1,58 @@
+\name{response-classes}
+
+\docType{class}
+
+\alias{response-classes}
+
+\alias{GLMresponse-class}
+\alias{transInit-class}
+
+\title{Class "GLmresponse" and class "transInit"}
+
+\description{Specific instances of response models for \code{\link{depmix}}
+models.}
+
+\section{Slots}{
+	
+	Both \code{GLMresponse} and \code{transInit} contain the
+	\code{response}-class. In addition to the slots of that class, these
+	classes have the following slots: 
+	
+	\describe{
+    	
+		\item{\code{formula}:}{A formula that specifies the model.}
+
+		\item{\code{family}:}{A family object specifying the link 
+		function. Currently, the only options are \code{gaussian()} from 
+		the \code{\link{stats}}-package and \code{multinomial}.}
+	}
+	
+}
+
+\details{
+	
+	The \code{GLMresponse}-class offers an interface to the
+	\code{\link[stats]{glm}} functions that are subsequently used in fitting
+	the \code{depmix} model of which the response is a part.
+	
+	The \code{transInit} is an extension of \code{response} that is used to
+	model the transition matrix and the initial state probabilities by the
+	use of a multinomial logistic model, the difference being that in fact
+	the response is missing as the transitions between states are not
+	observed.  This class has its own fit function which is an interface to
+	the multinom function in \code{\link{nnet}}.
+	
+}
+
+\section{Accessor Functions}{
+	The following functions should be used for accessing the corresponding
+	slots:
+	\describe{
+		\item{\code{npar}:}{The number of parameters of the model.}
+		\item{\code{getdf}:}{The number of non-fixed parameters.}
+	}
+}
+
+\author{Ingmar Visser}
+
+\keyword{classes}


Property changes on: trunk/man/response-classes.Rd
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/man/response.Rd
===================================================================
--- trunk/man/response.Rd	                        (rev 0)
+++ trunk/man/response.Rd	2008-03-23 15:18:12 UTC (rev 109)
@@ -0,0 +1,85 @@
+\name{response}
+
+\docType{method}
+
+\alias{response}
+\alias{transInit}
+\alias{GLMresponse}
+
+\alias{transInit,formula-method}
+\alias{GLMresponse,formula-method}
+
+\alias{getdf}
+\alias{getdf,response-method}
+
+\alias{show,GLMresponse-method}
+
+\title{Methods for creating depmix response models}
+
+\description{
+
+Create \code{response} objects for \code{\link{depmix}} models using
+formulae and family objects.
+
+}
+
+\usage{
+	
+	GLMresponse(formula, data=NULL, family=gaussian(), pstart=NULL, 
+		fixed=NULL, prob=TRUE, ...)
+	
+	transInit(formula, nstates, data=NULL, family=multinomial(),
+		pstart=NULL, fixed=NULL, prob=TRUE, ...)
+	
+	\S4method{getdf}{response}(object)
+}
+
+\arguments{
+	\item{formula}{A model formula.}
+	\item{nstates}{The number of states of the model.}
+	\item{family}{A family object; currently only multinomial() and
+		gaussian() are allowed options.}
+	\item{data}{An optional data.frame to interpret the variables from the 
+		formula argument in.}
+	\item{pstart}{Starting values for the coefficients and other
+		parameters, ie the standard deviation for the gaussian() family.}
+	\item{fixed}{Logical vector indicating which paramters are to be fixed.}
+	\item{prob}{Logical indicating whether the starting values for
+		multinomial() family models are probabilities or logistic
+		parameters (see details).}
+	\item{object}{Object of class response.}
+	\item{...}{Not used currently.}
+}
+
+\details{
+	
+	Both methods use the familiar formula interface from linear and general
+	linear models to specify how responses (or transition or prior
+	parameters) depend on covariates.
+	
+	The GLMresponse model is an interface to the glm functions of which
+	the functionality is leant, ie predict, fit and density functions. 
+	
+	The transInit response model provides functionality for multinomial
+	responses that are currently fit using nnet (this may change in the
+	future but this should not affect the interface of this function). Note
+	that the transInit model actually lacks a reponse, ie the y-slot is
+	empty, at the time of construction, as the transitions are not
+	observed. 
+	
+}
+
+\value{
+	
+	\code{GLMresponse} and \code{transInit} return objects of class
+	\code{GLMresponse} and \code{transInit} respectively; both classes
+	extend the \code{\link{response-class}}. 
+	
+	\code{getdf} returns the number of free parameters of a
+	\code{response} model.
+
+}
+
+\author{Ingmar Visser} 
+
+\keyword{methods}


Property changes on: trunk/man/response.Rd
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/man/speed.Rd
===================================================================
--- trunk/man/speed.Rd	                        (rev 0)
+++ trunk/man/speed.Rd	2008-03-23 15:18:12 UTC (rev 109)
@@ -0,0 +1,36 @@
+\name{speed}
+
+\docType{data}
+
+\alias{speed}
+
+\title{Speed Accuracy Switching Data}
+
+\description{
+
+	This data set is a bivariate series of reaction times and accuracy
+	scores of a single subject switching between slow and accurate
+	responding and fast guessing on a lexical decision task.  The slow and
+	accurate responding, and the fast guessing can be modelled using two
+	states, with a switching regime between them.  The dataset further
+	contains a third variable called Pacc, representing the relative
+	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 a single subject from experiment 2
+	in \cite{Van der Maas et al, 2005}.
+	
+}
+
+\usage{data(speed)}
+
+\format{Data.frame}
+
+\source{
+
+	Han L. J. Van der Maas, Conor V. Dolan and Peter C. M. Molenaar (2007),
+	Phase Transitions in the Trade-Off between Speed and Accuracy in Choice
+	Reaction Time Tasks.  \emph{Manuscript in preparation}. 
+
+}
+
+\keyword{datasets}



More information about the depmix-commits mailing list