Movatterモバイル変換


[0]ホーム

URL:


Title:Recurrent Event Data Analysis
Version:0.5.6
Description:Contains implementations of recurrent event data analysis routines including (1) survival and recurrent event data simulation from stochastic process point of view by the thinning method proposed by Lewis and Shedler (1979) <doi:10.1002/nav.3800260304> and the inversion method introduced in Cinlar (1975, ISBN:978-0486497976), (2) the mean cumulative function (MCF) estimation by the Nelson-Aalen estimator of the cumulative hazard rate function, (3) two-sample recurrent event responses comparison with the pseudo-score tests proposed by Lawless and Nadeau (1995) <doi:10.2307/1269617>, (4) gamma frailty model with spline rate function following Fu, et al. (2016) <doi:10.1080/10543406.2014.992524>.
Imports:Rcpp, graphics, methods, splines2 (≥ 0.4.3), stats
LinkingTo:Rcpp, RcppArmadillo
Suggests:ggplot2, grDevices, knitr, rmarkdown, tinytest,
Depends:R (≥ 3.2.3)
License:GPL (≥ 3)
LazyData:true
VignetteBuilder:knitr
Collate:'RcppExports.R' 'class.R' 'Recur.R' 'Survr.R' 'aic.R''baseline.R' 'coef.R' 'data.R' 'mcf-generic.R' 'mcf-formula.R''mcf-rateReg.R' 'mcfDiff.R' 'misc.R' 'plot.R' 'rateReg.R''reda-package.R' 'show.R' 'simEvent.R' 'summary.R' 'zzz.R'
URL:https://wwenjie.org/reda,https://github.com/wenjie2wang/reda
BugReports:https://github.com/wenjie2wang/reda/issues
Encoding:UTF-8
RoxygenNote:7.3.2
NeedsCompilation:yes
Packaged:2025-09-02 13:02:51 UTC; wenjie
Author:Wenjie WangORCID iD [aut, cre], Haoda Fu [aut], Sy Han (Steven) Chiou [ctb], Jun YanORCID iD [ctb]
Maintainer:Wenjie Wang <wang@wwenjie.org>
Repository:CRAN
Date/Publication:2025-09-02 14:00:07 UTC

Recurrent Event Data Analysis

Description

The R packagereda provides functions for simulating, exploring andmodeling recurrent event data.

Details

The main functions are summarized as follows:

See the package vignettes for more introduction and demonstration.

Author(s)

Maintainer: Wenjie Wangwang@wwenjie.org (ORCID)

Authors:

Other contributors:

See Also

Useful links:


Akaike Information Criterion (AIC)

Description

AIC,rateReg-method is an S4 class method calculating Akaikeinformation criterion (AIC) for one or severalrateReg objects,according to the formula - 2 * log-likelihood + 2 * nPar, where nParrepresents the number of parameters in the fitted model.

Usage

## S4 method for signature 'rateReg'AIC(object, ..., k = 2)

Arguments

object

An object used to dispatch a method.

...

Optionally more fitted model objects.

k

An optional numeric value used as the penalty per parameter. Thedefaultk = 2 is the classic AIC.

Details

When comparing models fitted by maximum likelihood to the same data, thesmaller the AIC, the better the fit. A friendly warning will be thrown outif the numbers of observation were different in the model comparison.help(AIC, stats) for other details.

Value

If just one object is provided, a numeric value representingcalculated AIC. If multiple objects are provided, a data frame withrows corresponding to the objects and columnsdf andAIC,wheredf means degree of freedom, which is the number ofparameters in the fitted model.

See Also

rateReg for model fitting;summary,rateReg-method for summary of a fitted model;BIC,rateReg-method for BIC.

Examples

## See examples given in function rateReg.

Bayesian Information Criterion (BIC)

Description

BIC,rateReg-method is an S4 class method calculatingBayesian information criterion (BIC) or so-calledSchwarz's Bayesian criterion (SBC)for one or severalrateReg objects,according to the formula- 2 * log-likelihood + ln(nObs) * nPar,where nPar represents the number of parameters in the fitted modeland nObs is the number of observations.

Usage

## S4 method for signature 'rateReg'BIC(object, ...)

Arguments

object

An object used to dispatch a method.

...

More fitted model objects.

Details

When comparing models fitted by maximum likelihood to the samedata, the smaller the BIC, the better the fit.help(BIC, stats) for other details.

Value

If just one object is provided, a numeric value representingcalculated BIC.If multiple objects are provided, a data frame with rowscorresponding to the objects and columnsdf andBIC,wheredf means degree of freedom,which is the number of parameters in the fitted model.

See Also

rateReg for model fitting;summary,rateReg-method for summary of a fitted model;AIC,rateReg-method for AIC.

Examples

## See examples given in function rateReg.

Formula Response for Recurrent Event Data

Description

Create an S4 class object that represents formula response for recurrentevent data with optional checking procedures embedded.

Usage

Recur(  time,  id,  event,  terminal,  origin,  check = c("hard", "soft", "none"),  ...)

Arguments

time

A numerical vector representing the time of reccurence event orcensoring, or a list with elements named"time1" and"time2" for specifying the follow-up of recurrent events. In thelatter case, function%to% (or%2%) can be used forease of typing. In addition to numeric values,Date anddifftime are allowed and converted to numeric values. An errorwill be thrown if this argument is not specified.

id

Subject identificators. It can be numeric vector, charactervector, or a factor vector. If it is left unspecified,Recurwill assume that each row represents a subject.

event

A numeric vector that may represent the status, costs, or typesof the recurrent events. Logical vector is allowed and converted tonumeric vector. Non-positive values are internally converted to zeroindicating censoring status.

terminal

A numeric vector that may represent the status, costs, ortypes of the terminal events. Logical vector is allowed and convertedto numeric vector. Non-positive values are internally converted to zeroindicating censoring status. If a scalar value is specified, allsubjects will have the same status of terminal events at their lastrecurrent episodes. The length of the specifiedterminal shouldbe equal to the number of subjects, or number of data rows. In thelatter case, each subject may have at most one positive entry ofterminal at the last recurrent episode.

origin

The time origin of each subject. If a scalar value isspecified, all subjects will have the same origin at the specifiedvalue. The length of the specifiedorigin should be equal to thenumber of subjects, or number of data rows. In the latter case,different subjects may have different origins. However, one subjectmust have the same origin. In addition to numeric values,Dateanddifftime are also supported and converted to numeric values.

check

A character value specifying how to perform the checks forrecurrent event data. Errors or warnings will be thrown, respectively,if thecheck is specified to be"hard" (by default) or"soft". Ifcheck = "none" is specified, no data checkingprocedure will be run.

...

Other arguments for future usage. A warning will be thrown ifany invalid argument is specified.

Details

This is a successor function of the deprecated functionSurvr. Seethe vignette by 'vignette("reda-Recur")' for details.

Value

AnRecur object.

Examples

library(reda)with(valveSeats, Recur(Days, ID))with(valveSeats, Recur(Days, ID, No.))with(valveSeats, Recur(Days, ID, No., terminal = 1))with(valveSeats, Recur(Days, ID, No., origin = 10))

