SCM

SCM Repository

[depmix] Diff of /trunk/man/depmix.fit.Rd
ViewVC logotype

Diff of /trunk/man/depmix.fit.Rd

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 98, Fri Mar 21 23:45:47 2008 UTC revision 99, Sun Mar 23 14:11:15 2008 UTC
# Line 6  Line 6 
6  \alias{depmix.fit}  \alias{depmix.fit}
7  \alias{fit,depmix-method}  \alias{fit,depmix-method}
8    
9    \alias{posterior}
10    \alias{posterior,depmix.fitted-method}
11    
12  \alias{show,depmix.fitted-method}  \alias{show,depmix.fitted-method}
13  \alias{summary,depmix.fitted-method}  \alias{summary,depmix.fitted-method}
14    
# Line 21  Line 24 
24          \S4method{fit}{depmix}(object, fixed=NULL, equal=NULL, conrows=NULL,          \S4method{fit}{depmix}(object, fixed=NULL, equal=NULL, conrows=NULL,
25                  conrows.upper=0, conrows.lower=0, method=NULL,...)                  conrows.upper=0, conrows.lower=0, method=NULL,...)
26    
27            \S4method{posterior}{depmix.fitted}(object,...)
28          \S4method{summary}{depmix.fitted}(object)          \S4method{summary}{depmix.fitted}(object)
29    
30  }  }
# Line 91  Line 95 
95    
96          \item{conMat}{: The constraint matrix A, see details.}          \item{conMat}{: The constraint matrix A, see details.}
97    
98          \item{posterior}{: The posterior state probabilities.}          \item{posterior}{: Returns a data.frame with nstates(object) + 1
99            columns; the first column has the viterbi states, the other columns
100            have the delta probabilities, see Rabiner (1989).}
101    
102          The print method shows the \code{message} and the summary method          The print method shows the \code{message} and the summary method
103          shows the parameter estimates.          shows the parameter estimates.
104    
105  }  }
106    
107    \references{
108    
109            Lawrence R. Rabiner (1989).  A tutorial on hidden Markov models and
110            selected applications in speech recognition.  \emph{Proceedings of
111            IEEE}, 77-2, p.  267-295.
112    
113    }
114    
115  \examples{  \examples{
116    
117  data(speed)  data(speed)
# Line 111  Line 125 
125  # to see the parameters  # to see the parameters
126  summary(mod1)  summary(mod1)
127    
128    
129    data(balance)
130    # four binary items on the balance scale task
131    
132    # now fit some latent class models
133    trstart=c(1,0,0,1) # as this is a latent class model, the transition are not optimized
134    instart=c(0.5,0.5)
135    set.seed(1)
136    respstart=runif(16)
137    # note that ntimes argument is used to make this a mixture model
138    mod <- depmix(list(d1~1,d2~1,d3~1,d4~1), data=balance, nstates=2,
139            family=list(multinomial(),multinomial(),multinomial(),multinomial()),
140            respstart=respstart,trstart=trstart,instart=instart,
141            ntimes=rep(1,nrow(balance)))
142    
143    mod1 <- fit(mod)
144    
145    # add age as covariate on class membership by using the prior argument
146    trstart=c(1,0,0,1) # as this is a latent class model, the transition are not optimized
147    instart=c(0.5,0.5,0,0) # we need the initial probs and the coefficients of age
148    set.seed(2)
149    respstart=c(runif(16))
150    trstart=c(1,0,0,1)
151    mod2 <- depmix(list(d1~1,d2~1,d3~1,d4~1), data=balance, nstates=2,
152            family=list(multinomial(),multinomial(),multinomial(),multinomial()),
153            trstart=trstart, instart=instart, respstart=respstart,
154            ntimes=rep(1,nrow(balance)), prior=~age, initdata=balance)
155    
156    mod3 <- fit(mod2)
157    
158    # check the likelihood ratio; adding age significantly improves the goodness-of-fit
159    llratio(mod3,mod1)
160    
161  }  }
162    
163  \author{Ingmar Visser}  \author{Ingmar Visser}

Legend:
Removed from v.98  
changed lines
  Added in v.99

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge