View source: R/traveltimeHMM.R
traveltimeHMM | R Documentation |
traveltimeHMM
estimates trip- and link- specific speed parameters from observed average speeds per unique trip and link.
traveltimeHMM( logspeeds = NULL, trips = NULL, timeBins = NULL, linkIds = NULL, data = NULL, nQ = 1L, model = c("HMM", "trip-HMM", "trip", "no-dependence"), tol.err = 10, L = 10L, max.it = 20L, verbose = FALSE, max.speed = NULL, seed = NULL, tmat.p = NULL, init.p = NULL )
logspeeds |
A numeric vector of speed observations (in km/h) on the (natural) log-scale. Needs
to be provided if |
trips |
An integer or character vector of trip ids for each observation of |
timeBins |
A character vector of time bins for each observation of |
linkIds |
A vector of link ids (route or way) for each observation of |
data |
A data frame or equivalent object that contains one column for each of
|
nQ |
An integer corresponding to the number of different congestion states that the traversal
of a given link can take corresponding to |
model |
Type of model as string, |
tol.err |
A numeric variable representing the threshold under which the estimation algorithm will
consider it has reached acceptable estimate values. Default is |
L |
An integer minimum number of observations per factor ( |
max.it |
An integer for the upper limit of the iterations to be performed by the estimation
algorithm. Default is |
verbose |
A boolean that triggers verbose output. Default is |
max.speed |
An optional float for the maximum speed in km/h, on the linear scale
(not the log-scale, unlike for |
seed |
An optional float for the seed used for the random generation of the first Markov transition matrix
and initial state vector. Default is |
tmat.p |
An optional starting value for the Markov transition matrix Γ of size |
init.p |
An optional starting value for the Markov initial state vector γ
of size |
traveltimeHMM
returns a list of the following parameters.
factors |
a factor of interactions (linkId x timeBin) of length |
trip |
a factor of trip IDs. |
tmat |
a transition matrix with rows corresponding to |
init |
a initial state probability matrix with rows corresponding to |
sd |
a matrix of standard deviations estimates for the natural logarithm of the speed (in km/h), with rows corresponding to |
mean |
a matrix of mean estimates for the natural logarithm of the speed (in km/h), with rows corresponding to |
tau |
a numeric variable for the standard deviation estimate for the trip effect parameter |
logE |
a numeric vector of trip effect estimates corresponding to |
nQ |
an integer corresponding to the number of different congestion states, equal to the parameter nQ that was passed in the function call. |
nB |
an integer number of unique time bins. |
nObs |
an integer number of observations. |
model |
a character string corresponding to the type of model used. |
Woodard, D., Nogin, G., Koch, P., Racz, D., Goldszmidt, M., Horvitz, E., 2017. Predicting travel time reliability using mobile phone GPS data. Transportation Research Part C, 75, 30-44.
## Not run: data(tripset) # Fit an HMM model with 2 hidden congestion states and 20 algorithm iterations fit <- traveltimeHMM(tripset$logspeed, tripset$tripID, tripset$timeBin, tripset$linkID, nQ = 2, max.it = 20) # Perform prediction - use ?predict.traveltime for details single_trip <- subset(tripset, tripID==2700) pred <- predict.traveltime(fit, single_trip,single_trip$time[1]) hist(pred) mean(pred) sum(single_trip$traveltime) ?traveltimeHMM # for help on traveltimeHMM, the estimation function ?predict.traveltime # for help on predict.traveltime, the prediction function ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.