An S4 Class Representing Formula Response for Recurrent Event Data

Description

The classRecur is an S4 that represents a formula response forrecurrent event data model. The functionRecur producesobjects of this class. See “Slots” for details.

Slots

.Data

A numeric matrix that consists of the following columns:

  • time1: the beginning of time segements;

  • time2: the end of time segements;

  • id: Identificatorsof subjects;

  • event: Event indicators;

  • :terminal: Indicators of terminal events.

call

A function call producing the object.

ID

A character vector for unique original identificators of subjects.

ord

An integer vector for increasingly ordering data byid,time2, and- event. Sorting is often done in themodel-fitting steps, where the indices stored in this slot can be useddirectly.

rev_ord

An integer vector for reverting the ordering of the sorteddata (byord) to its original ordering. This slot is provided toeasily revert the sorting.

first_idx

An integer vector indicating the first record of eachsubject in the sorted matrix. It helps in the data checking produce andmay be helpful in model-fitting step, such as getting the origin time.

last_idx

An integer vector indicating the last record of each subjectin the sorted data. Similar tofirst_idx, it helps in the datachecking produce and may be helpful in the model-fitting step, such aslocating the terminal events.

check

A character string indicating how the data checking isperformed. It just records the option that users specified on datachecking.

time_class

A character vector preserving the class(es) of input times.

See Also

Recur


Recurrent Episodes

Description

Specify time segements or recurrent episodes by endpoints.

Usage

time1 %to% time2time1 %2% time2

Arguments

time1

The left end-points of the recurrent episodes.

time2

The right end-points of the recurrent episodes.

Details

This function is intended to be used for specifying the argumenttimein functionRecur.

Value

A list that consists of two elements named"time1" and"time2".


Formula Response for Recurrent Event Data

Description

Create an S4 class that represents formula response for recurrent event datamodeled by methods based on counts and rate function. Note that thefunction is deprecated since version 0.5.0 and will be removed in future.

Usage

Survr(ID, time, event, origin = 0, check = TRUE, ...)

Arguments

ID

Subject identificators. It can be numeric vector, charactervector, or a factor vector.

time

Time of reccurence event or censoring. In addition to numericvalues,Date anddifftime are supported and converted tonumeric values.

event

A numeric vector indicating failure cost or event indicatortaking positive values as costs (1 as events), and non-positivevalues as censoring. Logical vector is allowed and will be converted tonumeric vector.

origin

The time origin of each subject or process. In addition tonumeric values,Date anddifftime are also supported andconverted to numeric values. Different subjects may have differentorigins. However, one subject must have the same origin.

check

A logical value suggesting whether to perform data checkingprocedure. The default value isTRUE.FALSE should be setwith caution and only for processed data already in recerruent eventdata framework.

...

Other arguments for future usage.

Details

This is a similar function toSurvr in packagesurvrec but with a more considerate checking procedure embedded forrecurrent event data modeled by methods based on counts and rate function.The checking rules apply to each subject respectively and include that


An S4 Class Representing Formula Response

Description

The classSurvr is an S4 that represents a formula response forrecurrent event data model. The functionSurvr producesobjects of this class. See “Slots” for details.

Slots

.Data

A numeric matrix object.

ID

A charactrer vector for original subject identificator.

check

A logical value indicating whether to performance data checking.

ord

An integer vector for increasingly ordering data byID,time, and1 - event.

See Also

Survr


Convert An Recur Object to A Character Vector

Description

Summarize and convert the recurrent episodes for each subjects intocharacter strings.

Usage

## S4 method for signature 'Recur'as.character(x, ...)

Arguments

x

An Recur object.

...

Other arguments for future usage.

Details

This function is intended to be a helper function for the 'show()' method of'Recur' objects. To be precise, the function set the maximum number ofrecurrent episodes for each subject to be 'max(2L,as.integer(getOption("reda.Recur.maxPrint")))'. By default, at most threerecurrent episodes will be summarized for printing. When subjects havingmore than three recurrent episodes, the first'getOption("reda.Recur.maxPrint") - 1' number of recurrent episodes and thelast one will be summarized. One may use 'options()' to adjust the setting.For example, the default value is equivalent to 'options(reda.Recur.maxPrint= 3)'.


Estimated Baseline Rate Function

Description

An S4 class generic function that returns the estimated baseline ratefunction.

Usage

baseRate(object, ...)## S4 method for signature 'rateReg'baseRate(object, level = 0.95, control = list(), ...)

Arguments

object

An object used to dispatch a method.

...

Other arguments for future usage.

level

An optional numeric valueindicating the confidence level required. The default value is 0.95.

control

An optional list to specify the time gridwhere the baseline rate function is estimated.The availble elements of the control list includegrid,length.out,from andto.The time grid can be directly specified via elementgrid.A dense time grid is suggested.Elementlength.out represents the length of grid points.The dafault value is 1,000.Elementfrom means the starting point of grid with default 0.Elementto represnts the endpoint of gridwith the right boundary knot as default.Whengrid is missing, the grid will be generatedbyseq (from packagebase)with argumentsfrom,to andlength.out.

Value

AbaseRate object.

Functions

See Also

rateReg for model fitting;summary,rateReg-method for summary of a fitted model;plot,baseRate.rateReg-method for ploting method.

Examples

## See examples given in function rateReg.

An S4 Class Representing Estimated Baseline Rate Function

Description

An S4 class that represents the estimated baseline rate function from model.The functionbaseRate produces objects of this class.

Slots

baseRate

A data frame.

level

A numeric value.

See Also

baseRate,rateReg-method


Checks for Recurrent Event Data

Description

Perform several checks for recurrent event data and update objectattributions if some rows of the contained data (in the.Data slot)have been removed by such asna.action.

Usage

check_Recur(x, check = c("hard", "soft", "none"))

Arguments

x

AnRecur object.

check

A character value specifying how to perform the checks forrecurrent event data. Errors or warnings will be thrown, respectively,if thecheck is specified to be"hard" (by default) or"soft". Ifcheck = "none" is specified, no data checkingprocedure will be run.

Value

AnRecur object invisibly.


Estimated Coefficients of Covariates

Description

coef,rateReg-method is an S4 class method that extracts estimatedcoefficients of covariates fromrateReg object produced by functionrateReg.

Usage

## S4 method for signature 'rateReg'coef(object, ...)

Arguments

object

ArateReg object.

...

Other arguments for future usage.

Value

A named numeric vector.

See Also

rateReg for model fitting;confint,rateReg-method for confidence intervalsfor covariate coefficients;summary,rateReg-method for summary of a fitted model.

Examples

## See examples given in function rateReg.

Confidence Intervals for Covariate Coefficients

Description

confint,rateReg-method is an S4 class method forrateReg object, which returns approximate confidence intervalsfor all or specified covariates.

Usage

## S4 method for signature 'rateReg'confint(object, parm, level = 0.95, ...)

Arguments

object

ArateReg object.

parm

A specification of which parameters are to be given confidenceintervals, either a vector of numbers or a vector of names. If missing,all parameters are considered.

level

