Calculates a bound for the log of the ratio of interim time of two samples
(referred to as baseline and treatment) based on partial interval recording (PIR) data,
assuming that the average event durations are equal across samples and that
interim times are exponentially distributed.
factor or vector indicating levels of the PIR measurements.
base_level
a character string or value indicating the name of the baseline level.
conf_level
Desired coverage rate of the calculated confidence interval. Default is .95.
intervals
the number of intervals in the sample of observations. Default is NA
exponentiate
Logical value indicating if the log of the bounds and the confidence interval should be exponentiated. Default is FALSE.
Details
The interim ratio estimate is based on the assumptions that
1) the underlying behavior stream follows an Alternating Renewal Process,
2) the average event durations in each sample are equal, and
3) interim times follow exponential distributions.
The PIR vector can be in any order corresponding to the factor or vector phase.
The levels of phase can be any two levels, such as "A" and "B", "base" and "treat",
or "0" and "1". If there are more than two levels in phase this function will not work.
A value for base_level must be specified; if it is a chaaracter string it is case sensitive.
intervals is the number of intervals in the observations.
This is a single value and is assumed to be constant across both samples and all observations.
If intervals is sent as a vector instead of a single value, the first value in the vector will
be used. This value is only relevant if the mean of one of the samples is at the floor or ceiling
of 0 or 1. In that case it will be used to truncate the sample mean. If the sample mean is at the
floor or ceiling and no value for intervals is provided, the function will stop.
Value
A list with three named entries
The first entry, estimate_bounds, contains the lower and upper bound for the estimate of the prevalence ratio.
The second entry, estimate_SE, contains the standard errors for the upper and lower bounds.
The third entry, estimate_CI, contains the lower and upper bounds for the confidence interval of the prevalence ratio.
Author(s)
Daniel Swan <dswan@utexas.edu>
Examples
# Estimate bounds on the interim time ratio for Carl from the Moes dataset
data(Moes)
with(subset(Moes, Case == "Carl"),
interim_bounds(PIR = outcome, phase = Phase, base_level = "No Choice"))
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(ARPobservation)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/ARPobservation/interim_bounds.Rd_%03d_medium.png", width=480, height=480)
> ### Name: interim_bounds
> ### Title: Interim bounds and confidence interval
> ### Aliases: interim_bounds
>
> ### ** Examples
>
> # Estimate bounds on the interim time ratio for Carl from the Moes dataset
> data(Moes)
> with(subset(Moes, Case == "Carl"),
+ interim_bounds(PIR = outcome, phase = Phase, base_level = "No Choice"))
$estimate_bounds
lower_bound upper_bound
-1.331262 -1.277613
$estimate_SE
lower_SE upper_SE
0.9410545 0.9410545
$estimate_CI
lower_CI upper_CI
-3.1756949 0.5668204
>
>
>
>
>
> dev.off()
null device
1
>