Description Usage Arguments Value Author(s) References Examples

View source: R/lmestDecoding.R

Function that performs local and global decoding (Viterbi algorithm) from the output of `lmest`

, `lmestCont`

, and `lmestMixed`

.

1 2 3 4 5 6 7 8 9 10 11 | ```
lmestDecoding(est, sequence = NULL, fort = TRUE, ...)
## S3 method for class 'LMbasic'
lmestDecoding(est, sequence = NULL,fort = TRUE, ...)
## S3 method for class 'LMmanifest'
lmestDecoding(est, sequence = NULL, fort = TRUE, ...)
## S3 method for class 'LMlatent'
lmestDecoding(est, sequence = NULL, fort = TRUE,...)
## S3 method for class 'LMbasiccont'
lmestDecoding(est, sequence = NULL, fort = TRUE,...)
## S3 method for class 'LMmixed'
lmestDecoding(est, sequence = NULL, fort = TRUE,...)
``` |

`est` |
an object obtained from a call to |

`sequence` |
an integer vector indicating the units for the decoding. If |

`fort` |
to use fortran routines when possible |

`...` |
further arguments |

`Ul ` |
matrix of local decoded states corresponding to each row of Y |

`Ug ` |
matrix of global decoded states corresponding to each row of Y |

Francesco Bartolucci, Silvia Pandolfi, Fulvia Pennoni, Alessio Farcomeni, Alessio Serafini

Viterbi A. (1967) Error Bounds for Convolutional Codes and an Asymptotically Optimum Decoding Algorithm. *IEEE Transactions on Information Theory*, **13**, 260-269.

Juan B., Rabiner L. (1991) Hidden Markov Models for Speech Recognition. *Technometrics*, **33**, 251-272.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | ```
# Decoding for basic LM model
data("data_drug")
long <- data_drug[,-6]-1
long <- data.frame(id = 1:nrow(long),long)
long <- reshape(long,direction = "long",
idvar = "id",
varying = list(2:ncol(long)))
est <- lmest(index = c("id","time"),
k = 3,
data = long,
weights = data_drug[,6],
modBasic = 1)
# Decoding for a single sequence
out1 <- lmestDecoding(est, sequence = 1)
out2 <- lmestDecoding(est, sequence = 1:4)
# Decoding for all sequences
out3 <- lmestDecoding(est)
## Not run:
# Decoding for LM model with covariates on the initial and transition probabilities
data("data_SRHS_long")
SRHS <- data_SRHS_long[1:2400,]
# Categories rescaled to vary from 0 (“poor”) to 4 (“excellent”)
SRHS$srhs <- 5 - SRHS$srhs
est2 <- lmest(responsesFormula = srhs ~ NULL,
latentFormula = ~
I(gender - 1) +
I( 0 + (race == 2) + (race == 3)) +
I(0 + (education == 4)) +
I(0 + (education == 5)) +
I(age - 50) + I((age-50)^2/100),
index = c("id","t"),
data = SRHS,
k = 2,
paramLatent = "difflogit",
output = TRUE)
# Decoding for a single sequence
out3 <- lmestDecoding(est2, sequence = 1)
# Decoding for the first three sequences
out4 <- lmestDecoding(est2, sequence = 1:3)
# Decoding for all sequences
out5 <- lmestDecoding(est2)
## End(Not run)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.