An optional numeric value to specify the confidence levelrequired. By default, the value is 0.95, which produces 95% confidenceintervals.

...

Other arguments for future usage.

Details

Under regularity condition (Shao 2003, Theorem 4.16 and Theorem 4.17, page287, 290), the approximate confidence intervals are constructed looselybased on Fisher information matrix and estimates of coefficients.

Value

A numeric matrix with row names and column names.

References

Shao, J. (2003),Mathematical statistics,Springer texts in statistics, New York: Springer, 2nd Edition.

See Also

rateReg for model fitting;coef,rateReg-method for point estimatesof covariate coefficients;summary,rateReg-method for summary of a fitted model.

Examples

## See examples given in function rateReg.

Is the xect from the Recur class?

Description

ReturnTRUE if the specified xect is from theRecurclass,FALSE otherwise.

Usage

is.Recur(x)

Arguments

x

AnR xect.

Value

A logical value.


Mean Cumulative Function (MCF)

Description

An S4 class generic function that returns the mean cumulative function (MCF)estimates from a fitted model or returns the nonparametric MCF estimates (byNelson-Aalen estimator or Cook-Lawless cumulative sample mean estimator)from the sample data.

Usage

mcf(object, ...)## S4 method for signature 'formula'mcf(  object,  data,  subset,  na.action,  variance = c("LawlessNadeau", "Poisson", "bootstrap", "CSV", "none"),  logConfInt = FALSE,  adjustRiskset = TRUE,  level = 0.95,  control = list(),  ...)## S4 method for signature 'rateReg'mcf(  object,  newdata,  groupName,  groupLevels,  level = 0.95,  na.action,  control = list(),  ...)

Arguments

object

An object used to dispatch a method.

...

Other arguments for future usage.

data

A data frame, list or environment containing the variables inthe model. If not found in data, the variables are taken fromenvironment(formula), usually the environment from which thefunction is called.

subset

An optional vector specifying a subset of observations to beused in the fitting process.

na.action

A function that indicates what should the procedure do ifthe data containsNAs. The default is set by the na.actionsetting ofoptions. The "factory-fresh" default isna.omit. Other possible values inlcudena.fail,na.exclude, andna.pass.help(na.fail) for details.

variance

A character specifying the method for variance estimates.The available options are"LawlessNadeau" (the default) forLawless and Nadeau (1995) method,"Poisson" for Poisson processmethod,"bootstrap" for bootstrap method,"CSV" forvariance estimates of the corresponding cumulative sample mean function(CSM) by the cumulative sample variance method (Cook and Lawless, 2007),and"none" for no variance estimates. Partial matching on thenames is allowed.

logConfInt

A logical value. IfFALSE (the default), theconfidence interval are constructed based on the normality of the MCFestimates. Otherwise, the confidence intervals of given level areconstucted based on the normality of logarithm of the MCF estimates.

adjustRiskset

A logical value indicating whether to adjust the sizeof risk-set. IfTRUE by default, the size of risk-set will beadjusted based on at-risk indicators and Nelson-Aalen estimator will bereturned. Otherwise, the cumulative sample mean (CSM) function given byCook and Lawless (2007) will be returned without adjustment on size ofrisk-set.

level

An optional numeric value indicating the confidence levelrequired. The default value is 0.95.

control

An optional named list specifying other options. ForrateReg object, it can be used to specify the time grid where theMCF is estimated. The available named elements are given as follows:

  • grid: The time grid where MCF is estimated. A densegrid is suggested for further using the plot method.

  • length.out: The length of grid points. The dafaultvalue is 1,000.

  • from: The starting point of grid. The default value isthe left boundary knots (forrateReg object).

  • to: The endpoint of grid. The default value is theright boundary knots (forrateReg object).

The optionlength.out,from,to will be ignored ifgrid is specified directly. Otherwise, the grid will be generatedby functionseq.int with specifiedfrom,to andlength.out.

For formula method, the available named elements are given as follows:

  • B: The number of bootstrap replicates for usingbootstrap method for variance estimates of sample MCF estimates.The default value is 200.

  • se.method: The method used for SE estimates forbootstrap. The available methods include"sample.se"(the default) and"normality". The former takes thesample SE of point estimates from bootstrap samples; The latterestimates SE based on interquantile and normality assumption.

  • ci.method: The method used for confidence interval (CI)for bootstrap. The available options include"normality"(the default) and"percentile". The former estimates theCI based on SE estimates and normality assumption; The lattertakes percentiles of the bootstrap estimates.

  • keep.data: A logical value specifying whether to keep theprocessed data in the output object. IfTRUE(the default), the processed data will be kept in the output andavailable for later usage. Otherwise, an empty dataframe object will be returned in thedata slot.FALSE may be set when the memory consumption isof concern and we only need MCF estimates. For example, thefunctionmcfDiff andmcfDiff.test will not beapplicable for themcf.formula object with an emptydata slot.

  • verbose: A logical value. The default value isTRUE. IfFALSE, possible data checking messages(not including warnings or errors) will be suppressed.

newdata

An optional data frame. If specified, the data frame shouldhave the same column names as the covariate names appearing in theformula of original fitting.

groupName

An optional length-one charactor vector to specify the namefor grouping each unique row innewdata, such as "gender" for"male" and "female". The default value is "Group".

groupLevels

An optional charactor vector to specify the levels foreach unique row innewdata, such as "treatment" and "control".The default values are"Level" followed by a numeric sequencewith length of number of levels.

Details

Forformula object withRecur object as response, thecovariate specified at the right hand side of the formula should be either1 or any "linear" conbination of categorical variable in the data.The former computes the overall sample MCF. The latter computes the sampleMCF for each level of the combination of the categorical variable(s)specified, respectively.

The MCF estimates are computed on each unique time point of the sample data.By default, the size of risk set is adjusted over time based on the at-riskindicators, which results in the Nelson-Aalen nonparametric estimator(Nelson 2003). If the size of risk set remains a constant (total number ofprocesses) over time (specified byadjustRiskset = FALSE), thecumulative sample mean (CSM) function introduced in Chapter 1 of Cook andLawless (2007) will be computed instead. The point estimate of sample MCFat each time point does not assume any particular underlying model. Thevariance estimates at each time point is computed following the Lawless andNadeau method (LawLess and Nadeau 1995), the Poisson process method, or thebootstrap methods. The approximate confidence intervals are provided aswell, which are constructed based on the asymptotic normality of the MCFitself (by default) or the logarithm of MCF.

ForrateReg object,mcf estimates the baseline MCF and itsconfidence interval at each time grid if argumentnewdata is notspecified. Otherwise,mcf estimates MCF and its confidence intervalfor the givennewdata based on Delta-method.

Value

Amcf.formula ormcf.rateReg object.

A brief description of the slots of amcf.formula object is given asfollows:

Most slots of amcf.rateReg object are inherited from the inputrateReg object. A brief description of other slots is given asfollows:

Functions

References

Cook, R. J., and Lawless, J. (2007).The statistical analysis ofrecurrent events, Springer Science & Business Media.

