From a6bdd49abbf082aae520004d1a3dbaf353d79f3e Mon Sep 17 00:00:00 2001
From: Mohamad
Date: Wed, 25 Nov 2020 22:35:33 -0500
Subject: [PATCH] small fixes
---
DESCRIPTION | 3 +-
NAMESPACE | 6 +-
R/predict.R | 32 +--
R/traveltimeHMM.R | 2 +-
R/zzz.R | 0
README.md | 12 +-
docs/articles/traveltimeHMM.html | 14 +-
docs/index.html | 14 +-
docs/reference/index.html | 2 +-
docs/reference/predict.traveltimeHMM.HMM.html | 191 ++++++++++++++
docs/reference/predict.traveltimeHMM.html | 236 ++++++++++++++++++
.../predict.traveltimeHMM.no_dependence.html | 199 +++++++++++++++
docs/reference/time_bins_functional.html | 6 +-
docs/reference/traveltimeHMM.html | 24 +-
...me.HMM.Rd => predict.traveltimeHMM.HMM.Rd} | 11 +-
...traveltime.Rd => predict.traveltimeHMM.Rd} | 27 +-
...=> predict.traveltimeHMM.no_dependence.Rd} | 21 +-
man/time_bins_functional.Rd | 6 +-
man/traveltimeHMM.Rd | 22 +-
man/tripset.Rd | 6 +-
20 files changed, 751 insertions(+), 83 deletions(-)
create mode 100644 R/zzz.R
create mode 100644 docs/reference/predict.traveltimeHMM.HMM.html
create mode 100644 docs/reference/predict.traveltimeHMM.html
create mode 100644 docs/reference/predict.traveltimeHMM.no_dependence.html
rename man/{predict.traveltime.HMM.Rd => predict.traveltimeHMM.HMM.Rd} (85%)
rename man/{predict.traveltime.Rd => predict.traveltimeHMM.Rd} (78%)
rename man/{predict.traveltime.no_dependence.Rd => predict.traveltimeHMM.no_dependence.Rd} (82%)
diff --git a/DESCRIPTION b/DESCRIPTION
index 670e514..cf2d79c 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -26,7 +26,7 @@ BugReports: https://github.com/melmasri/traveltimeHMM/issues
License: GPL-3
Encoding: UTF-8
LazyData: true
-RoxygenNote: 6.1.1
+RoxygenNote: 7.1.1
Suggests:
testthat,
knitr,
@@ -41,4 +41,3 @@ Suggests:
kableExtra
VignetteBuilder: knitr
Depends: R (>= 2.10)
-
diff --git a/NAMESPACE b/NAMESPACE
index 70a35df..7ec8807 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -1,8 +1,8 @@
# Generated by roxygen2: do not edit by hand
-S3method(predict,traveltime)
-S3method(predict,traveltime.HMM)
-S3method(predict,traveltime.no_dependence)
+S3method(predict,traveltimeHMM)
+S3method(predict,traveltimeHMM.HMM)
+S3method(predict,traveltimeHMM.no_dependence)
export(forwardback)
export(gaussian_param_by_factor)
export(getValidE)
diff --git a/R/predict.R b/R/predict.R
index bc6c3fb..9f0898c 100644
--- a/R/predict.R
+++ b/R/predict.R
@@ -1,12 +1,12 @@
#' Predict the travel time for a trip using a \code{traveltimeHMM} model object
#'
-#' \code{predict.traveltime} performs a point prediction by simulation using parameter estimates provided by a \code{traveltimeHMM} model object.
+#' \code{predict.traveltimeHMM} performs a point prediction by simulation using parameter estimates provided by a \code{traveltimeHMM} model object.
#' Prediction can be performed for a single trip only.
#'
#' The function begins by validating and, if required, replacing the value of the parameter \code{logE}
#' (see explanation alongside \code{logE} in the \emph{Arguments} section). It then transfers execution
-#' to the appropriate function according to the selected model: \code{predict.traveltime.HMM} for
-#' models of the \code{HMM} family, or \code{predict.traveltime.no_dependence} otherwise.
+#' to the appropriate function according to the selected model: \code{predict.traveltimeHMM} for
+#' models of the \code{HMM} family, or \code{predict.traveltimeHMM.no_dependence} otherwise.
#'
#' @param object A model object (a list) provided through the execution of function \code{timetravelHMM}.
#' The list includes information on model as well as estimates for its parameters.
@@ -27,7 +27,7 @@
#' @param time_bins.fun A functional to map real time to specified time bins, see `?rules2timebins`.
#' @param ... not used.
#'
-#' @return \code{predict.traveltime} returns a numerical vector of size \code{n} representing the point prediction of total travel time, in seconds, for each run.
+#' @return \code{predict.traveltimeHMM} returns a numerical vector of size \code{n} representing the point prediction of total travel time, in seconds, for each run.
#'
#' @examples
#' \dontrun{
@@ -41,19 +41,19 @@
#' single_trip <- subset(tripset, tripID==2700)
#'
#' # We need to supply the time stamp of the very first link traversal (third parameter)
-#' pred <- predict.traveltime(fit, single_trip,single_trip$time[1])
+#' pred <- predict(fit, single_trip,single_trip$time[1])
#'
#' hist(pred) # histogram of prediction samples
#' mean(pred) # travel time point estimate
#' sum(single_trip$traveltime) # observed travel time
#'
#' ?traveltimeHMM # for help on traveltimeHMM, the estimation function
-#' ?predict.traveltime # for help on predict.traveltime, the prediction function
+#' ?predict.traveltimeHMM # for help on predict.traveltimeHMM, the prediction function
#' }
#' @references
#' {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.}
#' @export
-predict.traveltime<-function(object, tripdata, starttime = Sys.time(), n = 1000, logE = NULL,time_bins.fun = time_bins, ... ){
+predict.traveltimeHMM<-function(object, tripdata, starttime = Sys.time(), n = 1000, logE = NULL,time_bins.fun = time_bins, ... ){
# We first perform basic checks. 'tripdata' must be a list, data frame or data table
# that minimally includes objects 'linkID' and 'length', the latter having
@@ -66,18 +66,18 @@ predict.traveltime<-function(object, tripdata, starttime = Sys.time(), n = 1000
stop('length of objects do not match!')
# Models of the HMM family ('HMM', 'trip-HMM') are handled by function 'predict.traveltime.HMM'
- # whilst others are handled by function 'predict.traveltime.no_dependence'
+ # whilst others are handled by function 'predict.traveltimeHMM.no_dependence'
# (both functions are below).
if(grepl('HMM', object$model))
- predict.traveltime.HMM(object, tripdata, starttime, n, logE, time_bins = time_bins.fun, ...)
+ predict.traveltimeHMM.HMM(object, tripdata, starttime, n, logE, time_bins = time_bins.fun, ...)
else
- predict.traveltime.no_dependence(object, tripdata , starttime, n, logE, time_bins = time_bins.fun, ...)
+ predict.traveltimeHMM.no_dependence(object, tripdata , starttime, n, logE, time_bins = time_bins.fun, ...)
}
#' Predict the travel time for a trip using a \code{traveltimeHMM} model object that is not of the HMM family
#' @keywords internal
#'
-#' \code{predict.traveltime.no_dependence} performs a point prediction by simulation using parameter estimates provided by a \code{traveltimeHMM} model object that is not of the \code{HMM} family (see man page for \code{predict.traveltime}).
+#' \code{predict.traveltimeHMM.no_dependence} performs a point prediction by simulation using parameter estimates provided by a \code{traveltimeHMM} model object that is not of the \code{HMM} family (see man page for \code{predict.traveltimeHMM}).
#'
#' The function implements Algorithm 2 from Woodard et al., 2017. However, the state transition matrix
#' and initial state probability vector are not handled as they were not generated at the estimation stage.
@@ -95,13 +95,13 @@ predict.traveltime<-function(object, tripdata, starttime = Sys.time(), n = 1000
#' @param time_bins a functional map between real time and time bins, see `?rules2timebins`.
#' @param ... not used.
#'
-#' @return \code{predict.traveltime.no_dependence} returns a vector of size \code{n} of representing the point prediction of total travel time, in seconds, for each run.
+#' @return \code{predict.traveltimeHMM.no_dependence} returns a vector of size \code{n} of representing the point prediction of total travel time, in seconds, for each run.
#'
#' @importFrom stats rnorm runif
#' @references
#' {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.}
#' @export
-predict.traveltime.no_dependence <- function(object, tripdata, starttime, n = 1000, logE = NULL, time_bins = time_bins, ...) {
+predict.traveltimeHMM.no_dependence <- function(object, tripdata, starttime, n = 1000, logE = NULL, time_bins = time_bins, ...) {
linkIds = tripdata$linkID # Contains IDs of all links for a given trip
len = tripdata$length # Contains the length (in km) of each link in 'linkIds'
logE <- getValidE(object, logE, n) # Get a valid vector for 'logE'; see comments in function for details.
@@ -143,7 +143,7 @@ predict.traveltime.no_dependence <- function(object, tripdata, starttime, n = 10
#' Predict the travel time for a trip using a \code{traveltimeHMM} model object of the HMM family
#' @keywords internal
#'
-#' \code{predict.traveltime.HMM} performs a point prediction by simulation using parameter estimates provided by a \code{traveltimeHMM} model object of the \code{HMM} family (see man page for \code{predict.traveltime}).
+#' \code{predict.traveltime.HMM} performs a point prediction by simulation using parameter estimates provided by a \code{traveltimeHMM} model object of the \code{HMM} family (see man page for \code{predict.traveltimeHMM}).
#'
#' The function implements Algorithm 2 from Woodard et al., 2017, including its handling
#' of the state transition matrix and initial state probability vector.
@@ -161,13 +161,13 @@ predict.traveltime.no_dependence <- function(object, tripdata, starttime, n = 10
#' @param time_bins a functional map between real time and time bins, see `?rules2timebins`.
#' @param ... not used.
#'
-#' @return \code{predict.traveltime.HMM} returns a vector of size \code{n} of representing the point prediction of total travel time, in seconds, for each run.
+#' @return \code{predict.traveltimeHMM.HMM} returns a vector of size \code{n} of representing the point prediction of total travel time, in seconds, for each run.
#'
#' @importFrom stats rnorm runif
#' @references
#' {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.}
#' @export
-predict.traveltime.HMM <- function(object, tripdata, starttime, n, logE, time_bins = time_bins, ...) {
+predict.traveltimeHMM.HMM <- function(object, tripdata, starttime, n, logE, time_bins = time_bins, ...) {
linkIds = tripdata$linkID # Contains IDs of all links for a given trip
len = tripdata$length # Contains the length (in km) of each link in 'linkIds'
logE <- getValidE(object, logE, n) # Get a valid vector for 'logE'; see comments in function for details.
diff --git a/R/traveltimeHMM.R b/R/traveltimeHMM.R
index 99f9329..a55325f 100644
--- a/R/traveltimeHMM.R
+++ b/R/traveltimeHMM.R
@@ -445,7 +445,7 @@ traveltimeHMM <- function(logspeeds = NULL, trips = NULL, timeBins = NULL, linkI
nB = nB,
nObs = nObs,
model = model)
- class(obj) <- append(class(obj),"traveltime", after=0)
+ class(obj) <- append(class(obj),"traveltimeHMM", after=0)
invisible(obj)
}
diff --git a/R/zzz.R b/R/zzz.R
new file mode 100644
index 0000000..e69de29
diff --git a/README.md b/README.md
index f3f8ffd..2e6c1cb 100644
--- a/README.md
+++ b/README.md
@@ -37,12 +37,12 @@ library(traveltimeHMM)
data(tripset)
head(tripset)
#> tripID linkID timeBin logspeed traveltime length time
-#> 1 2700 10469 Weekday 1.692292 13.000000 70.61488 2014-04-28 03:07:27
-#> 2 2700 10444 Weekday 2.221321 18.927792 174.50487 2014-04-28 03:07:41
-#> 3 2700 10460 Weekday 2.203074 8.589937 77.76295 2014-04-28 03:07:58
-#> 4 2700 10462 Weekday 1.924290 14.619859 100.15015 2014-04-28 03:08:07
-#> 5 2700 10512 Weekday 1.804293 5.071986 30.81574 2014-04-28 03:08:21
-#> 6 2700 5890 Weekday 2.376925 31.585355 340.22893 2014-04-28 03:08:26
+#> 1 2700 10469 Weekday 1.692292 13.000000 70.61488 2014-04-28 06:07:27
+#> 2 2700 10444 Weekday 2.221321 18.927792 174.50487 2014-04-28 06:07:41
+#> 3 2700 10460 Weekday 2.203074 8.589937 77.76295 2014-04-28 06:07:58
+#> 4 2700 10462 Weekday 1.924290 14.619859 100.15015 2014-04-28 06:08:07
+#> 5 2700 10512 Weekday 1.804293 5.071986 30.81574 2014-04-28 06:08:21
+#> 6 2700 5890 Weekday 2.376925 31.585355 340.22893 2014-04-28 06:08:26
```
To fit a simple `HMM` model use the following code
diff --git a/docs/articles/traveltimeHMM.html b/docs/articles/traveltimeHMM.html
index 8edcad5..e978941 100644
--- a/docs/articles/traveltimeHMM.html
+++ b/docs/articles/traveltimeHMM.html
@@ -71,7 +71,7 @@
Introduction to traveltimeHMM: making reliable travel time predictions on road networks
Travel data is organized around the notions of trips and links. Links are road segments each with well-defined beginning and end points and which can be traversed. A vehicle performs a trip when it travels from a start point to an end point through a sequence of links. Thus trips can be considered as ordered sequences of links. tripset includes data for a collection of trips.
Field tripID contains each trip’s ID, whereas field linkID contains the IDs of each link making up a trip. Both fields need to be numerical. It is assumed that, in the data set, all trips are grouped together and all links of a given trip appear in the order in which they are traversed (No verification is performed to that effect). A given link corresponds to some physical entity such as a road segment, a portion of a road segment, or any combination of those. Hence, it is expected that links are used in more than one trip.
Predict the travel time for a trip using a traveltimeHMM model object of the HMM family
+
+
+
# S3 method for traveltimeHMM.HMM
+predict(object, tripdata, starttime, n, logE, time_bins=time_bins, ...)
+
+
Arguments
+
+
+
+
object
+
A model object (a list) provided through the execution of
+function timetravelHMM for a trip-HMM or HMM model type.
+The list includes information on model as well as estimates
+for its parameters. See timetravelHMM man page.
+
+
+
tripdata
+
A data frame of road links with information on each
+link's traversal. Columns minimally includes objects 'linkID' and 'length',
+and the latter must have the same length. Rows must be in chronological order.
+
+
+
starttime
+
The start date and time for the very first link of the trip, in POSIXct format.
+
+
+
n
+
Number of samples. Default is 1000.
+
+
+
logE
+
Point estimate of trip effects, in the form of a numerical vector of size n.
+
+
+
time_bins
+
a functional map between real time and time bins, see `?rules2timebins`.
+
+
+
...
+
not used.
+
+
+
+
Value
+
+
predict.traveltimeHMM.HMM returns a vector of size n of representing the point prediction of total travel time, in seconds, for each run.
+
References
+
+
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.
predict.traveltimeHMM performs a point prediction by simulation using parameter estimates provided by a traveltimeHMM model object.
+Prediction can be performed for a single trip only.
A model object (a list) provided through the execution of function timetravelHMM.
+The list includes information on model as well as estimates for its parameters.
+See timetravelHMM man page.
+
+
+
tripdata
+
A data frame of road links with information on each
+link's traversal. Columns minimally include objects 'linkID' and 'length',
+and the latter must have the same length. Rows must be in chronological order.
+The program assumes that the sequence of road links forms a coherent and feasible
+path. No verification is performed to that effect.
+
+
+
starttime
+
The start date and time for the very first link of the trip,
+in POSIXct format. Default is the current date and time.
+
+
+
n
+
Number of samples. Default is 1000.
+
+
+
logE
+
Point estimate of trip effects. logE normally needs to be a numerical vector of size n.
+If a single numerical value is supplied, it will be replicated into a vector. If logE is NULL
+the function will use either a vector of simulated values (if the model is from the trip family),
+or a vector of 0 otherwise. Default is NULL. NOTE: when simulating values for the
+vector, the value for \(\tau\) is taken from the model object.
+
+
+
time_bins.fun
+
A functional to map real time to specified time bins, see `?rules2timebins`.
+
+
+
...
+
not used.
+
+
+
+
Value
+
+
predict.traveltimeHMM returns a numerical vector of size n representing the point prediction of total travel time, in seconds, for each run.
+
Details
+
+
The function begins by validating and, if required, replacing the value of the parameter logE
+(see explanation alongside logE in the Arguments section). It then transfers execution
+to the appropriate function according to the selected model: predict.traveltimeHMM for
+models of the HMM family, or predict.traveltimeHMM.no_dependence otherwise.
+
References
+
+
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.
+
+
Examples
+
# NOT RUN {
+data(tripset)
+
+# Fit a model - use ?traveltimeHMM for details
+fit<-traveltimeHMM(tripset$logspeed, tripset$tripID,
+ tripset$timeBin, tripset$linkID, nQ=2, max.it=10)
+
+# Perform a prediction for trip #2700 using the fitted model.
+single_trip<-subset(tripset, tripID==2700)
+
+# We need to supply the time stamp of the very first link traversal (third parameter)
+pred<-predict(fit, single_trip,single_trip$time[1])
+
+hist(pred) # histogram of prediction samples
+mean(pred) # travel time point estimate
+sum(single_trip$traveltime) # observed travel time
+
+?traveltimeHMM# for help on traveltimeHMM, the estimation function
+?predict.traveltimeHMM# for help on predict.traveltimeHMM, the prediction function
+# }
A model object (a list) provided through the execution of
+function timetravelHMM for a trip or no-dependence model type.
+The list includes information on model as well as estimates
+for its parameters. See timetravelHMM man page.
+
+
+
tripdata
+
A data frame of road links with information on each
+link's traversal. Columns minimally includes objects 'linkID' and 'length',
+and the latter must have the same length. Rows must be in chronological order.
+
+
+
starttime
+
The start date and time for the very first link of the trip, in POSIXct format.
+
+
+
n
+
Number of samples. Default is 1000.
+
+
+
logE
+
Point estimate of trip effects, in the form of a numerical vector of size n.
+
+
+
time_bins
+
a functional map between real time and time bins, see `?rules2timebins`.
+
+
+
...
+
not used.
+
+
+
+
Value
+
+
predict.traveltimeHMM.no_dependence returns a vector of size n of representing the point prediction of total travel time, in seconds, for each run.
+
References
+
+
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.
Examp
# Perform prediction - use ?predict.traveltime for detailssingle_trip<-subset(tripset, tripID==2700)
-pred<-predict.traveltime(fit, single_trip,single_trip$time[1])
+pred<-predict.traveltime(fit, single_trip,single_trip$time[1])
hist(pred)
mean(pred)
sum(single_trip$traveltime)
diff --git a/man/predict.traveltime.HMM.Rd b/man/predict.traveltimeHMM.HMM.Rd
similarity index 85%
rename from man/predict.traveltime.HMM.Rd
rename to man/predict.traveltimeHMM.HMM.Rd
index 8510ada..773a7ed 100644
--- a/man/predict.traveltime.HMM.Rd
+++ b/man/predict.traveltimeHMM.HMM.Rd
@@ -1,11 +1,10 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/predict.R
-\name{predict.traveltime.HMM}
-\alias{predict.traveltime.HMM}
+\name{predict.traveltimeHMM.HMM}
+\alias{predict.traveltimeHMM.HMM}
\title{Predict the travel time for a trip using a \code{traveltimeHMM} model object of the HMM family}
\usage{
-\method{predict}{traveltime.HMM}(object, tripdata, starttime, n, logE,
- time_bins = time_bins, ...)
+\method{predict}{traveltimeHMM.HMM}(object, tripdata, starttime, n, logE, time_bins = time_bins, ...)
}
\arguments{
\item{object}{A model object (a list) provided through the execution of
@@ -28,7 +27,7 @@ and the latter must have the same length. Rows must be in chronological order.}
\item{...}{not used.}
}
\value{
-\code{predict.traveltime.HMM} returns a vector of size \code{n} of representing the point prediction of total travel time, in seconds, for each run.
+\code{predict.traveltimeHMM.HMM} returns a vector of size \code{n} of representing the point prediction of total travel time, in seconds, for each run.
}
\description{
Predict the travel time for a trip using a \code{traveltimeHMM} model object of the HMM family
@@ -44,7 +43,7 @@ Predict the travel time for a trip using a \code{traveltimeHMM} model object of
\keyword{Woodard}
\keyword{\code{HMM}}
\keyword{\code{predict.traveltime.HMM}}
-\keyword{\code{predict.traveltime}).}
+\keyword{\code{predict.traveltimeHMM}).}
\keyword{\code{traveltimeHMM}}
\keyword{a}
\keyword{al.,}
diff --git a/man/predict.traveltime.Rd b/man/predict.traveltimeHMM.Rd
similarity index 78%
rename from man/predict.traveltime.Rd
rename to man/predict.traveltimeHMM.Rd
index bea719e..c6efedd 100644
--- a/man/predict.traveltime.Rd
+++ b/man/predict.traveltimeHMM.Rd
@@ -1,11 +1,18 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/predict.R
-\name{predict.traveltime}
-\alias{predict.traveltime}
+\name{predict.traveltimeHMM}
+\alias{predict.traveltimeHMM}
\title{Predict the travel time for a trip using a \code{traveltimeHMM} model object}
\usage{
-\method{predict}{traveltime}(object, tripdata, starttime = Sys.time(),
- n = 1000, logE = NULL, time_bins.fun = time_bins, ...)
+\method{predict}{traveltimeHMM}(
+ object,
+ tripdata,
+ starttime = Sys.time(),
+ n = 1000,
+ logE = NULL,
+ time_bins.fun = time_bins,
+ ...
+)
}
\arguments{
\item{object}{A model object (a list) provided through the execution of function \code{timetravelHMM}.
@@ -34,17 +41,17 @@ vector, the value for \eqn{\tau} is taken from the model object.}
\item{...}{not used.}
}
\value{
-\code{predict.traveltime} returns a numerical vector of size \code{n} representing the point prediction of total travel time, in seconds, for each run.
+\code{predict.traveltimeHMM} returns a numerical vector of size \code{n} representing the point prediction of total travel time, in seconds, for each run.
}
\description{
-\code{predict.traveltime} performs a point prediction by simulation using parameter estimates provided by a \code{traveltimeHMM} model object.
+\code{predict.traveltimeHMM} performs a point prediction by simulation using parameter estimates provided by a \code{traveltimeHMM} model object.
Prediction can be performed for a single trip only.
}
\details{
The function begins by validating and, if required, replacing the value of the parameter \code{logE}
(see explanation alongside \code{logE} in the \emph{Arguments} section). It then transfers execution
-to the appropriate function according to the selected model: \code{predict.traveltime.HMM} for
-models of the \code{HMM} family, or \code{predict.traveltime.no_dependence} otherwise.
+to the appropriate function according to the selected model: \code{predict.traveltimeHMM} for
+models of the \code{HMM} family, or \code{predict.traveltimeHMM.no_dependence} otherwise.
}
\examples{
\dontrun{
@@ -58,14 +65,14 @@ fit <- traveltimeHMM(tripset$logspeed, tripset$tripID,
single_trip <- subset(tripset, tripID==2700)
# We need to supply the time stamp of the very first link traversal (third parameter)
-pred <- predict.traveltime(fit, single_trip,single_trip$time[1])
+pred <- predict(fit, single_trip,single_trip$time[1])
hist(pred) # histogram of prediction samples
mean(pred) # travel time point estimate
sum(single_trip$traveltime) # observed travel time
?traveltimeHMM # for help on traveltimeHMM, the estimation function
-?predict.traveltime # for help on predict.traveltime, the prediction function
+?predict.traveltimeHMM # for help on predict.traveltimeHMM, the prediction function
}
}
\references{
diff --git a/man/predict.traveltime.no_dependence.Rd b/man/predict.traveltimeHMM.no_dependence.Rd
similarity index 82%
rename from man/predict.traveltime.no_dependence.Rd
rename to man/predict.traveltimeHMM.no_dependence.Rd
index a620e48..5b3fef3 100644
--- a/man/predict.traveltime.no_dependence.Rd
+++ b/man/predict.traveltimeHMM.no_dependence.Rd
@@ -1,11 +1,18 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/predict.R
-\name{predict.traveltime.no_dependence}
-\alias{predict.traveltime.no_dependence}
+\name{predict.traveltimeHMM.no_dependence}
+\alias{predict.traveltimeHMM.no_dependence}
\title{Predict the travel time for a trip using a \code{traveltimeHMM} model object that is not of the HMM family}
\usage{
-\method{predict}{traveltime.no_dependence}(object, tripdata, starttime,
- n = 1000, logE = NULL, time_bins = time_bins, ...)
+\method{predict}{traveltimeHMM.no_dependence}(
+ object,
+ tripdata,
+ starttime,
+ n = 1000,
+ logE = NULL,
+ time_bins = time_bins,
+ ...
+)
}
\arguments{
\item{object}{A model object (a list) provided through the execution of
@@ -28,7 +35,7 @@ and the latter must have the same length. Rows must be in chronological order.}
\item{...}{not used.}
}
\value{
-\code{predict.traveltime.no_dependence} returns a vector of size \code{n} of representing the point prediction of total travel time, in seconds, for each run.
+\code{predict.traveltimeHMM.no_dependence} returns a vector of size \code{n} of representing the point prediction of total travel time, in seconds, for each run.
}
\description{
Predict the travel time for a trip using a \code{traveltimeHMM} model object that is not of the HMM family
@@ -44,8 +51,8 @@ Predict the travel time for a trip using a \code{traveltimeHMM} model object tha
\keyword{The}
\keyword{Woodard}
\keyword{\code{HMM}}
-\keyword{\code{predict.traveltime.no_dependence}}
-\keyword{\code{predict.traveltime}).}
+\keyword{\code{predict.traveltimeHMM.no_dependence}}
+\keyword{\code{predict.traveltimeHMM}).}
\keyword{\code{traveltimeHMM}}
\keyword{a}
\keyword{al.,}
diff --git a/man/time_bins_functional.Rd b/man/time_bins_functional.Rd
index 145ab88..dd868ee 100644
--- a/man/time_bins_functional.Rd
+++ b/man/time_bins_functional.Rd
@@ -4,8 +4,10 @@
\alias{time_bins_functional}
\title{Transforms a list of rules to a functional}
\usage{
-time_bins_functional(time_bin_readable_function = time_bins_readable,
- period = c("hours", "minutes"))
+time_bins_functional(
+ time_bin_readable_function = time_bins_readable,
+ period = c("hours", "minutes")
+)
}
\arguments{
\item{rules}{...}
diff --git a/man/traveltimeHMM.Rd b/man/traveltimeHMM.Rd
index 8334ade..7558291 100644
--- a/man/traveltimeHMM.Rd
+++ b/man/traveltimeHMM.Rd
@@ -4,11 +4,23 @@
\alias{traveltimeHMM}
\title{Estimate trip- and link- specific speed parameters from observed average speeds}
\usage{
-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)
+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
+)
}
\arguments{
\item{logspeeds}{A numeric vector of speed observations (in km/h) on the (natural) log-scale. Needs
diff --git a/man/tripset.Rd b/man/tripset.Rd
index 30c1cd2..6c03d91 100644
--- a/man/tripset.Rd
+++ b/man/tripset.Rd
@@ -4,7 +4,8 @@
\name{tripset}
\alias{tripset}
\title{A sample of 4914 trips over Quebec City in 2014}
-\format{A data frame with 322799 rows and 7 variables:
+\format{
+A data frame with 322799 rows and 7 variables:
\describe{
\item{tripID}{a numeric unique trip ID}
\item{linkID}{a numeric ID representing differet road links}
@@ -13,7 +14,8 @@
\item{traveltime}{the travel time of corresponding trip on the specified linkId in seconds}
\item{length}{the trip driving length in meters over the corresponding linkId}
\item{time}{the first observed GPS timestamp on the corresponding linkId of that trip}
-}}
+}
+}
\usage{
tripset
}