sp {hmm.discnp} | R Documentation |
Returns the probabilities that the underlying hidden state is equal to each of the possible state values, at each time point, given the observation sequence.
sp(y, model = NULL, tpm=NULL, Rho=NULL, ispd=NULL, X=NULL,
addIntercept=NULL, warn=TRUE, drop=TRUE)
y |
The observations on the basis of which the probabilities
of the underlying hidden states are to be calculated. May be
a vector of a one or two column matrix of observations, or
a list each component of which is such a vector or matrix.
If |
model |
An object of class |
tpm |
The transition probability matrix for the underlying hidden
Markov chain. Ignored if |
Rho |
An object specifying the distribution of the observations, given
the underlying state. I.e. the “emission” probabilities.
See |
ispd |
Vector specifying the initial state probability distribution
of the underlying hidden Markov chain. Ignored if |
X |
An optional numeric matrix, or a list of
such matrices, of predictors. Ignored if The use of such predictors is (currently, at least) applicable
only in the univariate emissions setting. If |
addIntercept |
Logical scalar. See the documentation of |
warn |
Logical scalar; should a warning be issued if |
drop |
Logical scalar. If |
Note that in contrast to predict.hmm.discnp()
, components
in model
take precendence over individually supplied
components (tpm
, Rho
, ispd
, X
and addIntercept
).
If y
is a single matrix of observations or a list of
length 1, and if drop
is TRUE
then the returned
value is a matrix whose rows correspond to the states of
the hidden Markov chain, and whose columns correspond to the
observation times. Otherwise the returned value is a list of such
matrices, one for each matrix of observations.
Rolf Turner
r.turner@auckland.ac.nz
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 <- rhmm(ylengths=rep(300,20),nsim=1,tpm=P,Rho=R,drop=TRUE)
fit <- hmm(y,K=2,verb=TRUE,keep.y=TRUE,itmax=10)
cpe1 <- sp(model=fit) # Using the estimated parameters.
cpe2 <- sp(y,tpm=P,Rho=R,warn=FALSE) # Using the ``true'' parameters.
# The foregoing would issue a warning that Rho had no row names
# were it not for the fact that "warn" has been set to FALSE.