Lawless, J. F. and Nadeau, C. (1995). Some Simple Robust Methods for theAnalysis of Recurrent Events.Technometrics, 37, 158–168.

Nelson, W. B. (2003).Recurrent Events Data Analysis for ProductRepairs, Disease Recurrences, and Other Applications (Vol. 10). SIAM.

See Also

rateReg for model fitting;mcfDiff for comparing two-sample MCFs.plot-method for plotting MCF.

Examples

library(reda)### sample MCF## Example 1. valve-seat data## the default variance estimates by Lawless and Nadeau (1995) methodvalveMcf0 <- mcf(Recur(Days, ID, No.) ~ 1, data = valveSeats)plot(valveMcf0, conf.int = TRUE, mark.time = TRUE, addOrigin = TRUE) +    ggplot2::xlab("Days") + ggplot2::theme_bw()## variance estimates following Poisson process modelvalveMcf1 <- mcf(Recur(Days, ID, No.) ~ 1,                 data = valveSeats, variance = "Poisson")## variance estimates by bootstrap method (with 1,000 bootstrap samples)set.seed(123)valveMcf2 <- mcf(Recur(Days, ID, No.) ~ 1,                 data = valveSeats, variance = "bootstrap",                 control = list(B = 200))## comparing the variance estimates from different methodslibrary(ggplot2)ciDat <- rbind(cbind(valveMcf0@MCF, Method = "Lawless & Nadeau"),               cbind(valveMcf1@MCF, Method = "Poisson"),               cbind(valveMcf2@MCF, Method = "Bootstrap"))ggplot(ciDat, aes(x = time, y = se)) +    geom_step(aes(color = Method, linetype = Method)) +    xlab("Days") + ylab("SE estimates") + theme_bw()## comparing the confidence interval estimates from different methodsggplot(ciDat, aes(x = time)) +    geom_step(aes(y = MCF)) +    geom_step(aes(y = lower, color = Method, linetype = Method)) +    geom_step(aes(y = upper, color = Method, linetype = Method)) +    xlab("Days") + ylab("Confidence intervals") + theme_bw()## Example 2. the simulated datasimuMcf <- mcf(Recur(time, ID, event) ~ group + gender,               data = simuDat, ID %in% 1 : 50)plot(simuMcf, conf.int = TRUE, lty = 1 : 4,     legendName = "Treatment & Gender")### estimate MCF difference between two groups## one sample MCF object of two groupsmcf0 <- mcf(Recur(time, ID, event) ~ group, data = simuDat)## two-sample pseudo-score testsmcfDiff.test(mcf0)## difference estimates over timemcf0_diff <- mcfDiff(mcf0, testVariance = "none")plot(mcf0_diff)## or explicitly ask for the difference of two sample MCFmcf1 <- mcf(Recur(time, ID, event) ~ 1, data = simuDat,            subset = group %in% "Contr")mcf2 <- mcf(Recur(time, ID, event) ~ 1, data = simuDat,            subset = group %in% "Treat")## perform two-sample tests and estimate difference at the same timemcf12_diff1 <- mcfDiff(mcf1, mcf2)mcf12_diff2 <- mcf1 - mcf2   # or equivalently using the `-` methodstopifnot(all.equal(mcf12_diff1, mcf12_diff2))mcf12_diff1plot(mcf12_diff1)### For estimated MCF from a fitted model,### see examples given in function rateReg.

An S4 Class Representing Sample MCF

Description

An S4 class that represents sample mean cumulative function (MCF) from data.The functionmcf produces objects of this class.

Slots

formula

Formula.

data

A data frame.

MCF

A data frame.

origin

A named numeric vector.

multiGroup

A logical value.

variance

A character vector.

logConfInt

A logical value.

level

A numeric value.

See Also

mcf,formula-method.


An S4 Class Respresenting Estimated MCF from a Fitted Model

Description

An S4 class that represents estimated mean cumulative function (MCF) fromModels. The functionmcf produces objects of this class.

Slots

call

Function call.

formula

Formula.

spline

A character.

knots

A numeric vector.

degree

A nonnegative integer.

Boundary.knots

A numeric vector.

newdata

A numeric matrix.

MCF

A data frame.

level

A numeric value between 0 and 1.

na.action

A length-one character vector.

control

A list.

multiGroup

A logical value.

See Also

mcf,rateReg-method


Comparing Two-Sample MCFs

Description

This function estimates the sample MCF difference between two groups. Boththe point estimates and the confidence intervals are computed (Lawless andNadeau 1995). The two-sample pseudo-score test proposed by Cook, Lawless,and Nadeau (1996) is also performed by default.

Usage

mcfDiff(mcf1, mcf2 = NULL, level = 0.95, ...)mcfDiff.test(  mcf1,  mcf2 = NULL,  testVariance = c("robust", "Poisson", "none"),  ...)

Arguments

mcf1

Amcf.formula object representing the MCF for one or twogroups.

mcf2

An optional secondmcf.formula object orNULL.

level

A numeric value indicating the confidence level required. Thedefault value is 0.95.

...

Other arguments passed tomcfDiff.test.

testVariance

A character string specifying the method for computingthe variance estimate for the pseudo-score test statistic proposed byCook, Lawless, and Nadeau (1996). The applicable options include"robust" (default) for an estimate robust to departures fromPoisson assumptions,"Poisson" for an estimate for Poissonprocess, and"none" for not performing any test (if only thedifference estimates are of interest inmcfDiff).

Details

The functionmcfDiff estimates the two-sample MCFs' difference andinternally calls functionmcfDiff.test to perform the pseudo-scoretests by default. A- method is available as a simple wrapper for thefunctionmcfDiff for comparing two-sample MCFs from twomcf.formula objects. For instance, supposemcf1 andmcf2 aremcf.formula objects, each of which represents thesample MCF estimates for one group. The function callmcf1 - mcf2 isequivalent tomcfDiff(mcf1, mcf2).

The null hypothesis of the two-sample pseudo-score test is that there is nodifference between the two sample MCFs, while the alternative hypothesissuggests a difference. The test is based on a family of test statisticsproposed by Lawless and Nadeau (1995). The argumenttestVariancespecifies the method for computing the variance estimates of the teststatistics under different model assumption. See the document of argumenttestVariance for all applicable options. For the variance estimatesrobust to departures from Poisson process assumption, both constant weightand the linear weight function (with scaling) suggested in Cook, Lawless,and Nadeau (1996) are implemented. The constant weight is powerful in caseswhere the two MCFs are approximately proportional to each other. The linearweight function is originallya(u) = t - u, whereu representsthe time variable andt is the first time point when the risk set ofeither group becomes empty. It is further scaled by1 / t for teststatistics invariant to the unit of measurement of the time variable. Thelinear weight function puts more emphasis on the difference at earily timesthan later times and is more powerful for cases where the MCFs are no longerproportional to each other, but not crossing. Also see Cook and Lawless(2007, Section 3.7.5) for more details.

Value

The functionmcfDiff returns amcfDiff object (of S4 class)that contains the following slots:

The functionmcfDiff.test returns amcfDiff.test object (of S4class) that contains the following slots:

References

