sp(y, object = NULL, tpm, Rho, ispd=NULL, means = FALSE)
y
hmm.discnp
as returned by
hmm()
.object
is not NULL
.
Ignored if object
is not NULL
(in which
case tpm
is extracted from objec
object
is noobject
is not NULL
(in which
case ispd
is extracted from object
).
If both obje
means
is TRUE
then the
conditional expected value of the observations (given the
observation sequence) is calculated at each time point.
If means
is TRUE
and the observation vameans
is TRUE
then the returned value is
a list with componentsprobs
as
described above. If there is a single vector of observations y
then
probs
is a matrix whose rows correspond to the states
of the hidden Markov chain, and whose columns correspond to
the observation times. If the observations consist of a
list of observation vectors, then probs
is a list
of such matrices, one for each vector of observations.
Likewise for the means
component of the list returned
when the argument means
is TRUE
.
hmm()
, mps()
,
viterbi()
, pr()
,
fitted.hmm.discnp()
P <- matrix(c(0.7,0.3,0.1,0.9),2,2,byrow=TRUE)
R <- matrix(c(0.5,0,0.1,0.1,0.3,
0.1,0.1,0,0.3,0.5),5,2)
set.seed(42)
y.num <- sim.hmm(rep(300,20),P,R)
fit.num <- hmm(y.num,K=2,verb=TRUE)
cpe1 <- sp(object=fit.num,means=TRUE) # Using the estimated parameters.
cpe2 <- sp(y.num,tpm=P,Rho=R,means=TRUE) # Using the ``true'' parameters.
Run the code above in your browser using DataLab