Lawless, J. F., & Nadeau, C. (1995). Some Simple Robust Methods for theAnalysis of Recurrent Events.Technometrics, 37(2), 158–168.

Cook, R. J., Lawless, J. F., & Nadeau, C. (1996). Robust Tests for TreatmentComparisons Based on Recurrent Event Responses.Biometrics, 52(2),557–571.

Cook, R. J., & Lawless, J. (2007).The Statistical Analysis ofRecurrent Events. Springer Science & Business Media.

Examples

## See examples given for function mcf.

An S4 Class Representing Sample MCF Difference

Description

An S4 class that represents the difference between two sample meancumulative functions from data. The functionmcfDiffproduces objects of this class.

Slots

call

A function call.

MCF

A data frame.

origin

A named numeric vector.

variance

A character vector.

logConfInt

A logical value.

level

A numeric value.

test

AmcfDiff.test class object.

See Also

mcfDiff


An S4 Class Representing the Two-Sample Pseudo-Score Test Results

Description

An S4 class that represents the results of the two-sample pseudo-score testsbetween two sample mean cumulative functions. The functionmcfDiff.test produces objects of this class.

Slots

.Data

A numeric matrix.

testVariance

A character vector.

See Also

mcfDiff.test


Parametrizations of Covariates and Covariate Coefficients

Description

This function helps the parametrizations of covariates and covariatecoeffcients when users specify a general hazard rate function in functionsimEvent andsimEventData. It applies the specified function(or the built-in option)FUN to thei_{th} row of the covariatematrixz and thei_{th} row of the coefficient matrix,iteratively, fori from one to the number of rows of the covariatematrixz.

Usage

parametrize(z, zCoef, FUN = c("exponential", "linear", "excess"), ...)

Arguments

z

A numeric matrix, each row of which represents the covariate vectorat one perticular time point.

zCoef

A numeric matrix, each row of which represents the covariatecoeffcient vector at one perticular time point.

FUN

The parametrization of the model parameter(s) with covariates andcovariate coefficients. The built-in options include"exponential","linear","excess" forparametrization in the exponential, linear, excess relative risk modelform, respectively. It can also be a function that at least has argumentz andzCoef for incorporating the covariates and covariatecoefficients into the model. The user-specified function should expectthat both the inputz andzCoef are numeric vectors andreturn a numeric value (or can be convected to a numeric value byas.numeric).

...

Other arguments that can be passed to the functionFUN.

Value

A numeric vector.

See Also

simEvent

Examples

## time pointstimeVec <- c(0.5, 2)## time-variant covariateszMat <- cbind(0.5, ifelse(timeVec > 1, 1, 0))## time-varying coefficientszCoefMat <- cbind(sin(timeVec), timeVec)## the following three ways are equivalent for the exponential form,## where the first one (using the built-in option) has the best performanceparametrize(zMat, zCoefMat, FUN = "exponential")parametrize(zMat, zCoefMat, function(z, zCoef) exp(z %*% zCoef))sapply(1 : 2, function(i) as.numeric(exp(zMat[i, ] %*% zCoefMat[i, ])))

Plot Baseline Rate or Mean Cumulative Function (MCF)

Description

S4 class methods plotting sample MCF from data, estimated MCF, or estimatedbaseline hazard rate function from a fitted model by usingggplot2plotting system. The plots generated are thus able to be further customizedproperly.

Usage

## S4 method for signature 'mcf.formula,missing'plot(  x,  y,  lty,  col,  legendName,  legendLevels,  conf.int = FALSE,  mark.time = FALSE,  addOrigin = FALSE,  ...)## S4 method for signature 'mcf.rateReg,missing'plot(x, y, conf.int = FALSE, lty, col, ...)## S4 method for signature 'baseRate.rateReg,missing'plot(x, y, conf.int = FALSE, lty, col, ...)## S4 method for signature 'mcfDiff,missing'plot(  x,  y,  lty,  col,  legendName,  legendLevels,  conf.int = TRUE,  addOrigin = FALSE,  ...)

Arguments

x

An object used to dispatch a method.

y

An argument that should be missing and ignored now. Its existenceis just for satisfying the definition of generaic functionplotin packagegraphics for methods' dispatching.

lty

An optional numeric vector indicating line types specified todifferent groups: 0 = blank, 1 = solid, 2 = dashed, 3 = dotted, 4 =dotdash, 5 = longdash, 6 = twodash.

col

An optional character vector indicating line colors specified todifferent groups.

legendName

An optional length-one charactor vector to specify thename for grouping each unique row innewdata, such as "gender"for "male" and "female". The default value is generated from theobject.

legendLevels

An optional charactor vector to specify the levels foreach unique row innewdata, such as "treatment" and "control".The default values are generated from theobject.

conf.int

A logical value indicating whether to plot confidenceinterval. The default value isFALSE.

mark.time

A logical value with default valueFALSE. IfTRUE, each censoring time is marked by "+" on the MCF curves.Otherwise, the censoring time would not be marked.

addOrigin

A logical value indicating whether the MCF curves startfrom origin time. The default value isFALSE.

...

Other arguments for further usage.

Value

Aggplot object.

See Also

mcf for estimation of MCF;rateReg for model fitting.

Examples

## See examples given in function mcf and rateReg.

Recurrent Events Regression Based on Counts and Rate Function

Description

This function fits recurrent event data (event counts) by gamma frailtymodel with spline rate function. The default model is the gamma frailtymodel with one piece constant baseline rate function, which is equivalent tonegative binomial regression with the same shape and rate parameter in thegamma prior. Spline (including piecewise constant) baseline hazard ratefunction can be specified for the model fitting.

Usage

rateReg(  formula,  data,  subset,  na.action,  start = list(),  control = list(),  contrasts = NULL,  ...)rateReg.control(  df = NULL,  degree = 0L,  knots = NULL,  Boundary.knots = NULL,  periodic = FALSE,  verbose = TRUE,  ...)

Arguments

formula

Recur object produced by functionRecur.The terminal events and risk-free episodes specified inRecurwill be ignored since the model does not support them.

data

An optional data frame, list or environment containing thevariables in the model. If not found in data, the variables are takenfromenvironment(formula), usually the environment from whichfunctionrateReg is called.

subset

An optional vector specifying a subset of observations to beused in the fitting process.

na.action

A function that indicates what should the procedure do ifthe data containsNAs. The default is set by the na.actionsetting ofoptions. The "factory-fresh" default isna.omit. Other possible values inlcudena.fail,na.exclude, andna.pass. Seehelp(na.fail) fordetails.

start

An optional list of starting values for the parameters to beestimated in the model. See more in Section details.

control

An optional list of parameters to control the maximizationprocess of negative log likelihood function and adjust the baseline ratefunction. See more in Section details.

contrasts

An optional list, whose entries are values (numericmatrices or character strings naming functions) to be used asreplacement values for the contrasts replacement function and whosenames are the names of columns of data containing factors. Seecontrasts.arg ofmodel.matrix.default for details.

...

Other arguments passed torateReg.control() andstats::constrOptim().

df

A nonnegative integer to specify the degree of freedom of baselinerate function. If argumentknots ordegree are specified,df will be neglected whether it is specified or not.

degree

A nonnegative integer to specify the degree of spline bases.

knots

A numeric vector that represents all the internal knots ofbaseline rate function. The default isNULL, representing no anyinternal knots.

Boundary.knots

A length-two numeric vector to specify the boundaryknots for baseline rate funtion. By default, the left boundary knot isthe smallest origin time and the right one takes the largest censoringtime from data.

periodic

A logical value indicating if periodic splines should beused.

verbose

A logical value with defaultTRUE. Set it toFALSE to supress messages from this function.

Details

FunctionRecur in the formula response by default first checksthe dataset and will report an error if the dataset does not fall intorecurrent event data framework. Subject's ID will be pinpointed if itsobservation violates any checking rule. SeeRecur for all thechecking rules.

FunctionrateReg first constructs the design matrix fromthe specified arguments:formula,data,subset,na.action andconstrasts before model fitting.The constructed design matrix will be checked again tofit the recurrent event data frameworkif any observation with missing covariates is removed.

The model fitting process involves minimization of negative loglikelihood function, which calls functionconstrOptiminternally.help(constrOptim) for more details.

The argumentstart is an optional listthat allows users to specify the initial guess forthe parameter values for the minimization ofnegative log likelihood function.The available numeric vector elements in the list include

The argumentcontrol allows users to control the process ofminimization of negative log likelihood function passed toconstrOptim and specify the boundary knots of baseline rate function.

Value

ArateReg object, whose slots include

References

Fu, H., Luo, J., & Qu, Y. (2016).Hypoglycemic events analysis via recurrent time-to-event (HEART) models.Journal Of Biopharmaceutical Statistics, 26(2), 280–298.

See Also

summary,rateReg-method for summary of fitted model;coef,rateReg-method for estimated covariate coefficients;confint,rateReg-method for confidence interval ofcovariate coefficients;baseRate,rateReg-method for estimated coefficients of baselinerate function;mcf,rateReg-method for estimated MCF from a fitted model;plot,mcf.rateReg-method for plotting estimated MCF.

Examples

library(reda)## constant rate function(constFit <- rateReg(Recur(time, ID, event) ~ group + x1, data = simuDat))## six pieces' piecewise constant rate function(piecesFit <- rateReg(Recur(time, ID, event) ~ group + x1,                      data = simuDat, subset = ID %in% 1:50,                      knots = seq.int(28, 140, by = 28)))## fit rate function with cubic spline(splineFit <- rateReg(Recur(time, ID, event) ~ group + x1, data = simuDat,                      knots = c(56, 84, 112), degree = 3))## more specific summarysummary(constFit)summary(piecesFit)summary(splineFit)## model selection based on AIC or BICAIC(constFit, piecesFit, splineFit)BIC(constFit, piecesFit, splineFit)## estimated covariate coefficientscoef(piecesFit)coef(splineFit)## confidence intervals for covariate coefficientsconfint(piecesFit)confint(splineFit, "x1", 0.9)confint(splineFit, 1, 0.975)## estimated baseline rate functionsplinesBase <- baseRate(splineFit)plot(splinesBase, conf.int = TRUE)## estimated baseline mean cumulative function (MCF) from a fitted modelpiecesMcf <- mcf(piecesFit)plot(piecesMcf, conf.int = TRUE, col = "blueviolet")## estimated MCF for given new datanewDat <- data.frame(x1 = rep(0, 2), group = c("Treat", "Contr"))splineMcf <- mcf(splineFit, newdata = newDat, groupName = "Group",                 groupLevels = c("Treatment", "Control"))plot(splineMcf, conf.int = TRUE, lty = c(1, 5))## example of further customization by ggplot2library(ggplot2)plot(splineMcf) +    geom_ribbon(aes(x = time, ymin = lower,                    ymax = upper, fill = Group),                data = splineMcf@MCF, alpha = 0.2) +    xlab("Days")

An S4 Class Representing a Fitted Model

Description

The classrateReg is an S4 class that represents a fitted model. ThefunctionrateReg produces objects of this class. See“Slots” for details.

Slots

call

Function call.

formula

Formula.

nObs

A positive integer

spline

A list.

estimates

A list.

control

A list.

start

A list.

na.action

A character vector (of length one).

xlevels

A list.

contrasts

A list.

convergCode

A nonnegative integer.

logL

A numeric value.

fisher

A numeric matrix.

See Also

rateReg


Show an object.

Description

S4 class methods that display objects produced from this package (similar toS3 classprint methods).

Usage

## S4 method for signature 'Recur'show(object)## S4 method for signature 'rateReg'show(object)## S4 method for signature 'summary.rateReg'show(object)## S4 method for signature 'summary.Recur'show(object)## S4 method for signature 'mcf.formula'show(object)## S4 method for signature 'mcf.rateReg'show(object)## S4 method for signature 'simEvent'show(object)## S4 method for signature 'mcfDiff'show(object)## S4 method for signature 'mcfDiff.test'show(object)

Arguments

object

An object used to dispatch a method.


Simulated Survival times or Recurrent Events

Description

The functionsimEvent generates simulated recurrent events orsurvival time (the first event time) from one stochastic process. ThefunctionsimEventData provides a simple wrapper that callssimEvent internally and collects the generated survival data orrecurrent events into a data frame. More examples are available in one ofthe package vignettes in addition to the function documentation.

Usage

simEvent(  z = 0,  zCoef = 1,  rho = 1,  rhoCoef = 1,  rhoMax = NULL,  origin = 0,  endTime = 3,  frailty = 1,  recurrent = TRUE,  interarrival = "rexp",  relativeRisk = c("exponential", "linear", "excess", "none"),  method = c("thinning", "inversion"),  arguments = list(),  ...)simEventData(nProcess = 1, z = 0, origin = 0, endTime = 3, frailty = 1, ...)

Arguments

z

Time-invariant or time-varying covariates. The default value is0 for no covariate effect. This argument should be a numericvector for time-invariant covariates or a function of times that returnsa numeric matrix for time-varying covariates, where each row representsthe covariate vector at one perticular time point.

zCoef

Time-invariant or time-varying coefficients of covariates. Thedefault value is1. Similar to the argumentz, thisargument should be a numeric vector for time-invariant coefficients or afunction of times that returns a numeric matrix for time-varyingcoefficients, where each row represents the coefficient vector at oneperticular time point. The dimension of thez andzCoef(either specified or generated) has to match with each other.

rho

Baseline rate (or intensity) function for the Poisson process.The default is1 for a homogenous process of unit intensity. Thisargument can be either a non-negative numeric value for a homogenousprocess or a function of times for a non-homogenous process. In thelatter case, the function should be able to take a vector of time pointsand return a numerical matrix (or vector) with each row representing thebaseline hazard rate vector (or scalar value) at each time point.

rhoCoef

Coefficients of baseline rate function. The default value is1. It can be useful whenrho is a function generatingspline bases.

rhoMax

A positive number representing an upper bound of theunderlying rate function (excluding the frailty term but including thecovariate effect) for the thinning method. If this argument is leftunspecified, the function will try to determine an upper boundinternally.

origin

The time origin set to be0 by default. It should beeither a numeric value less thanendTime or a function thatreturns such a numeric value.

endTime

The end of follow-up time set to be3 by default.Similar toorigin,endTime should be either a numericvalue greater thanorigin or a function that returns such anumeric value.

frailty

A positive number or a function for frailty effect. Thedefault value is1 for no frailty effect. Other positive valuecan be specified directly for a shared frailty effect within a cluster.Similar toz,zCoef, andrho, a function can bespecified for other distribution of the frailty effect. The specifiedfunction should randomly return a positive numeric value. The functionsthat generate random numbers following a certain distribution fromstats package can be directly used. The arguments of the functioncan be specified through a list namedfrailty inarguments. For example, if we consider Gamma distribution withmean one as the distribution of frailty effect, we may specifyfrailty = "rgamma". The shape and scale parameter needs to bespecified through a list namedfrailty inarguments, suchasarguments = list(frailty = list(shape = 2, scale = 0.5)).

recurrent

A logical value with default valueTRUE indicatingwhether to generate recurrent event data or survival data.

interarrival

A function object for randomly generating (positive)interarrival time between two successive arrivals/events. The defaultvalue is"rexp" (i.e., functionstats::rexp) forgenerating interarrival times following exponential distribution, whichleads to a Poisson process. If the assumption of exponentialinterarrival times cannot be justified, we may consider a renewalprocess, (a generalization of Poisson process), in which interarrivaltimes between events independently follows an identical distribution. Acustomized function can be specified in this case. It must have at leastone argument namedrate for the expected number ofarrivals/events in unit time and returns one positive numericalvalue. If the function contains an argument namedn, it isassumed that the function returnsn interarrival times in onefunction call to possibly speed up the random number generationprocedure. Other arguments can be specified through a named list insidearguments.

relativeRisk

Relateive risk function for incorporating the covariatesand the covariate coefficients into the intensity function. Theapplicable choices includeexponential (the default) for theregular Cox model or Andersen-Gill model,linear for linear model(including an intercept term),excess for excess model, andnone for not incorporating the covariates through a relative riskfunction. A customized function can be specified. The specified functionmust have at least one argument namedz for the covariate vectorand another argument namedzCoef for covariate coefficient vector.The function should return a numeric value for givenz vector andzCoef vector. Other arguments can be specified through a namedlist insidearguments.

method

A character string specifying the method for generatingsimulated recurrent or survival data. The default method is thinningmethod (Lewis and Shedler 1979). Another available option is theinversion method (Cinlar 1975). When the rate function may go toinfinite, the inversion method is used and a warning will be thrown outif the thinning method is initially specified.

arguments

A list that consists of named lists for specifying otherarguments in the corresponding functions. For example, if a function oftime namedfoo with two arguments,x (for time) andy, is specified for the time-varying covariates, the value of itssecond argument,y, can be specified byarguments = list(z= list(y = 1). A partial matching on names is not allowed to avoidpossible misspecification. The input arguments will be evaluated withinfunctionsimEvent, which can be useful for randomly settingfunction parameters for each process in functionsimEventData. See examples and vignettes for details.

...

Additional arguements passed from functionsimEventData tofucntionsimEvent. For functionsimEvent,... isnot used.

nProcess

Number of stochastic processes. If missing, the value willbe the number of row of the specified matrixz. Otherwise, apositive number should be speicified.

Details

For each process, a time-invariant or time-varying baseline hazard rate(intensity) function of failure can be specified. Covariates and theircoefficients can be specified and incorporated by the specified relativerisk functions. The default is the exponential relative risk function, whichcorresponds to the Cox proportional hazard model (Cox 1972) for survivaldata or Andersen-Gill model (Andersen and Gill 1982) for recurrentevents. Other relative risk function can be specified through the argumentrelativeRisk. In addition, a frailty effect can be considered.Conditional on predictors (or covariates) and the unobserved frailty effect,the process is by default a Poisson process, where the interarrival timesbetween two successive arrivals/events follow exponential distribution. Ageneral renewal process can be specified throughinterarrival forother distributions of the interarrival times in addition to the exponentialdistribution.

The thinning method (Lewis and Shedler 1979) is applied for bounded hazardrate function by default. The inversion method (Cinlar 1975) is alsoavailable for possibly unbounded but integrable rate function over the giventime period. The inversion method will be used when the rate function may goto infinite and a warning will be thrown out if the thinning method isspecified originally.

For the covariatesz, the covariate coefficientszCoef, andthe baseline hazard rate functionrho, a function of time can bespecified for time-varying effect. The first argument of the input functionhas to be the time variable (not need to be named as "time" though). Otherarguments of the function can be specified through a named list inarguments, while the first argument should not be specified.

For the frailty effectfrailty, the starting pointorigin, andthe end point of the processendTime, functions that generate randomnumbers can be specified. An argumentn = 1 will be implicitlyspecified if the function has an argument namedn, which is designedfor those common functions generating random numbers fromstatspackage. Similar toz,zCoef, andrho, other argumentsof the function can be specified through a named list inarguments.

For time-varying covariates, the functionsimEventData assumescovariates can be observed only at event times and censoring times. Thus,covariate values are returned only at these time points. If we want otherobserved covariate values to be recorded, we may write a simple wrapperfunction forsimEvent similar tosimEventData.

Value

The functionsimEvent returns asimEvent S4 class object andthe functionsimEventData returns adata.frame.

References

Andersen, P. K., & Gill, R. D. (1982). Cox's regression model for countingprocesses: A large sample study.The annals of statistics, 10(4),1100–1120.

Cinlar, Erhan (1975).Introduction to stochastic processes. EnglewoodCliffs, NJ: Printice-Hall.

Cox, D. R. (1972). Regression models and life-tables.Journal of the Royal Statistical Society. Series B(Methodological), 34(2), 187–220.

Lewis, P. A., & G. S. Shedler. (1979). Simulation ofNonhomogeneous Poisson Processes by Thinning.Naval Research Logistics Quarterly,26(3), Wiley Online Library: 403–13.

Examples

library(reda)set.seed(123)### time-invariant covariates and coefficients## one processsimEvent(z = c(0.5, 1), zCoef = c(1, 0))simEvent(z = 1, zCoef = 0.5, recurrent = FALSE)## simulated datasimEventData(z = c(0.5, 1), zCoef = c(1, 0), endTime = 2)simEventData(z = cbind(rnorm(3), 1), zCoef = c(1, 0))simEventData(z = matrix(rnorm(5)), zCoef = 0.5, recurrent = FALSE)### time-varying covariates and time-varying coefficientszFun <- function(time, intercept) {    cbind(time / 10 + intercept, as.numeric(time > 1))}zCoefFun <- function(x, shift) {    cbind(sqrt(x + shift), 1)}simEvent(z = zFun, zCoef = zCoefFun,         arguments = list(z = list(intercept = 0.1),                          zCoef = list(shift = 0.1)))## same function of time for all processessimEventData(3, z = zFun, zCoef = zCoefFun,             arguments = list(z = list(intercept = 0.1),                              zCoef = list(shift = 0.1)))## same function within one process but different between processes## use quote function in the argumentssimDat <- simEventData(3, z = zFun, zCoef = zCoefFun,                       arguments = list(                           z = list(intercept = quote(rnorm(1) / 10)),                           zCoef = list(shift = 0.1)                       ))## check the intercept randomly generated,## which should be the same within each ID but different between IDs.unique(with(simDat, cbind(ID, intercept = round(X.1 - time / 10, 6))))### non-negative time-varying baseline hazard rate functionsimEvent(rho = function(timeVec) { sin(timeVec) + 1 })simEventData(3, origin = rnorm(3), endTime = rnorm(3, 5),             rho = function(timeVec) { sin(timeVec) + 1 })## specify other argumentssimEvent(z = c(rnorm(1), rbinom(1, 1, 0.5)) / 10,         rho = function(a, b) { sin(a + b) + 1 },         arguments = list(rho = list(b = 0.5)))simEventData(z = cbind(rnorm(3), rbinom(3, 1, 0.5)) / 10,             rho = function(a, b) { sin(a + b) + 1 },             arguments = list(rho = list(b = 0.5)))## quadratic B-splines with one internal knot at "time = 1"## (using function 'bSpline' from splines2 package)simEvent(rho = splines2::bSpline, rhoCoef = c(0.8, 0.5, 1, 0.6),         arguments = list(rho = list(degree = 2, knots = 1,                                     intercept = TRUE,                                     Boundary.knots = c(0, 3))))### frailty effect## Gamma distribution with mean onesimEvent(z = c(0.5, 1), zCoef = c(1, 0), frailty = rgamma,         arguments = list(frailty = list(shape = 2, scale = 0.5)))## lognormal with mean zero (on the log scale)set.seed(123)simEvent(z = c(0.5, 1), zCoef = c(1, 0), frailty = "rlnorm",         arguments = list(frailty = list(sdlog = 1)))## or equivalentlyset.seed(123)logNorm <- function(a) exp(rnorm(n = 1, mean = 0, sd = a))simEvent(z = c(0.5, 1), zCoef = c(1, 0), frailty = logNorm,         arguments = list(frailty = list(a = 1)))### renewal process## interarrival times following uniform distributionrUnif <- function(n, rate, min) runif(n, min, max = 2 / rate)simEvent(interarrival = rUnif,         arguments = list(interarrival = list(min = 0)))## interarrival times following Gamma distribution with scale oneset.seed(123)simEvent(interarrival = function(n, rate) rgamma(n, shape = 1 / rate))## or equivalentlyset.seed(123)simEvent(interarrival = function(rate) rgamma(n = 1, shape = 1 / rate))### relative risk functioinset.seed(123)simEvent(relativeRisk = "linear")## or equivalentlyrriskFun <- function(z, zCoef, intercept) {    as.numeric(z %*% zCoef) + intercept}set.seed(123)simEvent(relativeRisk = rriskFun,         arguments = list(relativeRisk = list(intercept = 1)))

An S4 Class for Simulated Recurrent Event or Survival Times

Description

An S4 class that represents the simulated recurrent event or survival timefrom one stochastic process. The functionsimEvent producesobjects of this class.

Slots

.Data

A numerical vector of possibly length zero.

call

A function call.

z

A list.

zCoef

A list.

rho

A list.

rhoCoef

A numerical vector.

frailty

A list.

origin

A list.

endTime

A list.

censoring

A list.

recurrent

A logical vector.

interarrival

A list.

relativeRisk

A list.

method

A character vector.

See Also

simEvent


Simulated Sample Dataset for Demonstration

Description

A simulated data frame with covariates namedID,time,event,group,x1,andgender, where

Format

A data frame with 500 rows and 6 variables.

Details

The sample dataset is originally simulated by the thinningmethod developed by Lewis and Shedler (1979) andfurther processed for a better demonstration purpose.See Fu et al. (2016) for details also.

References

Lewis, P. A., & Shedler, G. S. (1979).Simulation of nonhomogeneous Poisson processes by thinning.Naval Research Logistics Quarterly, 26(3), 403–413.

Fu, H., Luo, J., & Qu, Y. (2016).Hypoglycemic events analysis via recurrent time-to-event (HEART) models.Journal Of Biopharmaceutical Statistics, 26(2), 280–298.


Summarize anRecur object

Description

Summarize anRecur object

Usage

## S4 method for signature 'Recur'summary(object, ...)

Arguments

object

AnRecur object.

...

Other arguments not used.

Value

summary.Recur object.


Summarizing a Fitted Model

Description

Summary of estimated coefficients of covariates, rate function bases,and estimated rate parameter of frailty random variable, etc.

Usage

## S4 method for signature 'rateReg'summary(object, showCall = TRUE, showKnots = TRUE, ...)

Arguments

object

ArateReg object.

showCall

A logic value with dafaultTRUE,indicating whether functionshowprints out the original call information ofrateReg.It may be helpful for a more concise printout.

showKnots

A logic value with defaultTRUE,indicating whether functionshowprints out the internal and boundary knots.Similar to argumentshowCall, It may be helpfulfor a more concise printout.

...

Other arguments for future usage.

Details

summary,rateReg-method returns asummary.rateReg object,whose slots include

For the meaning of other slots, seerateReg.

Value

summary.rateReg object

See Also

rateReg for model fitting;coef,rateReg-method for point estimates ofcovariate coefficients;confint,rateReg-method for confidence intervalsof covariate coeffcients;baseRate,rateReg-method for coefficients of baselinerate function.

Examples

## See examples given in function rateReg.

An S4 Class for Summarized Recur Object

Description

An S4 Class for Summarized Recur Object

Slots

call

A function call.

sampleSize

An integer representing the sample size (number ofsubjects).

reSize

An integer representing the number of recurrent events.

avgReSize

A numeric value representing the average number of recurrentevents per subject.

propTem

A numeric value representing the proportion of subjects havingterminal event.

medFU

A numeric value for median follow-up time.

medTem

A numeric value for median survival time of the terminalevents.


An S4 Class Representing Summary of a Fitted Model

Description

The classsummary.rateReg is an S4 class with selective slots ofrateReg object. See “Slots” for details. The functionsummary,rateReg-method produces objects of this class.

Slots

call

Function call.

spline

A character.

knots

A numeric vector.

Boundary.knots

A numeric vector.

covarCoef

A numeric matrix.

frailtyPar

A numeric matrix.

degree

A nonnegative integer.

baseRateCoef

A numeric matrix.

logL

A numeric value.

See Also

summary,rateReg-method


Valve Seats Dataset

Description

Valve seats wear out in certain diesel engines, each with 16 valve seats.The dataset served as an example of recurrence data in Nelson (1995),which consists of valve-seat replacements on 41 engines in a fleet.The covariates are namedID,Days, andNo., where

Format

A data frame with 89 rows and 3 variables.

References

Nelson, W. (1995), Confidence Limits for RecurrenceData-Applied to Cost or Number of Product Repairs,Technometrics,37, 147–157.


[8]ページ先頭

©2009-2025 Movatter.jp