pammtools/ 0000755 0001750 0001750 00000000000 14166453533 012431 5 ustar nilesh nilesh pammtools/MD5 0000644 0001750 0001750 00000015653 14166453533 012753 0 ustar nilesh nilesh e4944faa49875735c9151c0f42d7aeda *DESCRIPTION
ca61e01cf34f5d70bd57b9a4a30d24ec *LICENSE
d4b79efc98d95229eba29f0378d208f2 *NAMESPACE
8543a903ff8b006cb1b38fcf75012fce *NEWS.md
eefc3c9920b3bae7487fafb167478704 *R/add-functions.R
345246c8445095b9a6a4713d1d74e0e0 *R/as-ped.R
9c364fc2796e9761e34e7aed2e79094d *R/convenience-plots.R
b4bff026deac930d0896e7f14d8a8a93 *R/cumulative-coefficient.R
67fe16331ac73ea62440316cf7c82253 *R/cumulative-effect.R
2764cd5eb865f3481e1b9ec80530702a *R/data.R
c9b41750437947f465fd9686d71b71d3 *R/formula-specials.R
fd88f3ad167d200070cdaaf5e5c1df95 *R/formula-utils.R
078062e22a0c6cec0bc52e6f81b5be03 *R/geom-hazard.R
ff166d70a4bfac4cffc24fa267d2fbb3 *R/get-cut-points.R
17188fb86f8087f5186b840938b43941 *R/get-terms.R
506f909a21055403224aee32fff6aa02 *R/ggplot-extensions.R
6db0c91c3a5a35fce4b7ed07b389649b *R/helpers.R
d421458027759e570aa733f748e37e3c *R/interval-information.R
28285cc69e150ce6f748a5d69ebf7ca3 *R/lag-lead-utils.R
14578655de809a22a0caed5432621567 *R/make-newdata.R
497227769aee37c971070e2e38a62cd0 *R/model-evaluation.R
71533de4157ff92d0229bb74a2abda35 *R/nest-utils.R
34fe463bb7b08f4959c41edab3220532 *R/pammfit.R
0dc687c3f2c03951a37adf80f93cc92c *R/pammtools.R
49e26fa1e4ca1b37f9869dd63a4eb6f2 *R/predict.R
1e7b06dc9f0c7509f1a8dee97ce946bc *R/rpexp.R
891fd91ead812e815aa87c1b048568e2 *R/sim-pexp.R
7cfd1d783148c917ab0ece1f211dc5c5 *R/split-data.R
413aeabe9159438f01f834c6ba2aacfa *R/sysdata.rda
c7249e05cb8d639e277f5a8642d7d38b *R/tdc-utils.R
a692f736f9fa3b94420cda60cc9848ff *R/tidiers.R
5b9c338e364f3c5ca54af191acca143f *R/tidyverse-methods.R
8d2487dbf45064f33b08e5a80830b68e *R/utils-pipe.R
19d682f7c3294ae8eb98441791c85561 *R/viz-elra.R
eb1a69b5a46606d2c3f975dac3485ed4 *R/warnings.R
0e7ed45e025eddd0fb33d4473a1e1040 *R/zzz.R
8281c0af42acb9442bf8d4db2a0ff6f5 *README.md
6ae12af754ce37cd2f4b660aadcb8d29 *data/daily.rda
35c1e5c5a412c5b0852e7a2d96c52b82 *data/patient.rda
d36f8046a5d763cff479528f534a4cd0 *data/simdf_elra.rda
3d81b95c03378a3f9b7d69777fba5d9b *data/staph.rda
c9cdaeccbdb50c2aa6fd97c440a8e404 *data/tumor.rda
7b90e48bff176d7e2d50589d18b3df5c *inst/CITATION
78ef86f015c95897021f0785e27b5f1f *man/add_cif.Rd
acfe0706866a94798c3fd66715bc7afe *man/add_hazard.Rd
c1232b509c0fc5e933077136f56473e5 *man/add_surv_prob.Rd
a35cc185f797ade470e55dcc852ec66d *man/add_tdc.Rd
cd4c8fd5da08daf7a7f3d827612a49e4 *man/add_term.Rd
f23b8c6d7b7981dd7127565ae085fd64 *man/as.data.frame.crps.Rd
2d0ed4869e9a70c782d73ed4bb613404 *man/as_ped.Rd
358b3be81f688c4beb148ec77d572d2d *man/as_ped_cr.Rd
5fd0840eb74f9c898aadbb8dc65c098a *man/calc_ci.Rd
c634103495de152fbd207f5508ea0426 *man/combine_df.Rd
3f74de30d3830116dc24bd4acccd0441 *man/compute_cumu_diff.Rd
f318647d52f86416c7faeb5dab14d1fe *man/cumulative_coefficient.Rd
39a96a6d355ed7f11b4b812904b459d7 *man/daily.Rd
65bccf7433eeaf89aff1c2290190ea63 *man/dplyr_verbs.Rd
34389f1b1fe0195b48917130e821ed1f *man/elra_matrix.Rd
902f3ad830b5e604402f5d57c52728f9 *man/fcumu.Rd
f030bbfa43e833a62b529713607fa689 *man/figures/logo.png
f8939a28334b642fe86bd05bcb446648 *man/formula_helpers.Rd
a284443f9d4b777397dd3cf1a1a10691 *man/geom_hazard.Rd
a3d4f5b88d6d244d2f70ead21f296b6a *man/geom_stepribbon.Rd
14fda6c4959ee79fabf5fdc5cd65158e *man/get_cif.Rd
fadfa1885b2dbe4efaa22173e833d422 *man/get_cumu_eff.Rd
381247c6aa47ff3872dce3b0bd2d0395 *man/get_cumu_hazard.Rd
2207dbaa922f2929821f3cfeb93da402 *man/get_cumulative.Rd
79b38d1fd95556053268b0a8b4d5b31f *man/get_cut.Rd
a80195a57e043adfe750fee99746fb00 *man/get_event_types.Rd
4181aed2f2000dc663a9cbd45e3e705e *man/get_hazard.Rd
5669a57f85c29b57deb6123bdfec966f *man/get_intervals.Rd
1c3b03537b5fa872ccac93dc93ddcd4d *man/get_laglead.Rd
c8c1121509cc2f5f3d99ab5f4e1c74a9 *man/get_ped_form.Rd
ccf4b710769a91e5733fa31fca7ddc7e *man/get_plotinfo.Rd
041aa8f5d15273a9e20420bbcd51e4be *man/get_sim_ci.Rd
5e7bd6dc469599ecd631f26a4f33b33f *man/get_surv_prob.Rd
2d04296e0da7e76a97b00d675e13605f *man/get_tdc_form.Rd
8e5c6096e82e71c90f9398656b38fcd1 *man/get_tdc_vars.Rd
4538d5cb1644cbd6fb1138295478fece *man/get_term.Rd
5783cbf88c5eca45ce8db9057558da24 *man/get_terms.Rd
a8ca2992dec741914357445add65cc35 *man/gg_fixed.Rd
370888d945fd6e4990217d42b4bd297a *man/gg_laglead.Rd
12929d59d913d16969b6ec105af48574 *man/gg_partial.Rd
aeddbf6e6fab268a795a98ed29fd170f *man/gg_re.Rd
2ea58e9a00defefe754270cc9ec772e6 *man/gg_slice.Rd
761d9db7c3eedb77ec4aba4f08743f46 *man/gg_smooth.Rd
96125f30e6a0b6da2e578ac10a22e77c *man/gg_tensor.Rd
4a905c88f295bca227d350a9ad61d28b *man/has_tdc.Rd
354c8c7b17db153fe62e8e9a4ab18f09 *man/int_info.Rd
8feec77043e287827042b80ee3835421 *man/modus.Rd
38eee2ee61289de88c5d53e5e3a2e546 *man/nest_tdc.Rd
cc9b3b1b480a898c32bd11afd4426375 *man/newdata.Rd
7589766dec76a8e6be77c43e97c5fdea *man/pamm.Rd
760c9cbaece01ae6211e893c8f65b93a *man/pammtools.Rd
3e78c2aca8fca53a5919d86beecc8aba *man/patient.Rd
422596eb4ae376289c6e599d4eb8534f *man/ped_info.Rd
1f7896a1b866ff9ae89ba35be7c7b6f1 *man/pipe.Rd
8d93fbc369d7cbb47c52772623354a50 *man/predictSurvProb.pamm.Rd
5e2b14eba50f994b1f2a794a74ed3174 *man/prep_concurrent.Rd
cb7844d8de8b63a3695a6a5005e7c2b7 *man/rpexp.Rd
5aaf7619714262912c7d7594e654ce46 *man/sample_info.Rd
45436d54473cce841a87f376ef0f8c89 *man/seq_range.Rd
c4f365e8532c585205b5315f09576c5f *man/sim_pexp.Rd
9e58649289fd3c71c7793263c37b6a4f *man/simdf_elra.Rd
2278f59cb602a18ceeb3d30ffefebc79 *man/specials.Rd
4fe38b6f0545770bfcf221732a686223 *man/split_data.Rd
4d77ef1043d82c1dddfd59c64ef20277 *man/split_data_recurrent.Rd
046f06801f17bd643fc4e93980d08c93 *man/staph.Rd
6df42c3fd7140c481dec801fa28cd367 *man/tidiers.Rd
00e7fbe06eb573be2e9a0333ed41aac4 *man/tidy_fixed.Rd
d7bd704f2980cd65464de3983b18ffb3 *man/tidy_smooth.Rd
97704482f1e9d5b1ed6f104400b263de *man/tidy_smooth2d.Rd
85a79072670eff59dc545271128110cf *man/tumor.Rd
3aab2351d93a7b720b7ae7ee33e47343 *man/warn_about_new_time_points.Rd
d2e4d5c85f2bb9eb08e44d7d223f6e92 *tests/testthat.R
9e2c48606653ddd4db83c42fb8c4ab17 *tests/testthat/test-add-functions.R
3944f0fa2ad7222b8c92d8af52be5c80 *tests/testthat/test-as-ped-cr.R
f011fd3f47560d171e7b3d4c61165b5c *tests/testthat/test-as-ped.R
846b652972194986e4164f52b9bae284 *tests/testthat/test-cumulative-coefficients.R
790be3f62431add4b8eb7e5398e41a63 *tests/testthat/test-cumulative-effect.R
36e944a4330618b15f432636785d2a09 *tests/testthat/test-formula-utils.R
e53614a6934375607abe9d93e2359e59 *tests/testthat/test-interval-functions.R
2be39683ae16103c3c4f133013d1c248 *tests/testthat/test-mgcv-convenience.R
8f2eb7710ad4cc642fb539e1a8f382c8 *tests/testthat/test-model-evaluation.R
28a9f49f8b28ff797898ed459df23221 *tests/testthat/test-newdata.R
0873c6c18bcb7e813660f5d3011f0846 *tests/testthat/test-pamm-fit.R
b3ea56865f02e1cf560fee6b75c848d7 *tests/testthat/test-predict-functions.R
f48cb63b9e6bd2fdace8cc66485e6f87 *tests/testthat/test-simple-transform.R
55a7c2a950c832360f7da787c846f6d7 *tests/testthat/test-simulation.R
3a42ab4d5c8e156683b1f21e3cab6db7 *tests/testthat/test-specials.R
9f2ffbbc9283947b6d0822295eebde12 *tests/testthat/test-tdc-transform.R
be64b75d909f4d6344b907537ce7f140 *tests/testthat/test-tidyverse-S3methods.R
pammtools/NEWS.md 0000644 0001750 0001750 00000015543 14166256721 013537 0 ustar nilesh nilesh # pammtools 0.5.8
+ removed argument `methods` from `pamm`. Can be specified via `...`. Fixes #200
+ adapted `warn_about_new_time_points` when original data not stored in model object. Fixes #203
+ Fixed issue where not all ped attributes were retained when applying dplyr functions #202
# pammtools 0.5.7
+ added staph data with recurrent events
# pammtools 0.5.6
+ maintenance fix
+ fixes to URLs and DOIs
# pammtools 0.5.4
+ updates to the `split_data` function that now accepts `Surv(start, stop, event)` type inputs, e.g., to construct left-truncated data.
+ Support and [vignette for left truncated data](https://adibender.github.io/pammtools/articles/left-truncation.html)
+ Support and [vignette for competing risks data](https://adibender.github.io/pammtools/articles/competing-risks.html)
+ Support and [vignette for recurrent events data](https://adibender.github.io/pammtools/articles/recurrent-events.html)
# pammtools 0.2.4
* CRAN fix. Discrepancy between man page and code.
# pammtools 0.2.3
* CRAN fix. Compliance with new dplyr version (1.0.0)
# pammtools 0.2.2
* CRAN fix, removed plyr dependency (see issue #141)
* `as_ped.ped` now also works for transformations with time-dependent covariates
# pammtools 0.2.1
* Adds a new interface for model estimation called `pamm`, which is a thin wrapper
around `mgcv::gam` with some arguments pre-set.
* Adds S3 method `predictSurvProb.pamm`
* Adds support and vignette for model evaluation using package **`pec`**
* Fixed bug when CIs were calculated simulation based and model contained factor variables
* Removed unnecessary dependencies in Imports/Suggests
# pammtools 0.1.15
* Interface for specification of data transformation in `as_ped` changed. The vertical bar `|` is no longer necessary to indicate concurrent or cumulative effects
# pammtools 0.1.14
* Support for new interface to tidyr
# pammtools 0.1.13
* Functions `get_hazard` and `add_hazard` also gain `reference` argument.
Allows to calculate (log-)hazard ratios.
* Introduces breaking changes to `add_term` function. Argument `relative` is replaced by `reference`, makes calculation of relative (log-)hazards, i.e. hazard ratios, more flexible. Argument `se.fit` is replaced by `ci`.
# pammtools 0.1.11
## bugs
* fixes bug in **`dplyr`** reverse dependency (see #101)
* fixes bug in tidiers for Aalen models (see #99)
## documentation
* Better documentation and functionality for `make_newdata`
* Added new vignette linking to tutorial paper (online only)
# pammtools 0.1.9
* maintenance update: fixes CRAN issues due to new RNG
# pammtools 0.1.8
## documentation
* Updates to cumulative effect vignette
* Updates to time-dependent covariate vignette (+ data transformation)
* Update citation information
## Features
* `concurrent` now has a `lag = 0` argument, can be set to positive integer values
* `as_ped` accepts multiple `concurrent` specials with different `lag` specifications
## Bug/Issue fixes
* Fixed bug caused by changes in **`checkmate`** [#73](https://github.com/adibender/pammtools/issues/73)
* Bug Fixes [#42](https://github.com/adibender/pammtools/issues/42), [#76](https://github.com/adibender/pammtools/issues/76), [#63](https://github.com/adibender/pammtools/issues/63), [#77](https://github.com/adibender/pammtools/issues/77)
# pammtools 0.1.7
* Further improved support for cumulative effects
* Added vignette on estimation and visualization of cumulative effect
* Updated vignette on convenience functions (now "Workflow and convenience functions")
* Other (minor) upgrades/updates to documentation/vignettes
* Updates homepage (via pkgdown)
# pammtools 0.1.3
## Minor changes
* Update documentation
* More tests/improved coverage
* Lag-lead column is adjusted in `make-newdata.fped`
## Bug fixes
- visualization functions `gg_laglead` and `gg_partial_ll` did not
calculate the lag-lead-window correctly when applied to `ped` data
# pammtools 0.1.0
## Features
* Better support for cumulative effects
* Lag-Lead matrix now contains quadrature weights
* Better support for visualization of cumulative effects
# pammtools 0.0.9
## Breaking changes
* `make_newdata` loses arguments `expand` and `n` and
gains `...` where arbitrary covariate specifications can be placed, i.e.
e.g. `age=seq_range(age, n=20)`. Multiple such expression can be provided and
a data frame with one row for each combination of the evaluated expressions
will be returned. All variables not specified in \code{...} will be set to
respective mean or modus values. For data of class `ped` or `fped` `make_newdata` will try to specify time-dependent variables intelligently.
* `te_var` argument in `concurrent` and `cumulative` was renamed to
`tz_var`
* `te` arguments have been replaced by `tz` (time points at which `z` was observed) in all functions to avoid confusion with `mgcv::te`
(e.g., `gg_laglead`)
## Updates and new features
* Overall better support for cumulative effects
* Added convenience functions for work with cumulative effects, namely
- `gg_partial` and
- `gg_slice`
* Added helper functions to calculate and visualize Lag-lead windows
- `get_laglead`
- `gg_laglead`
* Added convenience `geom`s for piece-wise constant hazards (see examples in
`?geom_hazard`, cumulative hazards and survival probabilities (usually
`aes(x=time, y = surv_prob)`, but data set doesn't contain extra row for
`time = 0`), thus
- `geom_stephazard` adds row (x=0, y = y[1]) to the data before plotting
- `geom_hazard` adds row (x = 0, y = 0) before plotting (can also be used
for cumulative hazard)
- `geom_surv` add row (x = 0, y = 1) before plotting
# pammtools 0.0.8
* All data transformation is now handled using `as_ped` (see
[data transformation vignette](https://adibender.github.io/pammtools/articles/data-transformation.html))
* Data transformation now handles
- standard time-to-event data
- time-to-event data with concurrent effects of time-dependent covariates
- time-to-event data with cumulative effects of time-dependent covariates
* Added functionality to flexibly simulate data from PEXP including cumulative effects, see `?sim_pexp`
* Added functionality to calculate Aalen-model style cumulative coefficients,
see `?cumulative_coefficient`
* Breaking change in `split_data` (`as_ped` now main data trafo function):
- removed `max.end` argument
- added `max_time` argument to introduce administrative censoring at
`max_time` when no custom interval split points are provided
# pammtools 0.0.3
## pammtools 0.0.3.2
* More `tidyeval` adaptations
* consistent handling of "no visible global binding" NOTEs
* Release used in
A. Bender, Groll A., Scheipl F., "A generalized additive model approach to
time-to-event analysis" (2017). Statistical Modelling (*to appear*)
## pammtools 0.0.3.1
* some adaptations to `tidyeval`
* Minor bug fixes
# pammtools 0.0.2
* Ported `pamm` package to `pammtools` due to naming conflicts with `PAMM`
package on CRAN
pammtools/DESCRIPTION 0000644 0001750 0001750 00000004522 14166453533 014142 0 ustar nilesh nilesh Package: pammtools
Title: Piece-Wise Exponential Additive Mixed Modeling Tools for
Survival Analysis
Version: 0.5.8
Date: 2022-01-04
Authors@R: c(
person("Andreas", "Bender", , "andreas.bender@stat.uni-muenchen.de", role = c("aut", "cre"), comment=c(ORCID = "0000-0001-5628-8611")),
person("Fabian", "Scheipl", , "fabian.scheipl@stat.uni-muenchen.de", role = c("aut"), comment = c(ORCID = "0000-0001-8172-3603")),
person("Philipp", "Kopper", , "philipp.kopper@stat.uni-muenchen.de", role = c("aut"), comment = c(ORCID="0000-0002-5037-7135")),
person("Lukas", "Burk", , "burk@leibniz-bips.de", role = c("ctb"),
comment = c(ORCID="0000-0001-7528-3795")))
Description: The Piece-wise exponential (Additive Mixed) Model
(PAMM; Bender and others (2018) ) is a
powerful model class for the analysis of survival (or time-to-event) data,
based on Generalized Additive (Mixed) Models (GA(M)Ms). It offers intuitive specification and robust estimation of complex survival models with stratified baseline hazards, random effects, time-varying effects, time-dependent covariates and cumulative effects (Bender and others (2019)), as well as support for left-truncated, competing risks and recurrent events data.
pammtools provides tidy workflow for survival analysis with PAMMs,
including data simulation, transformation and other functions for data
preprocessing and model post-processing as well as visualization.
Depends: R (>= 3.5.0)
Imports: mgcv, survival (>= 2.39-5), checkmate, magrittr, rlang, tidyr
(>= 1.0.0), ggplot2 (>= 3.2.2), dplyr (>= 1.0.0), purrr (>=
0.2.3), tibble, lazyeval, Formula, mvtnorm, pec, vctrs (>=
0.3.0)
Suggests: testthat
License: MIT + file LICENSE
LazyData: true
URL: https://adibender.github.io/pammtools/
BugReports: https://github.com/adibender/pammtools/issues
RoxygenNote: 7.1.2
Encoding: UTF-8
NeedsCompilation: no
Packaged: 2022-01-08 09:57:48 UTC; ab
Author: Andreas Bender [aut, cre] (),
Fabian Scheipl [aut] (),
Philipp Kopper [aut] (),
Lukas Burk [ctb] ()
Maintainer: Andreas Bender
Repository: CRAN
Date/Publication: 2022-01-09 03:32:43 UTC
pammtools/README.md 0000644 0001750 0001750 00000005423 14150477345 013714 0 ustar nilesh nilesh
[](https://github.com/adibender/pammtools/actions)
[](https://cran.r-project.org/web/checks/check_results_pammtools.html)
[](https://lifecycle.r-lib.org/articles/stages.html)
[](https://travis-ci.org/adibender/pammtools)
[](https://ci.appveyor.com/project/adibender/pammtools/branch/master)
[](https://codecov.io/github/adibender/pammtools/branch/master)
[](https://cran.r-project.org/package=pammtools)
[](https://cran.r-project.org/package=pammtools)
[]( https://opensource.org/licenses/MIT)
# **`pammtools`**: Piece-Wise Exponential Additive Mixed Modeling Tools
### Installation
Install from CRAN or GitHub using:
``` r
# CRAN
install.packages("pammtools")
```
### Overview
**`pammtools`** facilitates the estimation of Piece-wise exponential
Additive Mixed Models (PAMMs) for time-to-event data. PAMMs can be
represented as generalized additive models and can therefore be
estimated using GAM software (e.g. **`mgcv`**), which, compared to other
packages for survival analysis, often offers more flexibility w.r.t. to
the specification of covariate effects (e.g. non-linear, time-varying
effects, cumulative effects, etc.).
To get started, see the
[Articles](https://adibender.github.io/pammtools/articles/) section.
pammtools/man/ 0000755 0001750 0001750 00000000000 14154722042 013173 5 ustar nilesh nilesh pammtools/man/newdata.Rd 0000644 0001750 0001750 00000007370 13662013606 015116 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/make-newdata.R
\name{make_newdata}
\alias{make_newdata}
\alias{make_newdata.default}
\alias{make_newdata.ped}
\alias{make_newdata.fped}
\title{Construct a data frame suitable for prediction}
\usage{
make_newdata(x, ...)
\method{make_newdata}{default}(x, ...)
\method{make_newdata}{ped}(x, ...)
\method{make_newdata}{fped}(x, ...)
}
\arguments{
\item{x}{A data frame (or object that inherits from \code{data.frame}).}
\item{...}{Covariate specifications (expressions) that will be evaluated
by looking for variables in \code{x}. Must be of the form \code{z = f(z)}
where \code{z} is a variable in the data set and \code{f} a known
function that can be usefully applied to \code{z}. Note that this is also
necessary for single value specifications (e.g. \code{age = c(50)}).
For data in PED (piece-wise exponential data) format, one can also specify
the time argument, but see "Details" an "Examples" below.}
}
\description{
This functions provides a flexible interface to create a data set that
can be plugged in as \code{newdata} argument to a suitable \code{predict}
function (or similar).
The function is particularly useful in combination with one of the
\code{add_*} functions, e.g., \code{\link[pammtools]{add_term}},
\code{\link[pammtools]{add_hazard}}, etc.
}
\details{
Depending on the type of variables in \code{x}, mean or modus values
will be used for variables not specified in ellipsis
(see also \code{\link[pammtools]{sample_info}}). If \code{x} is an object
that inherits from class \code{ped}, useful data set completion will be
attempted depending on variables specified in ellipsis. This is especially
useful, when creating a data set with different time points, e.g. to
calculate survival probabilities over time (\code{\link[pammtools]{add_surv_prob}})
or to calculate a time-varying covariate effects (\code{\link[pammtools]{add_term}}).
To do so, the time variable has to be specified in \code{...}, e.g.,
\code{tend = seq_range(tend, 20)}. The problem with this specification is that
not all values produced by \code{seq_range(tend, 20)} will be actual values
of \code{tend} used at the stage of estimation (and in general, it will
often be tedious to specify exact \code{tend} values). \code{make_newdata}
therefore finds the correct interval and sets \code{tend} to the respective
interval endpoint. For example, if the intervals of the PED object are
\eqn{(0,1], (1,2]} then \code{tend = 1.5} will be set to \code{2} and the
remaining time-varying information (e.g. offset) completed accordingly.
See examples below.
}
\examples{
# General functionality
tumor \%>\% make_newdata()
tumor \%>\% make_newdata(age=c(50))
tumor \%>\% make_newdata(days=seq_range(days, 3), age=c(50, 55))
tumor \%>\% make_newdata(days=seq_range(days, 3), status=unique(status), age=c(50, 55))
# mean/modus values of unspecified variables are calculated over whole data
tumor \%>\% make_newdata(sex=unique(sex))
tumor \%>\% group_by(sex) \%>\% make_newdata()
# You can also pass a part of the data sets as data frame to make_newdata
purrr::cross_df(list(days = c(0, 500, 1000), sex = c("male", "female"))) \%>\%
make_newdata(x=tumor)
# Examples for PED data
ped <- tumor \%>\% slice(1:3) \%>\% as_ped(Surv(days, status)~., cut = c(0, 500, 1000))
ped \%>\% make_newdata(age=c(50, 55))
# if time information is specified, other time variables will be specified
# accordingly and offset calculated correctly
ped \%>\% make_newdata(tend = c(1000), age = c(50, 55))
ped \%>\% make_newdata(tend = unique(tend))
ped \%>\% group_by(sex) \%>\% make_newdata(tend = unique(tend))
# tend is set to the end point of respective interval:
ped <- tumor \%>\% as_ped(Surv(days, status)~.)
seq_range(ped$tend, 3)
make_newdata(ped, tend = seq_range(tend, 3))
}
pammtools/man/prep_concurrent.Rd 0000644 0001750 0001750 00000001047 13662013606 016676 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/formula-specials.R
\name{prep_concurrent}
\alias{prep_concurrent}
\alias{prep_concurrent.list}
\title{Extract information on concurrent effects}
\usage{
prep_concurrent(x, formula, ...)
\method{prep_concurrent}{list}(x, formula, ...)
}
\arguments{
\item{x}{A suitable object from which variables contained in
\code{formula} can be extracted.}
\item{...}{Further arguments passed to methods.}
}
\description{
Extract information on concurrent effects
}
\keyword{internal}
pammtools/man/combine_df.Rd 0000644 0001750 0001750 00000001122 13662013606 015545 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/make-newdata.R
\name{combine_df}
\alias{combine_df}
\title{Create a data frame from all combinations of data frames}
\usage{
combine_df(...)
}
\arguments{
\item{...}{Data frames that should be combined to one data frame.
Elements of first df vary fastest, elements of last df vary slowest.}
}
\description{
Works like \code{\link[base]{expand.grid}} but for data frames.
}
\examples{
combine_df(
data.frame(x=1:3, y=3:1),
data.frame(x1=c("a", "b"), x2=c("c", "d")),
data.frame(z=c(0, 1)))
}
\keyword{internal}
pammtools/man/int_info.Rd 0000644 0001750 0001750 00000003111 14116612001 015252 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/interval-information.R
\name{int_info}
\alias{int_info}
\alias{int_info.default}
\alias{int_info.data.frame}
\alias{int_info.ped}
\alias{int_info.pamm}
\title{Create start/end times and interval information}
\usage{
int_info(x, ...)
\method{int_info}{default}(x, min_time = 0L, ...)
\method{int_info}{data.frame}(x, min_time = 0L, ...)
\method{int_info}{ped}(x, ...)
\method{int_info}{pamm}(x, ...)
}
\arguments{
\item{x}{A numeric vector of cut points in which the follow-up should be
partitioned in or object of class \code{ped}.}
\item{...}{Currently ignored.}
\item{min_time}{Only intervals that have lower borders larger than
this value will be included in the resulting data frame.}
}
\value{
A data frame containing the start and end times of the
intervals specified by the \code{x} argument. Additionally, the interval
length, interval mid-point and a factor variable indicating the intervals.
}
\description{
Given interval breaks points, returns data frame with information on
interval start time, interval end time, interval length and a factor
variable indicating the interval (left open intervals). If an object of class
\code{ped} is provided, extracts unique interval information from object.
}
\examples{
## create interval information from cut points
int_info(c(1, 2.3, 5))
## extract interval information used to create ped object
tdf <- data.frame(time=c(1, 2.3, 5), status=c(0, 1, 0))
ped <- tdf \%>\% as_ped(Surv(time, status)~., id="id")
int_info(ped)
}
\seealso{
as_ped ped_info
}
\keyword{internal}
pammtools/man/tidy_fixed.Rd 0000644 0001750 0001750 00000001452 14116612001 015603 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tidiers.R
\name{tidy_fixed}
\alias{tidy_fixed}
\alias{tidy_fixed.gam}
\alias{tidy_fixed.coxph}
\title{Extract fixed coefficient table from model object}
\usage{
tidy_fixed(x, ...)
\method{tidy_fixed}{gam}(x, intercept = FALSE, ...)
\method{tidy_fixed}{coxph}(x, ...)
}
\arguments{
\item{x}{A model object.}
\item{...}{Currently not used.}
\item{intercept}{Should intercept also be returned? Defaults to \code{FALSE}.}
}
\description{
Given a model object, returns a data frame with columns \code{variable},
\code{coef} (coefficient), \code{ci_lower} (lower 95\\% CI) and
\code{ci_upper} (upper 95\\% CI).
}
\examples{
library(survival)
gc <- coxph(Surv(days, status)~age + sex, data = tumor)
tidy_fixed(gc)
}
\keyword{internal}
pammtools/man/formula_helpers.Rd 0000644 0001750 0001750 00000000743 13662013606 016657 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/formula-utils.R
\name{get_lhs_vars}
\alias{get_lhs_vars}
\alias{get_rhs_vars}
\title{Extract variables from the left-hand-side of a formula}
\usage{
get_lhs_vars(formula)
get_rhs_vars(formula)
}
\arguments{
\item{formula}{A \code{\link{formula}} object.}
}
\description{
Extract variables from the left-hand-side of a formula
Extract variables from the right-hand side of a formula
}
\keyword{internal}
pammtools/man/get_cumu_hazard.Rd 0000644 0001750 0001750 00000004210 13662013606 016622 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/add-functions.R
\name{get_cumu_hazard}
\alias{get_cumu_hazard}
\title{Calculate cumulative hazard}
\usage{
get_cumu_hazard(
newdata,
object,
ci = TRUE,
ci_type = c("default", "delta", "sim"),
time_var = NULL,
se_mult = 2,
interval_length = "intlen",
nsim = 100L,
...
)
}
\arguments{
\item{newdata}{ A data frame or list containing the values of the model covariates at which predictions
are required. If this is not provided then predictions corresponding to the
original data are returned. If \code{newdata} is provided then
it should contain all the variables needed for prediction: a
warning is generated if not. See details for use with \code{link{linear.functional.terms}}. }
\item{object}{ a fitted \code{gam} object as produced by \code{gam()}.
}
\item{ci}{\code{logical}. Indicates if confidence intervals should be
calculated. Defaults to \code{TRUE}.}
\item{ci_type}{The method by which standard errors/confidence intervals
will be calculated. Default transforms the linear predictor at
respective intervals. \code{"delta"} calculates CIs based on the standard
error calculated by the Delta method. \code{"sim"} draws the
property of interest from its posterior based on the normal distribution of
the estimated coefficients. See \href{https://adibender.github.io/simpamm/confidence-intervals.html}{here}
for details and empirical evaluation.}
\item{time_var}{Name of the variable used for the baseline hazard. If
not given, defaults to \code{"tend"} for \code{\link[mgcv]{gam}} fits, else
\code{"interval"}. The latter is assumed to be a factor, the former
numeric.}
\item{se_mult}{Factor by which standard errors are multiplied for calculating
the confidence intervals.}
\item{interval_length}{The variable in newdata containing the interval lengths.
Can be either bare unquoted variable name or character. Defaults to \code{"intlen"}.}
\item{...}{Further arguments passed to \code{\link[mgcv]{predict.gam}} and
\code{\link{get_hazard}}}
}
\description{
Calculate cumulative hazard
}
\keyword{internal}
pammtools/man/has_tdc.Rd 0000644 0001750 0001750 00000001210 14116612001 015050 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tdc-utils.R
\name{has_tdc}
\alias{has_tdc}
\title{Checks if data contains timd-dependent covariates}
\usage{
has_tdc(data, id_var)
}
\arguments{
\item{data}{A data frame (potentially) containing time-dependent covariates.}
\item{id_var}{A character indicating the grouping variable. For each covariate
it will be checked if their values change within a group specified by
\code{id_var}.}
}
\value{
Logical. \code{TRUE} if data contains time-dependent covariates, else \code{FALSE}.
}
\description{
Checks if data contains timd-dependent covariates
}
\keyword{internal}
pammtools/man/elra_matrix.Rd 0000644 0001750 0001750 00000001530 13662013606 015772 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/formula-specials.R
\name{make_time_mat}
\alias{make_time_mat}
\alias{make_latency_mat}
\alias{make_lag_lead_mat}
\alias{make_z_mat}
\title{Create matrix components for cumulative effects}
\usage{
make_time_mat(data, nz)
make_latency_mat(data, tz)
make_lag_lead_mat(data, tz, ll_fun = function(t, tz) t >= tz)
make_z_mat(data, z_var, nz, ...)
}
\arguments{
\item{data}{A data set (or similar) from which meta information on cut-points,
interval-specific time, covariates etc. can be obtained.}
\item{z_var}{Which should be transformed into functional covariate format
suitable to fit cumulative effects in \code{mgcv::gam}.}
}
\description{
These functions are called internally by \code{\link{get_cumulative}} and
should usually not be called directly.
}
\keyword{internal}
pammtools/man/get_surv_prob.Rd 0000644 0001750 0001750 00000003240 13722471465 016353 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/add-functions.R
\name{get_surv_prob}
\alias{get_surv_prob}
\title{Calculate survival probabilities}
\usage{
get_surv_prob(
newdata,
object,
ci = TRUE,
ci_type = c("default", "delta", "sim"),
se_mult = 2L,
time_var = NULL,
interval_length = "intlen",
nsim = 100L,
...
)
}
\arguments{
\item{newdata}{ A data frame or list containing the values of the model covariates at which predictions
are required. If this is not provided then predictions corresponding to the
original data are returned. If \code{newdata} is provided then
it should contain all the variables needed for prediction: a
warning is generated if not. See details for use with \code{link{linear.functional.terms}}. }
\item{object}{ a fitted \code{gam} object as produced by \code{gam()}.
}
\item{ci}{\code{logical}. Indicates if confidence intervals should be
calculated. Defaults to \code{TRUE}.}
\item{se_mult}{Factor by which standard errors are multiplied for calculating
the confidence intervals.}
\item{time_var}{Name of the variable used for the baseline hazard. If
not given, defaults to \code{"tend"} for \code{\link[mgcv]{gam}} fits, else
\code{"interval"}. The latter is assumed to be a factor, the former
numeric.}
\item{interval_length}{The variable in newdata containing the interval lengths.
Can be either bare unquoted variable name or character. Defaults to \code{"intlen"}.}
\item{...}{Further arguments passed to \code{\link[mgcv]{predict.gam}} and
\code{\link{get_hazard}}}
}
\description{
Calculate survival probabilities
}
\keyword{internal}
pammtools/man/tidy_smooth2d.Rd 0000644 0001750 0001750 00000001242 13662013606 016253 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tidiers.R
\name{tidy_smooth2d}
\alias{tidy_smooth2d}
\title{Extract 2d smooth objects in tidy format.}
\usage{
tidy_smooth2d(
x,
keep = c("x", "y", "fit", "se", "xlab", "ylab", "main"),
ci = FALSE,
...
)
}
\arguments{
\item{x}{ a fitted \code{gam} object as produced by \code{gam()}.}
\item{keep}{A vector of variables to keep.}
\item{ci}{A logical value indicating whether confidence intervals should be
calculated and returned. Defaults to \code{TRUE}.}
\item{...}{Further arguments passed to \code{\link[mgcv]{plot.gam}}}
}
\description{
Extract 2d smooth objects in tidy format.
}
pammtools/man/gg_tensor.Rd 0000644 0001750 0001750 00000001657 13662013606 015464 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/convenience-plots.R
\name{gg_tensor}
\alias{gg_tensor}
\title{Plot tensor product effects}
\usage{
gg_tensor(x, ci = FALSE, ...)
}
\arguments{
\item{x}{ a fitted \code{gam} object as produced by \code{gam()}.}
\item{ci}{A logical value indicating whether confidence intervals should be
calculated and returned. Defaults to \code{TRUE}.}
\item{...}{Further arguments passed to \code{\link[mgcv]{plot.gam}}}
}
\description{
Given a gam model this convenience function returns a \code{ggplot2} object
depicting 2d smooth terms specified in the model as heat/contour plots. If
more than one 2d smooth term is present individual terms are faceted.
}
\examples{
g <- mgcv::gam(Sepal.Length ~ te(Sepal.Width, Petal.Length), data=iris)
gg_tensor(g)
gg_tensor(g, ci=TRUE)
gg_tensor(update(g, .~. + te(Petal.Width, Petal.Length)))
}
\seealso{
\code{\link{tidy_smooth2d}}
}
pammtools/man/tumor.Rd 0000644 0001750 0001750 00000001720 14122025561 014625 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.R
\docType{data}
\name{tumor}
\alias{tumor}
\title{Stomach area tumor data}
\format{
An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 776 rows and 9 columns.
}
\usage{
tumor
}
\description{
Information on patients treated for a cancer disease
located in the stomach area.
The data set includes:
\describe{
\item{days}{Time from operation until death in days.}
\item{status}{Event indicator (0 = censored, 1 = death).}
\item{age}{The subject's age.}
\item{sex}{The subject's sex (male/female).}
\item{charlson_score}{Charlson comorbidity score, 1-6.}
\item{transfusion}{Has subject received transfusions (no/yes).}
\item{complications}{Did major complications occur during operation (no/yes).}
\item{metastases}{Did the tumor develop metastases? (no/yes).}
\item{resection}{Was the operation accompanied by a major resection (no/yes).}
}
}
\keyword{datasets}
pammtools/man/get_tdc_form.Rd 0000644 0001750 0001750 00000001014 13662013606 016114 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/formula-utils.R
\name{get_tdc_form}
\alias{get_tdc_form}
\title{Extract variables from the left-hand-side of a formula}
\usage{
get_tdc_form(
formula,
data = NULL,
tdc_specials = c("concurrent", "cumulative"),
invert = FALSE
)
}
\arguments{
\item{formula}{A \code{\link{formula}} object.}
}
\description{
Extract variables from the left-hand-side of a formula
Extract variables from the right-hand side of a formula
}
\keyword{internal}
pammtools/man/add_surv_prob.Rd 0000644 0001750 0001750 00000004536 13722471465 016335 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/add-functions.R
\name{add_surv_prob}
\alias{add_surv_prob}
\title{Add survival probability estimates}
\usage{
add_surv_prob(
newdata,
object,
ci = TRUE,
se_mult = 2,
overwrite = FALSE,
time_var = NULL,
interval_length = "intlen",
...
)
}
\arguments{
\item{newdata}{ A data frame or list containing the values of the model covariates at which predictions
are required. If this is not provided then predictions corresponding to the
original data are returned. If \code{newdata} is provided then
it should contain all the variables needed for prediction: a
warning is generated if not. See details for use with \code{link{linear.functional.terms}}. }
\item{object}{ a fitted \code{gam} object as produced by \code{gam()}.
}
\item{ci}{\code{logical}. Indicates if confidence intervals should be
calculated. Defaults to \code{TRUE}.}
\item{se_mult}{Factor by which standard errors are multiplied for calculating
the confidence intervals.}
\item{overwrite}{Should hazard columns be overwritten if already present in
the data set? Defaults to \code{FALSE}. If \code{TRUE}, columns with names
\code{c("hazard", "se", "lower", "upper")} will be overwritten.}
\item{time_var}{Name of the variable used for the baseline hazard. If
not given, defaults to \code{"tend"} for \code{\link[mgcv]{gam}} fits, else
\code{"interval"}. The latter is assumed to be a factor, the former
numeric.}
\item{interval_length}{The variable in newdata containing the interval lengths.
Can be either bare unquoted variable name or character. Defaults to \code{"intlen"}.}
\item{...}{Further arguments passed to \code{\link[mgcv]{predict.gam}} and
\code{\link{get_hazard}}}
}
\description{
Given suitable data (i.e. data with all columns used for estimation of the model),
this functions adds a column \code{surv_prob} containing survival probabilities
for the specified covariate and follow-up information (and CIs
\code{surv_lower}, \code{surv_upper} if \code{ci=TRUE}).
}
\examples{
ped <- tumor[1:50,] \%>\% as_ped(Surv(days, status)~ age)
pam <- mgcv::gam(ped_status ~ s(tend)+age, data=ped, family=poisson(), offset=offset)
ped_info(ped) \%>\% add_surv_prob(pam, ci=TRUE)
}
\seealso{
\code{\link[mgcv]{predict.gam}},
\code{\link[pammtools]{add_surv_prob}}
}
pammtools/man/get_hazard.Rd 0000644 0001750 0001750 00000004471 14116612001 015567 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/add-functions.R
\name{get_hazard}
\alias{get_hazard}
\alias{get_hazard.default}
\title{Calculate predicted hazard}
\usage{
get_hazard(object, newdata, ...)
\method{get_hazard}{default}(
object,
newdata,
reference = NULL,
ci = TRUE,
type = c("response", "link"),
ci_type = c("default", "delta", "sim"),
time_var = NULL,
se_mult = 2,
...
)
}
\arguments{
\item{object}{ a fitted \code{gam} object as produced by \code{gam()}.
}
\item{newdata}{ A data frame or list containing the values of the model covariates at which predictions
are required. If this is not provided then predictions corresponding to the
original data are returned. If \code{newdata} is provided then
it should contain all the variables needed for prediction: a
warning is generated if not. See details for use with \code{link{linear.functional.terms}}. }
\item{...}{Further arguments passed to \code{\link[mgcv]{predict.gam}} and
\code{\link{get_hazard}}}
\item{reference}{A data frame with number of rows equal to \code{nrow(newdata)} or
one, or a named list with (partial) covariate specifications. See examples.}
\item{ci}{\code{logical}. Indicates if confidence intervals should be
calculated. Defaults to \code{TRUE}.}
\item{type}{Either \code{"response"} or \code{"link"}. The former calculates
hazard, the latter the log-hazard.}
\item{ci_type}{The method by which standard errors/confidence intervals
will be calculated. Default transforms the linear predictor at
respective intervals. \code{"delta"} calculates CIs based on the standard
error calculated by the Delta method. \code{"sim"} draws the
property of interest from its posterior based on the normal distribution of
the estimated coefficients. See \href{https://adibender.github.io/simpamm/confidence-intervals.html}{here}
for details and empirical evaluation.}
\item{time_var}{Name of the variable used for the baseline hazard. If
not given, defaults to \code{"tend"} for \code{\link[mgcv]{gam}} fits, else
\code{"interval"}. The latter is assumed to be a factor, the former
numeric.}
\item{se_mult}{Factor by which standard errors are multiplied for calculating
the confidence intervals.}
}
\description{
Calculate predicted hazard
}
\keyword{internal}
pammtools/man/fcumu.Rd 0000644 0001750 0001750 00000000643 13662013606 014606 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sim-pexp.R
\name{fcumu}
\alias{fcumu}
\title{A formula special used to handle cumulative effect specifications}
\usage{
fcumu(..., by = NULL, f_xyz, ll_fun)
}
\description{
Can be used in the second part of the formula specification provided
to \code{\link[pammtools]{sim_pexp}} and should only be used in this
context.
}
\keyword{internal}
pammtools/man/split_data_recurrent.Rd 0000644 0001750 0001750 00000004346 14150243134 017702 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/split-data.R
\name{split_data_recurrent}
\alias{split_data_recurrent}
\title{Split data to obtain recurrent event data in PED format}
\usage{
split_data_recurrent(
formula,
data,
transition = character(),
cut = NULL,
max_time = NULL,
event = 1L,
min_events = 1L,
timescale = c("gap", "calendar"),
...
)
}
\arguments{
\item{formula}{A two sided formula with a \code{\link[survival]{Surv}} object
on the left-hand-side and covariate specification on the right-hand-side (RHS).
The RHS can be an extended formula, which specifies how TDCs should be transformed
using specials \code{concurrent} and \code{cumulative}. The left hand-side can
be in start-stop-notation. This, however, is only used to create left-truncated
data and does not support the full functionality.}
\item{data}{Either an object inheriting from data frame or in case of
time-dependent covariates a list of data frames (of length 2), where the first data frame
contains the time-to-event information and static covariates while the second
(and potentially further data frames) contain information on time-dependent
covariates and the times at which they have been observed.}
\item{transition}{A character indicating the column in data that indicates the
event/episode number for recurrent events.}
\item{cut}{Split points, used to partition the follow up into intervals.
If unspecified, all unique event times will be used.}
\item{max_time}{If \code{cut} is unspecified, this will be the last
possible event time. All event times after \code{max_time}
will be administratively censored at \code{max_time}.}
\item{event}{The value that encodes the occurrence of an event in the data set.}
\item{min_events}{Minimum number of events for each event number.}
\item{timescale}{Defines the timescale for the recurrent event data transformation.
Defaults to \code{"gaptime"}.}
\item{...}{Further arguments passed to the \code{data.frame} method and
eventually to \code{\link[survival]{survSplit}}}
}
\description{
Currently, the input data must be in start-stop notation for each spell and
contain a colum that indicates the spell (event number).
}
\seealso{
\code{\link[survival]{survSplit}}
}
\keyword{internal}
pammtools/man/daily.Rd 0000644 0001750 0001750 00000001676 14122025561 014573 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.R
\docType{data}
\name{daily}
\alias{daily}
\title{Time-dependent covariates of the \code{\link{patient}} data set.}
\format{
An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 18797 rows and 4 columns.
}
\usage{
daily
}
\description{
This data set contains the time-dependent covariates (TDCs) for the \code{\link{patient}}
data set. Note that nutrition was protocoled for at most 12 days after
ICU admission. The data set includes:
\describe{
\item{CombinedID}{Unique patient identifier. Can be used to merge with
\code{\link{patient}} data}
\item{Study_Day}{The calendar (!) day at which calories (or proteins) were
administered}
\item{caloriesPercentage}{The percentage of target calories supplied to the
patient by the ICU staff}
\item{proteinGproKG}{The amount of protein supplied to the patient by the
ICU staff}}
}
\keyword{datasets}
pammtools/man/add_hazard.Rd 0000644 0001750 0001750 00000007157 14116612001 015544 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/add-functions.R
\name{add_hazard}
\alias{add_hazard}
\alias{add_hazard.default}
\alias{add_cumu_hazard}
\title{Add predicted (cumulative) hazard to data set}
\usage{
add_hazard(newdata, object, ...)
\method{add_hazard}{default}(
newdata,
object,
reference = NULL,
type = c("response", "link"),
ci = TRUE,
se_mult = 2,
ci_type = c("default", "delta", "sim"),
overwrite = FALSE,
time_var = NULL,
...
)
add_cumu_hazard(
newdata,
object,
ci = TRUE,
se_mult = 2,
overwrite = FALSE,
time_var = NULL,
interval_length = "intlen",
...
)
}
\arguments{
\item{newdata}{ A data frame or list containing the values of the model covariates at which predictions
are required. If this is not provided then predictions corresponding to the
original data are returned. If \code{newdata} is provided then
it should contain all the variables needed for prediction: a
warning is generated if not. See details for use with \code{link{linear.functional.terms}}. }
\item{object}{ a fitted \code{gam} object as produced by \code{gam()}.
}
\item{...}{Further arguments passed to \code{\link[mgcv]{predict.gam}} and
\code{\link{get_hazard}}}
\item{reference}{A data frame with number of rows equal to \code{nrow(newdata)} or
one, or a named list with (partial) covariate specifications. See examples.}
\item{type}{Either \code{"response"} or \code{"link"}. The former calculates
hazard, the latter the log-hazard.}
\item{ci}{\code{logical}. Indicates if confidence intervals should be
calculated. Defaults to \code{TRUE}.}
\item{se_mult}{Factor by which standard errors are multiplied for calculating
the confidence intervals.}
\item{ci_type}{The method by which standard errors/confidence intervals
will be calculated. Default transforms the linear predictor at
respective intervals. \code{"delta"} calculates CIs based on the standard
error calculated by the Delta method. \code{"sim"} draws the
property of interest from its posterior based on the normal distribution of
the estimated coefficients. See \href{https://adibender.github.io/simpamm/confidence-intervals.html}{here}
for details and empirical evaluation.}
\item{overwrite}{Should hazard columns be overwritten if already present in
the data set? Defaults to \code{FALSE}. If \code{TRUE}, columns with names
\code{c("hazard", "se", "lower", "upper")} will be overwritten.}
\item{time_var}{Name of the variable used for the baseline hazard. If
not given, defaults to \code{"tend"} for \code{\link[mgcv]{gam}} fits, else
\code{"interval"}. The latter is assumed to be a factor, the former
numeric.}
\item{interval_length}{The variable in newdata containing the interval lengths.
Can be either bare unquoted variable name or character. Defaults to \code{"intlen"}.}
}
\description{
Add (cumulative) hazard based on the provided data set and model.
If \code{ci=TRUE} confidence intervals (CI) are also added. Their width can
be controlled via the \code{se_mult} argument. The method by which the
CI are calculated can be specified by \code{ci_type}.
This is a wrapper around
\code{\link[mgcv]{predict.gam}}. When \code{reference} is specified, the
(log-)hazard ratio is calculated.
}
\examples{
ped <- tumor[1:50,] \%>\% as_ped(Surv(days, status)~ age)
pam <- mgcv::gam(ped_status ~ s(tend)+age, data = ped, family=poisson(), offset=offset)
ped_info(ped) \%>\% add_hazard(pam, type="link")
ped_info(ped) \%>\% add_hazard(pam, type = "response")
ped_info(ped) \%>\% add_cumu_hazard(pam)
}
\seealso{
\code{\link[mgcv]{predict.gam}},
\code{\link[pammtools]{add_surv_prob}}
}
pammtools/man/get_tdc_vars.Rd 0000644 0001750 0001750 00000000735 13662013606 016135 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/formula-utils.R
\name{get_tdc_vars}
\alias{get_tdc_vars}
\title{Extract variables from the left-hand-side of a formula}
\usage{
get_tdc_vars(formula, specials = "cumulative", data = NULL)
}
\arguments{
\item{formula}{A \code{\link{formula}} object.}
}
\description{
Extract variables from the left-hand-side of a formula
Extract variables from the right-hand side of a formula
}
\keyword{internal}
pammtools/man/gg_partial.Rd 0000644 0001750 0001750 00000003531 13662013606 015577 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/viz-elra.R
\name{gg_partial}
\alias{gg_partial}
\alias{gg_partial_ll}
\alias{get_partial_ll}
\title{Visualize effect estimates for specific covariate combinations}
\usage{
gg_partial(data, model, term, ..., reference = NULL, ci = TRUE)
gg_partial_ll(
data,
model,
term,
...,
reference = NULL,
ci = FALSE,
time_var = "tend"
)
get_partial_ll(
data,
model,
term,
...,
reference = NULL,
ci = FALSE,
time_var = "tend"
)
}
\arguments{
\item{data}{Data used to fit the \code{model}.}
\item{model}{A suitable model object which will be used to estimate the
partial effect of \code{term}.}
\item{term}{A character string indicating the model term for which partial
effects should be plotted.}
\item{...}{Covariate specifications (expressions) that will be evaluated
by looking for variables in \code{x}. Must be of the form \code{z = f(z)}
where \code{z} is a variable in the data set and \code{f} a known
function that can be usefully applied to \code{z}. Note that this is also
necessary for single value specifications (e.g. \code{age = c(50)}).
For data in PED (piece-wise exponential data) format, one can also specify
the time argument, but see "Details" an "Examples" below.}
\item{reference}{If specified, should be a list with covariate value pairs,
e.g. \code{list(x1 = 1, x2=50)}. The calculated partial effect will be relative
to an observation specified in \code{reference}.}
\item{ci}{Logical. Indicates if confidence intervals for the \code{term}
of interest should be calculated/plotted. Defaults to \code{TRUE}.}
\item{time_var}{The name of the variable that was used in \code{model} to
represent follow-up time.}
}
\description{
Depending on the plot function and input, creates either a 1-dimensional slices,
bivariate surface or (1D) cumulative effect.
}
pammtools/man/as.data.frame.crps.Rd 0000644 0001750 0001750 00000002142 13662013606 017035 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/model-evaluation.R
\name{as.data.frame.crps}
\alias{as.data.frame.crps}
\title{Transform crps object to data.frame}
\usage{
\method{as.data.frame}{crps}(x, row.names = NULL, optional = FALSE, ...)
}
\arguments{
\item{x}{An object of class \code{crps}. See \code{\link[pec]{crps}}.}
\item{row.names}{\code{NULL} or a character vector giving the row
names for the data frame. Missing values are not allowed.}
\item{optional}{logical. If \code{TRUE}, setting row names and
converting column names (to syntactic names: see
\code{\link[base]{make.names}}) is optional. Note that all of \R's
\pkg{base} package \code{as.data.frame()} methods use
\code{optional} only for column names treatment, basically with the
meaning of \code{\link[base]{data.frame}(*, check.names = !optional)}.
See also the \code{make.names} argument of the \code{matrix} method.}
\item{...}{additional arguments to be passed to or from methods.}
}
\description{
A\code{as.data.frame} S3 method for objects of class \code{\link[pec]{crps}}.
}
pammtools/man/gg_re.Rd 0000644 0001750 0001750 00000001413 14116612001 014533 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/convenience-plots.R
\name{gg_re}
\alias{gg_re}
\title{Plot Normal QQ plots for random effects}
\usage{
gg_re(x, ...)
}
\arguments{
\item{x}{ a fitted \code{gam} object as produced by \code{gam()}.}
\item{...}{Further arguments passed to \code{\link[mgcv]{plot.gam}}}
}
\description{
Plot Normal QQ plots for random effects
}
\examples{
library(pammtools)
data("patient")
ped <- patient \%>\%
dplyr::slice(1:100) \%>\%
as_ped(Surv(Survdays, PatientDied)~ ApacheIIScore + CombinedicuID, id="CombinedID")
pam <- mgcv::gam(ped_status ~ s(tend) + ApacheIIScore + s(CombinedicuID, bs="re"),
data=ped, family=poisson(), offset=offset)
gg_re(pam)
plot(pam, select = 2)
}
\seealso{
\code{\link{tidy_re}}
}
pammtools/man/staph.Rd 0000644 0001750 0001750 00000001353 14127313143 014601 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.R
\docType{data}
\name{staph}
\alias{staph}
\title{Time until staphylococcus aureaus infection in children, with possible recurrence}
\format{
An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 374 rows and 6 columns.
}
\usage{
staph
}
\description{
This dataset originates from the Drakenstein child health study.
The data contains the following variables:
\describe{
\item{id}{Randomly generated unique child ID}
\item{t.start}{The time at which the child enters the risk set for the $k$-th event}
\item{t.stop}{Time of $k$-th infection or censoring}.
\item{enum}{Event number. Maximum of 6.}
\item{hiv}{}
}
}
\keyword{datasets}
pammtools/man/compute_cumu_diff.Rd 0000644 0001750 0001750 00000001400 14116612001 017141 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cumulative-coefficient.R
\name{compute_cumu_diff}
\alias{compute_cumu_diff}
\title{Calculate difference in cumulative hazards and respective standard errors}
\usage{
compute_cumu_diff(d1, d2, model, alpha = 0.05, nsim = 100L)
}
\arguments{
\item{d1}{A data set used as \code{newdata} in \code{predict.gam}}
\item{d2}{See \code{d1}}
\item{model}{A model object for which a predict method is implemented which
returns the design matrix (e.g., \code{mgcv::gam}).}
}
\description{
CIs are calculated by sampling coefficients from their posterior and
calculating the cumulative hazard difference \code{nsim} times. The CI
are obtained by the 2.5\\% and 97.5\\% quantiles.
}
\keyword{internal}
pammtools/man/as_ped_cr.Rd 0000644 0001750 0001750 00000006157 14150243134 015406 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/as-ped.R
\name{as_ped_cr}
\alias{as_ped_cr}
\title{Competing risks trafo}
\usage{
as_ped_cr(
data,
formula,
cut = NULL,
max_time = NULL,
tdc_specials = c("concurrent", "cumulative"),
censor_code = 0L,
combine = TRUE,
...
)
}
\arguments{
\item{data}{Either an object inheriting from data frame or in case of
time-dependent covariates a list of data frames (of length 2), where the first data frame
contains the time-to-event information and static covariates while the second
(and potentially further data frames) contain information on time-dependent
covariates and the times at which they have been observed.}
\item{formula}{A two sided formula with a \code{\link[survival]{Surv}} object
on the left-hand-side and covariate specification on the right-hand-side (RHS).
The RHS can be an extended formula, which specifies how TDCs should be transformed
using specials \code{concurrent} and \code{cumulative}. The left hand-side can
be in start-stop-notation. This, however, is only used to create left-truncated
data and does not support the full functionality.}
\item{cut}{Split points, used to partition the follow up into intervals.
If unspecified, all unique event times will be used.}
\item{max_time}{If \code{cut} is unspecified, this will be the last
possible event time. All event times after \code{max_time}
will be administratively censored at \code{max_time}.}
\item{tdc_specials}{A character vector. Names of potential specials in
\code{formula} for concurrent and or cumulative effects.}
\item{censor_code}{Specifies the value of the status variable that indicates censoring.
Often this will be \code{0}, which is the default.}
\item{...}{Further arguments passed to the \code{data.frame} method and
eventually to \code{\link[survival]{survSplit}}}
}
\value{
A data frame class \code{ped} in piece-wise exponential data format.
}
\description{
This is the general data transformation function provided by the
\code{pammtools} package. Two main applications must be distinguished:
\enumerate{
\item Transformation of standard time-to-event data.
\item Transformation of left-truncated time-to-event data.
\item Transformation of time-to-event data with time-dependent covariates (TDC).
}
For the latter, the type of effect one wants to estimate is also
important for the data transformation step.
In any case, the data transformation is specified by a two sided formula.
In case of TDCs, the right-hand-side of the formula can contain formula specials
\code{concurrent} and \code{cumulative}.
See the \href{https://adibender.github.io/pammtools//articles/data-transformation.html}{data-transformation}
vignette for details.
}
\examples{
tumor[1:3, ]
tumor[1:3, ] \%>\% as_ped(Surv(days, status)~ age + sex, cut = c(0, 500, 1000))
tumor[1:3, ] \%>\% as_ped(Surv(days, status)~ age + sex)
\dontrun{
data("cgd", package = "frailtyHL")
cgd2 <- cgd \%>\%
select(id, tstart, tstop, enum, status, age) \%>\%
filter(enum \%in\% c(1:2))
ped_re <- as_ped_recurrent(
formula = Surv(tstart, tstop, status) ~ age + enum,
data = cgd2,
transition = "enum")
}
}
\keyword{internal}
pammtools/man/warn_about_new_time_points.Rd 0000644 0001750 0001750 00000000637 14150473217 021117 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/warnings.R
\name{warn_about_new_time_points}
\alias{warn_about_new_time_points}
\alias{warn_about_new_time_points.pamm}
\title{Warn if new t_j are used}
\usage{
warn_about_new_time_points(object, newdata, ...)
\method{warn_about_new_time_points}{pamm}(object, newdata, ...)
}
\description{
Warn if new t_j are used
}
\keyword{internal}
pammtools/man/pamm.Rd 0000644 0001750 0001750 00000004360 14150252766 014426 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pammfit.R
\name{pamm}
\alias{pamm}
\alias{is.pamm}
\alias{print.pamm}
\alias{summary.pamm}
\alias{plot.pamm}
\title{Fit a piece-wise exponential additive model}
\usage{
pamm(formula, data = list(), ..., trafo_args = NULL, engine = "gam")
is.pamm(x)
\method{print}{pamm}(x, ...)
\method{summary}{pamm}(object, ...)
\method{plot}{pamm}(x, ...)
}
\arguments{
\item{formula}{ A GAM formula, or a list of formulae (see \code{\link[mgcv]{formula.gam}} and also \code{\link[mgcv]{gam.models}}).
These are exactly like the formula for a GLM except that smooth terms, \code{\link[mgcv]{s}}, \code{\link[mgcv]{te}}, \code{\link[mgcv]{ti}}
and \code{\link[mgcv]{t2}}, can be added to the right hand side to specify that the linear predictor depends on smooth functions of predictors (or linear functionals of these).
}
\item{data}{ A data frame or list containing the model response variable and
covariates required by the formula. By default the variables are taken
from \code{environment(formula)}: typically the environment from
which \code{gam} is called.}
\item{...}{Further arguments passed to \code{engine}.}
\item{trafo_args}{A named list. If data is not in PED format, \code{as_ped}
will be called internally with arguments provided in \code{trafo_args}.}
\item{engine}{Character name of the function that will be called to fit the
model. The intended entries are either \code{"gam"} or \code{"bam"}
(both from package \code{mgcv}).}
\item{x}{Any R object.}
\item{object}{An object of class \code{pamm} as returned by \code{\link{pamm}}.}
}
\description{
A thin wrapper around \code{\link[mgcv]{gam}}, however, some arguments are
prespecified:
\code{family=poisson()} and \code{offset=data$offset}.
These two can not be overwritten. In many cases it will also be advisable to
set \code{method="REML"}.
}
\examples{
ped <- tumor[1:100, ] \%>\%
as_ped(Surv(days, status) ~ complications, cut = seq(0, 3000, by = 50))
pam <- pamm(ped_status ~ s(tend) + complications, data = ped)
summary(pam)
## Alternatively
pamm(
ped_status ~ s(tend) + complications,
data = tumor[1:100, ],
trafo_args = list(formula = Surv(days, status)~complications))
}
\seealso{
\code{\link[mgcv]{gam}}
}
\keyword{internal}
pammtools/man/rpexp.Rd 0000644 0001750 0001750 00000001317 14150244027 014620 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rpexp.R
\name{rpexp}
\alias{rpexp}
\title{Draw random numbers from piece-wise exponential distribution.}
\usage{
rpexp(n = 1, rate = 1, t = 0)
}
\arguments{
\item{n}{number of observations. If \code{length(n) > 1}, the length is
taken to be the number required.}
\item{rate}{vector of rates.}
\item{t}{vector of the same length as \code{rate}, giving the times at
which the rate changes. The first element of \code{t} should be 0,
and \code{t} should be in increasing order.}
}
\description{
This is a copy of the same function from \code{rpexp} from package
\pkg{msm}.
Copied here to reduce dependencies.
}
\keyword{internal}
pammtools/man/get_ped_form.Rd 0000644 0001750 0001750 00000000772 13662013606 016124 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/formula-utils.R
\name{get_ped_form}
\alias{get_ped_form}
\title{Extract variables from the left-hand-side of a formula}
\usage{
get_ped_form(
formula,
data = NULL,
tdc_specials = c("concurrent", "cumulative")
)
}
\arguments{
\item{formula}{A \code{\link{formula}} object.}
}
\description{
Extract variables from the left-hand-side of a formula
Extract variables from the right-hand side of a formula
}
\keyword{internal}
pammtools/man/get_cut.Rd 0000644 0001750 0001750 00000000733 14116612001 015106 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/get-cut-points.R
\name{get_cut}
\alias{get_cut}
\alias{get_cut.default}
\title{Obtain interval break points}
\usage{
get_cut(data, formula, cut = NULL, ...)
\method{get_cut}{default}(data, formula, cut = NULL, max_time = NULL, event = 1L, ...)
}
\description{
Default method words for data frames.
The list method applies the default method to each data set within the list.
}
\keyword{internal}
pammtools/man/get_sim_ci.Rd 0000644 0001750 0001750 00000000524 13662013606 015567 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/add-functions.R
\name{get_sim_ci}
\alias{get_sim_ci}
\title{Calculate simulation based confidence intervals}
\usage{
get_sim_ci(newdata, object, alpha = 0.05, nsim = 100L, ...)
}
\description{
Calculate simulation based confidence intervals
}
\keyword{internal}
pammtools/man/gg_smooth.Rd 0000644 0001750 0001750 00000001515 13662013606 015454 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/convenience-plots.R
\name{gg_smooth}
\alias{gg_smooth}
\alias{gg_smooth.default}
\title{Plot smooth 1d terms of gam objects}
\usage{
gg_smooth(x, ...)
\method{gg_smooth}{default}(x, fit, ...)
}
\arguments{
\item{x}{A data frame or object of class \code{ped}.}
\item{...}{Further arguments passed to \code{\link{get_terms}}}
\item{fit}{A model object.}
}
\value{
A \code{\link[ggplot2]{ggplot}} object.
}
\description{
Given a gam model this convenience function returns a plot of all
smooth terms contained in the model. If more than one smooth is present, the
different smooth are faceted.
}
\examples{
g1 <- mgcv::gam(Sepal.Length ~ s(Sepal.Width) + s(Petal.Length), data=iris)
gg_smooth(iris, g1, terms=c("Sepal.Width", "Petal.Length"))
}
\seealso{
get_terms
}
pammtools/man/gg_laglead.Rd 0000644 0001750 0001750 00000002647 13662013606 015543 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lag-lead-utils.R
\name{gg_laglead}
\alias{gg_laglead}
\alias{gg_laglead.default}
\alias{gg_laglead.LL_df}
\alias{gg_laglead.nested_fdf}
\title{Plot Lag-Lead windows}
\usage{
gg_laglead(x, ...)
\method{gg_laglead}{default}(x, tz, ll_fun, ...)
\method{gg_laglead}{LL_df}(
x,
high_col = "grey20",
low_col = "whitesmoke",
grid_col = "lightgrey",
...
)
\method{gg_laglead}{nested_fdf}(x, ...)
}
\arguments{
\item{x}{Either a numeric vector of follow-up cut points or a suitable object.}
\item{...}{Further arguments passed to methods.}
\item{tz}{A vector of exposure times}
\item{ll_fun}{Function that specifies how the lag-lead matrix
should be constructed. First argument is the follow up time
second argument is the time of exposure.}
\item{high_col}{Color used to highlight exposure times within the lag-lead window.}
\item{low_col}{Color of exposure times outside the lag-lead window.}
\item{grid_col}{Color of grid lines.}
}
\description{
Given data defining a Lag-lead window, returns respective plot as a
\code{ggplot2} object.
}
\examples{
## Example 1: supply t, tz, ll_fun directly
gg_laglead(1:10, tz=-5:5,
ll_fun=function(t, tz) { t >= tz + 2 & t <= tz + 2 + 3})
## Example 2: extract information on t, tz, ll_from data with respective attributes
data("simdf_elra", package = "pammtools")
gg_laglead(simdf_elra)
}
\seealso{
get_laglead
}
pammtools/man/add_term.Rd 0000644 0001750 0001750 00000004650 13662013606 015250 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/add-functions.R
\name{add_term}
\alias{add_term}
\title{Embeds the data set with the specified (relative) term contribution}
\usage{
add_term(newdata, object, term, reference = NULL, ci = TRUE, se_mult = 2, ...)
}
\arguments{
\item{newdata}{ A data frame or list containing the values of the model covariates at which predictions
are required. If this is not provided then predictions corresponding to the
original data are returned. If \code{newdata} is provided then
it should contain all the variables needed for prediction: a
warning is generated if not. See details for use with \code{link{linear.functional.terms}}. }
\item{object}{ a fitted \code{gam} object as produced by \code{gam()}.
}
\item{term}{A character (vector) or regular expression indicating for
which term(s) information should be extracted and added to data set.}
\item{reference}{A data frame with number of rows equal to \code{nrow(newdata)} or
one, or a named list with (partial) covariate specifications. See examples.}
\item{ci}{\code{logical}. Indicates if confidence intervals should be
calculated. Defaults to \code{TRUE}.}
\item{se_mult}{The factor by which standard errors are multiplied to form
confidence intervals.}
\item{...}{Further arguments passed to \code{\link[mgcv]{predict.gam}}}
}
\description{
Adds the contribution of a specific term to the
linear predictor to the data specified by \code{newdata}.
Essentially a wrapper to \code{\link[mgcv]{predict.gam}}, with \code{type="terms"}.
Thus most arguments and their documentation below is from \code{\link[mgcv]{predict.gam}}.
}
\examples{
library(ggplot2)
ped <- as_ped(tumor, Surv(days, status)~ age, cut = seq(0, 2000, by = 100))
pam <- mgcv::gam(ped_status ~ s(tend) + s(age), family = poisson(),
offset = offset, data = ped)
#term contribution for sequence of ages
s_age <- ped \%>\% make_newdata(age = seq_range(age, 50)) \%>\%
add_term(pam, term = "age")
ggplot(s_age, aes(x = age, y = fit)) + geom_line() +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = .3)
# term contribution relative to mean age
s_age2 <- ped \%>\% make_newdata(age = seq_range(age, 50)) \%>\%
add_term(pam, term = "age", reference = list(age = mean(.$age)))
ggplot(s_age2, aes(x = age, y = fit)) + geom_line() +
geom_ribbon(aes(ymin = ci_lower, ymax = ci_upper), alpha = .3)
}
pammtools/man/calc_ci.Rd 0000644 0001750 0001750 00000000776 14116612001 015040 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tidiers.R
\name{calc_ci}
\alias{calc_ci}
\title{Calculate confidence intervals}
\usage{
calc_ci(ftab)
}
\arguments{
\item{ftab}{A table with two columns, containing coefficients in the first
column and standard-errors in the second column.}
}
\description{
Given 2 column matrix or data frame, returns 3 column data.frame
with coefficient estimate plus lower and upper borders of the
95\% confidence intervals.
}
\keyword{internal}
pammtools/man/geom_hazard.Rd 0000644 0001750 0001750 00000010465 14122025561 015745 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/geom-hazard.R
\docType{data}
\name{geom_hazard}
\alias{geom_hazard}
\alias{GeomHazard}
\alias{geom_stephazard}
\alias{GeomStepHazard}
\alias{geom_surv}
\alias{GeomSurv}
\title{(Cumulative) (Step-) Hazard Plots.}
\usage{
geom_hazard(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
geom_stephazard(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
direction = "vh",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
geom_surv(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
}
\arguments{
\item{mapping}{Set of aesthetic mappings created by \code{\link[ggplot2:aes]{aes()}} or
\code{\link[ggplot2:aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
default), it is combined with the default mapping at the top level of the
plot. You must supply \code{mapping} if there is no plot mapping.}
\item{data}{The data to be displayed in this layer. There are three
options:
If \code{NULL}, the default, the data is inherited from the plot
data as specified in the call to \code{\link[ggplot2:ggplot]{ggplot()}}.
A \code{data.frame}, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
\code{\link[ggplot2:fortify]{fortify()}} for which variables will be created.
A \code{function} will be called with a single argument,
the plot data. The return value must be a \code{data.frame}, and
will be used as the layer data. A \code{function} can be created
from a \code{formula} (e.g. \code{~ head(.x, 10)}).}
\item{stat}{The statistical transformation to use on the data for this
layer, as a string.}
\item{position}{Position adjustment, either as a string, or the result of
a call to a position adjustment function.}
\item{na.rm}{If \code{FALSE}, the default, missing values are removed with
a warning. If \code{TRUE}, missing values are silently removed.}
\item{show.legend}{logical. Should this layer be included in the legends?
\code{NA}, the default, includes if any aesthetics are mapped.
\code{FALSE} never includes, and \code{TRUE} always includes.
It can also be a named logical vector to finely select the aesthetics to
display.}
\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.}
\item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}. These are
often aesthetics, used to set an aesthetic to a fixed value, like
\code{colour = "red"} or \code{size = 3}. They may also be parameters
to the paired geom/stat.}
\item{direction}{direction of stairs: 'vh' for vertical then horizontal,
'hv' for horizontal then vertical, or 'mid' for step half-way between
adjacent x-values.}
}
\description{
\code{geom_hazard} is an extension of the \code{geom_line}, and
is optimized for (cumulative) hazard plots. Essentially, it adds a (0,0)
row to the data, if not already the case. Stolen from the
\code{RmcdrPlugin.KMggplot2} (slightly modified).
}
\examples{
library(ggplot2)
library(pammtools)
ped <- tumor[10:50,] \%>\% as_ped(Surv(days, status)~1)
pam <- mgcv::gam(ped_status ~ s(tend), data=ped, family = poisson(), offset = offset)
ndf <- make_newdata(ped, tend = unique(tend)) \%>\% add_hazard(pam)
# piece-wise constant hazards
ggplot(ndf, aes(x = tend, y = hazard)) +
geom_vline(xintercept = c(0, ndf$tend[c(1, (nrow(ndf)-2):nrow(ndf))]), lty = 3) +
geom_hline(yintercept = c(ndf$hazard[1:3], ndf$hazard[nrow(ndf)]), lty = 3) +
geom_stephazard() +
geom_step(col=2) +
geom_step(col=2, lty = 2, direction="vh")
# comulative hazard
ndf <- ndf \%>\% add_cumu_hazard(pam)
ggplot(ndf, aes(x = tend, y = cumu_hazard)) +
geom_hazard() +
geom_line(col=2) # doesn't start at (0, 0)
# survival probability
ndf <- ndf \%>\% add_surv_prob(pam)
ggplot(ndf, aes(x = tend, y = surv_prob)) +
geom_surv() +
geom_line(col=2) # doesn't start at c(0,1)
}
\seealso{
\code{\link[ggplot2]{geom_line}},
\code{\link[ggplot2]{geom_step}}.
}
\keyword{datasets}
pammtools/man/get_cif.Rd 0000644 0001750 0001750 00000000650 14116612001 015052 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/add-functions.R
\name{get_cif}
\alias{get_cif}
\alias{get_cif.default}
\title{Calculate CIF for one cause}
\usage{
get_cif(newdata, object, ...)
\method{get_cif}{default}(
newdata,
object,
ci,
time_var,
alpha,
n_sim,
cause_var,
coefs,
V,
sim_coef_mat,
...
)
}
\description{
Calculate CIF for one cause
}
\keyword{internal}
pammtools/man/pammtools.Rd 0000644 0001750 0001750 00000005646 14116612001 015477 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pammtools.R
\docType{package}
\name{pammtools}
\alias{pammtools}
\title{pammtools: Piece-wise exponential Additive Mixed Modeling tools.}
\description{
\code{pammtools} provides functions and utilities that facilitate fitting
Piece-wise Exponential Additive Mixed Models (PAMMs), including data
transformation and other convenience functions for pre- and post-processing
as well as plotting.
}
\details{
The best way to get an overview of the functionality provided and how to
fit PAMMs is to view the vignettes
available at \url{https://adibender.github.io/pammtools/articles/}.
A summary of the vignettes' content is given below:
\itemize{
\item \href{https://adibender.github.io/pammtools/articles/basics.html}{basics}:
Introduction to PAMMs and basic modeling.
\item \href{https://adibender.github.io/pammtools/articles/baseline.html}{baseline}:
Shows how to estimate and visualize baseline model (without covariates) and
comparison to respective Cox-PH model.
\item \href{https://adibender.github.io/pammtools/articles/convenience.html}{convenience}:
Convenience functions for post-processing and plotting PAMMs.
\item \href{https://adibender.github.io/pammtools/articles/data-transformation.html}{data-transformation}:
Transforming data into a format suitable to fit PAMMs.
\item \href{https://adibender.github.io/pammtools/articles/frailty.html}{frailty}:
Specifying "frailty" terms, i.e., random effects for PAMMs.
\item \href{https://adibender.github.io/pammtools/articles/splines.html}{splines}:
Specifying spline smooth terms for PAMMs.
\item \href{https://adibender.github.io/pammtools/articles/strata.html}{strata}:
Specifying stratified models in which each level of a grouping variable has a
different baseline hazard.
\item \href{https://adibender.github.io/pammtools/articles/tdcovar.html}{tdcovar}:
Dealing with time-dependent covariates.
\item \href{https://adibender.github.io/pammtools/articles/tveffects.html}{tveffects}:
Specifying time-varying effects.
\item \href{https://adibender.github.io/pammtools/articles/left-truncation.html}{left-truncation}:
Estimation for left-truncated data.
\item \href{https://adibender.github.io/pammtools/articles/competing-risks.html}{competing-risks}:
Competing risks analysis.
}
}
\references{
Bender, Andreas, Andreas Groll, and Fabian Scheipl. 2018.
“A Generalized Additive Model Approach to Time-to-Event Analysis”
Statistical Modelling, February. https://doi.org/10.1177/1471082X17748083.
Bender, Andreas, Fabian Scheipl, Wolfgang Hartl, Andrew G. Day, and Helmut Küchenhoff. 2019.
“Penalized Estimation of Complex, Non-Linear Exposure-Lag-Response Associations.”
Biostatistics 20 (2): 315–31. https://doi.org/10.1093/biostatistics/kxy003.
Bender, Andreas, and Fabian Scheipl. 2018.
“pammtools: Piece-Wise Exponential Additive Mixed Modeling Tools.”
ArXiv:1806.01042 \link{Stat}, June. https://arxiv.org/abs/1806.01042.
}
pammtools/man/geom_stepribbon.Rd 0000644 0001750 0001750 00000006205 14116612001 016632 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ggplot-extensions.R
\docType{data}
\name{geom_stepribbon}
\alias{geom_stepribbon}
\alias{GeomStepribbon}
\title{Step ribbon plots.}
\usage{
geom_stepribbon(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
}
\arguments{
\item{mapping}{Set of aesthetic mappings created by \code{\link[ggplot2:aes]{aes()}} or
\code{\link[ggplot2:aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
default), it is combined with the default mapping at the top level of the
plot. You must supply \code{mapping} if there is no plot mapping.}
\item{data}{The data to be displayed in this layer. There are three
options:
If \code{NULL}, the default, the data is inherited from the plot
data as specified in the call to \code{\link[ggplot2:ggplot]{ggplot()}}.
A \code{data.frame}, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
\code{\link[ggplot2:fortify]{fortify()}} for which variables will be created.
A \code{function} will be called with a single argument,
the plot data. The return value must be a \code{data.frame}, and
will be used as the layer data. A \code{function} can be created
from a \code{formula} (e.g. \code{~ head(.x, 10)}).}
\item{stat}{The statistical transformation to use on the data for this
layer, as a string.}
\item{position}{Position adjustment, either as a string, or the result of
a call to a position adjustment function.}
\item{na.rm}{If \code{FALSE}, the default, missing values are removed with
a warning. If \code{TRUE}, missing values are silently removed.}
\item{show.legend}{logical. Should this layer be included in the legends?
\code{NA}, the default, includes if any aesthetics are mapped.
\code{FALSE} never includes, and \code{TRUE} always includes.
It can also be a named logical vector to finely select the aesthetics to
display.}
\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.}
\item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}. These are
often aesthetics, used to set an aesthetic to a fixed value, like
\code{colour = "red"} or \code{size = 3}. They may also be parameters
to the paired geom/stat.}
}
\description{
\code{geom_stepribbon} is an extension of the \code{geom_ribbon}, and
is optimized for Kaplan-Meier plots with pointwise confidence intervals
or a confidence band.
}
\examples{
library(ggplot2)
huron <- data.frame(year = 1875:1972, level = as.vector(LakeHuron))
h <- ggplot(huron, aes(year))
h + geom_stepribbon(aes(ymin = level - 1, ymax = level + 1), fill = "grey70") +
geom_step(aes(y = level))
h + geom_ribbon(aes(ymin = level - 1, ymax = level + 1), fill = "grey70") +
geom_line(aes(y = level))
}
\seealso{
\code{\link[ggplot2]{geom_ribbon}} \code{geom_stepribbon}
inherits from \code{geom_ribbon}.
}
\keyword{datasets}
pammtools/man/gg_slice.Rd 0000644 0001750 0001750 00000004065 13662013606 015245 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/viz-elra.R
\name{gg_slice}
\alias{gg_slice}
\title{Plot 1D (smooth) effects}
\usage{
gg_slice(data, model, term, ..., reference = NULL, ci = TRUE)
}
\arguments{
\item{data}{Data used to fit the \code{model}.}
\item{model}{A suitable model object which will be used to estimate the
partial effect of \code{term}.}
\item{term}{A character string indicating the model term for which partial
effects should be plotted.}
\item{...}{Covariate specifications (expressions) that will be evaluated
by looking for variables in \code{x}. Must be of the form \code{z = f(z)}
where \code{z} is a variable in the data set and \code{f} a known
function that can be usefully applied to \code{z}. Note that this is also
necessary for single value specifications (e.g. \code{age = c(50)}).
For data in PED (piece-wise exponential data) format, one can also specify
the time argument, but see "Details" an "Examples" below.}
\item{reference}{If specified, should be a list with covariate value pairs,
e.g. \code{list(x1 = 1, x2=50)}. The calculated partial effect will be relative
to an observation specified in \code{reference}.}
\item{ci}{Logical. Indicates if confidence intervals for the \code{term}
of interest should be calculated/plotted. Defaults to \code{TRUE}.}
}
\description{
Flexible, high-level plotting function for (non-linear) effects conditional
on further covariate specifications and potentially relative to
a comparison specification.
}
\examples{
ped <- tumor[1:200, ] \%>\% as_ped(Surv(days, status) ~ . )
model <- mgcv::gam(ped_status~s(tend) + s(age, by = complications), data=ped,
family = poisson(), offset=offset)
make_newdata(ped, age = seq_range(age, 20), complications = levels(complications))
gg_slice(ped, model, "age", age=seq_range(age, 20), complications=levels(complications))
gg_slice(ped, model, "age", age=seq_range(age, 20), complications=levels(complications),
ci = FALSE)
gg_slice(ped, model, "age", age=seq_range(age, 20), complications=levels(complications),
reference=list(age = 50))
}
pammtools/man/sample_info.Rd 0000644 0001750 0001750 00000002074 13662013606 015763 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/make-newdata.R
\name{sample_info}
\alias{sample_info}
\alias{sample_info.data.frame}
\alias{sample_info.ped}
\alias{sample_info.fped}
\title{Extract information of the sample contained in a data set}
\usage{
sample_info(x)
\method{sample_info}{data.frame}(x)
\method{sample_info}{ped}(x)
\method{sample_info}{fped}(x)
}
\arguments{
\item{x}{A data frame (or object that inherits from \code{data.frame}).}
}
\value{
A data frame containing sample information (for each group).
If applied to an object of class \code{ped}, the sample means of the
original data is returned.
Note: When applied to a \code{ped} object, that doesn't contain covariates
(only interval information), returns data frame with 0 columns.
}
\description{
Given a data set and grouping variables, this function returns mean values
for numeric variables and modus for characters and factors. Usually
this function should not be called directly but will rather be called
as part of a call to \code{make_newdata}.
}
\keyword{internal}
pammtools/man/get_plotinfo.Rd 0000644 0001750 0001750 00000001024 13662013606 016152 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tidiers.R
\name{get_plotinfo}
\alias{get_plotinfo}
\title{Extract plot information for all special model terms}
\usage{
get_plotinfo(x, ...)
}
\arguments{
\item{x}{ a fitted \code{gam} object as produced by \code{gam()}.}
\item{...}{Further arguments passed to \code{\link[mgcv]{plot.gam}}}
}
\description{
Given a \code{mgcv} \code{\link[mgcv]{gamObject}}, returns the information
used for the default plots produced by \code{\link[mgcv]{plot.gam}}.
}
pammtools/man/modus.Rd 0000644 0001750 0001750 00000000405 13662013606 014612 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/helpers.R
\name{modus}
\alias{modus}
\title{Calculate the modus}
\usage{
modus(var)
}
\arguments{
\item{var}{A atomic vector}
}
\description{
Calculate the modus
}
\keyword{internal}
pammtools/man/get_term.Rd 0000644 0001750 0001750 00000001550 14116612001 015260 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/get-terms.R
\name{get_term}
\alias{get_term}
\title{Extract partial effects for specified model terms}
\usage{
get_term(data, fit, term, n = 100, ...)
}
\arguments{
\item{data}{A data frame containing variables used to fit the model. Only
first row will be used.}
\item{fit}{A fitted object of class \code{\link[mgcv]{gam}}.}
\item{term}{The (non-linear) model term of interest.}
\item{n}{Specify the output sequence either by supplying the
length of the sequence with \code{n}, or the spacing between value
with \code{by}. Specifying both is an error.
I recommend that you name these arguments in order to make it clear to
the reader.}
\item{...}{Further arguments passed to \code{\link{seq_range}}.}
}
\description{
Extract partial effects for specified model terms
}
\keyword{internal}
pammtools/man/patient.Rd 0000644 0001750 0001750 00000002444 14122025561 015127 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.R
\docType{data}
\name{patient}
\alias{patient}
\title{Survival data of critically ill ICU patients}
\format{
An object of class \code{data.frame} with 2000 rows and 12 columns.
}
\usage{
patient
}
\description{
A data set containing the survival time (or hospital release time) among
other covariates.
The full data is available \href{https://github.com/adibender/elra-biostats}{here}.
The following variables are provided:
\describe{
\item{Year}{The year of ICU Admission}
\item{CombinedicuID}{Intensive Care Unit (ICU) ID}
\item{CombinedID}{Patient identificator}
\item{Survdays}{Survival time of patients. Here it is assumed that patients
survive until t=30 if released from hospital.}
\item{PatientDied}{Status indicator; 1=death, 0=censoring}
\item{survhosp}{Survival time in hospital. Here it is assumed that patients
are censored at time of hospital release (potentially informative)}
\item{Gender}{Male or female}
\item{Age}{The patients age at Admission}
\item{AdmCatID}{Admission category: medical, surgical elective or surgical emergency}
\item{ApacheIIScore}{The patient's Apache II Score at Admission}
\item{BMI}{Patient's Body Mass Index}
\item{DiagID2}{Diagnosis at admission in 9 categories} }
}
\keyword{datasets}
pammtools/man/add_cif.Rd 0000644 0001750 0001750 00000003664 14116612001 015033 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/add-functions.R
\name{add_cif}
\alias{add_cif}
\alias{add_cif.default}
\title{Add cumulative incidence function to data}
\usage{
add_cif(newdata, object, ...)
\method{add_cif}{default}(
newdata,
object,
ci = TRUE,
overwrite = FALSE,
alpha = 0.05,
n_sim = 500L,
cause_var = "cause",
time_var = NULL,
...
)
}
\arguments{
\item{newdata}{ A data frame or list containing the values of the model covariates at which predictions
are required. If this is not provided then predictions corresponding to the
original data are returned. If \code{newdata} is provided then
it should contain all the variables needed for prediction: a
warning is generated if not. See details for use with \code{link{linear.functional.terms}}. }
\item{object}{ a fitted \code{gam} object as produced by \code{gam()}.
}
\item{...}{Further arguments passed to \code{\link[mgcv]{predict.gam}} and
\code{\link{get_hazard}}}
\item{ci}{\code{logical}. Indicates if confidence intervals should be
calculated. Defaults to \code{TRUE}.}
\item{overwrite}{Should hazard columns be overwritten if already present in
the data set? Defaults to \code{FALSE}. If \code{TRUE}, columns with names
\code{c("hazard", "se", "lower", "upper")} will be overwritten.}
\item{alpha}{The alpha level for confidence/credible intervals.}
\item{n_sim}{Number of simulations (draws from posterior of estimated coefficients)
on which estimation of CIFs and their confidence/credible intervals will be
based on.}
\item{cause_var}{Character. Column name of the 'cause' variable.}
\item{time_var}{Name of the variable used for the baseline hazard. If
not given, defaults to \code{"tend"} for \code{\link[mgcv]{gam}} fits, else
\code{"interval"}. The latter is assumed to be a factor, the former
numeric.}
}
\description{
Add cumulative incidence function to data
}
pammtools/man/sim_pexp.Rd 0000644 0001750 0001750 00000005566 14150243134 015316 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sim-pexp.R
\name{sim_pexp}
\alias{sim_pexp}
\title{Simulate survival times from the piece-wise exponential distribution}
\usage{
sim_pexp(formula, data, cut)
}
\arguments{
\item{formula}{An extended formula that specifies the linear predictor.
If you want to include a smooth baseline
or time-varying effects, use \code{t} within your formula as
if it was a covariate in the data, although it is not and should not
be included in the \code{data} provided to \code{sim_pexp}. See examples
below.}
\item{data}{A data set with variables specified in \code{formula}.}
\item{cut}{A sequence of time-points starting with 0.}
}
\description{
Simulate survival times from the piece-wise exponential distribution
}
\examples{
library(survival)
library(dplyr)
library(pammtools)
# set number of observations/subjects
n <- 250
# create data set with variables which will affect the hazard rate.
df <- cbind.data.frame(x1 = runif (n, -3, 3), x2 = runif (n, 0, 6)) \%>\%
as_tibble()
# the formula which specifies how covariates affet the hazard rate
f0 <- function(t) {
dgamma(t, 8, 2) *6
}
form <- ~ -3.5 + f0(t) -0.5*x1 + sqrt(x2)
set.seed(24032018)
sim_df <- sim_pexp(form, df, 1:10)
head(sim_df)
plot(survfit(Surv(time, status)~1, data = sim_df ))
# for control, estimate with Cox PH
mod <- coxph(Surv(time, status) ~ x1 + pspline(x2), data=sim_df)
coef(mod)[1]
layout(matrix(1:2, nrow=1))
termplot(mod, se = TRUE)
# and using PAMs
layout(1)
ped <- sim_df \%>\% as_ped(Surv(time, status)~., max_time=10)
library(mgcv)
pam <- gam(ped_status ~ s(tend) + x1 + s(x2), data=ped, family=poisson, offset=offset)
coef(pam)[2]
plot(pam, page=1)
\dontrun{
# Example 2: Functional covariates/cumulative coefficients
# function to generate one exposure profile, tz is a vector of time points
# at which TDC z was observed
rng_z = function(nz) {
as.numeric(arima.sim(n = nz, list(ar = c(.8, -.6))))
}
# two different exposure times for two different exposures
tz1 <- 1:10
tz2 <- -5:5
# generate exposures and add to data set
df <- df \%>\%
add_tdc(tz1, rng_z) \%>\%
add_tdc(tz2, rng_z)
df
# define tri-variate function of time, exposure time and exposure z
ft <- function(t, tmax) {
-1*cos(t/tmax*pi)
}
fdnorm <- function(x) (dnorm(x,1.5,2)+1.5*dnorm(x,7.5,1))
wpeak2 <- function(lag) 15*dnorm(lag,8,10)
wdnorm <- function(lag) 5*(dnorm(lag,4,6)+dnorm(lag,25,4))
f_xyz1 <- function(t, tz, z) {
ft(t, tmax=10) * 0.8*fdnorm(z)* wpeak2(t - tz)
}
f_xyz2 <- function(t, tz, z) {
wdnorm(t-tz) * z
}
# define lag-lead window function
ll_fun <- function(t, tz) {t >= tz}
ll_fun2 <- function(t, tz) {t - 2 >= tz}
# simulate data with cumulative effect
sim_df <- sim_pexp(
formula = ~ -3.5 + f0(t) -0.5*x1 + sqrt(x2)|
fcumu(t, tz1, z.tz1, f_xyz=f_xyz1, ll_fun=ll_fun) +
fcumu(t, tz2, z.tz2, f_xyz=f_xyz2, ll_fun=ll_fun2),
data = df,
cut = 0:10)
}
}
pammtools/man/as_ped.Rd 0000644 0001750 0001750 00000007770 14150243134 014724 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/as-ped.R
\name{as_ped}
\alias{as_ped}
\alias{as_ped.data.frame}
\alias{as_ped.nested_fdf}
\alias{as_ped.list}
\alias{is.ped}
\alias{as_ped.ped}
\alias{as_ped.pamm}
\alias{as_ped_recurrent}
\title{Transform data to Piece-wise Exponential Data (PED)}
\usage{
as_ped(data, ...)
\method{as_ped}{data.frame}(
data,
formula,
cut = NULL,
max_time = NULL,
tdc_specials = c("concurrent", "cumulative"),
censor_code = 0L,
transition = character(),
timescale = c("gap", "calendar"),
min_events = 1L,
...
)
\method{as_ped}{nested_fdf}(data, formula, ...)
\method{as_ped}{list}(data, formula, tdc_specials = c("concurrent", "cumulative"), ...)
is.ped(x)
\method{as_ped}{ped}(data, newdata, ...)
\method{as_ped}{pamm}(data, newdata, ...)
as_ped_recurrent(
data,
formula,
cut = NULL,
max_time = NULL,
tdc_specials = c("concurrent", "cumulative"),
censor_code = 0L,
transition = character(),
timescale = c("gap", "calendar"),
min_events = 1L,
...
)
}
\arguments{
\item{data}{Either an object inheriting from data frame or in case of
time-dependent covariates a list of data frames (of length 2), where the first data frame
contains the time-to-event information and static covariates while the second
(and potentially further data frames) contain information on time-dependent
covariates and the times at which they have been observed.}
\item{...}{Further arguments passed to the \code{data.frame} method and
eventually to \code{\link[survival]{survSplit}}}
\item{formula}{A two sided formula with a \code{\link[survival]{Surv}} object
on the left-hand-side and covariate specification on the right-hand-side (RHS).
The RHS can be an extended formula, which specifies how TDCs should be transformed
using specials \code{concurrent} and \code{cumulative}. The left hand-side can
be in start-stop-notation. This, however, is only used to create left-truncated
data and does not support the full functionality.}
\item{cut}{Split points, used to partition the follow up into intervals.
If unspecified, all unique event times will be used.}
\item{max_time}{If \code{cut} is unspecified, this will be the last
possible event time. All event times after \code{max_time}
will be administratively censored at \code{max_time}.}
\item{tdc_specials}{A character vector. Names of potential specials in
\code{formula} for concurrent and or cumulative effects.}
\item{censor_code}{Specifies the value of the status variable that indicates censoring.
Often this will be \code{0}, which is the default.}
\item{x}{any R object.}
\item{newdata}{A new data set (\code{data.frame}) that contains the same
variables that were used to create the PED object (code{data}).}
}
\value{
A data frame class \code{ped} in piece-wise exponential data format.
}
\description{
This is the general data transformation function provided by the
\code{pammtools} package. Two main applications must be distinguished:
\enumerate{
\item Transformation of standard time-to-event data.
\item Transformation of left-truncated time-to-event data.
\item Transformation of time-to-event data with time-dependent covariates (TDC).
}
For the latter, the type of effect one wants to estimate is also
important for the data transformation step.
In any case, the data transformation is specified by a two sided formula.
In case of TDCs, the right-hand-side of the formula can contain formula specials
\code{concurrent} and \code{cumulative}.
See the \href{https://adibender.github.io/pammtools//articles/data-transformation.html}{data-transformation}
vignette for details.
}
\examples{
tumor[1:3, ]
tumor[1:3, ] \%>\% as_ped(Surv(days, status)~ age + sex, cut = c(0, 500, 1000))
tumor[1:3, ] \%>\% as_ped(Surv(days, status)~ age + sex)
\dontrun{
data("cgd", package = "frailtyHL")
cgd2 <- cgd \%>\%
select(id, tstart, tstop, enum, status, age) \%>\%
filter(enum \%in\% c(1:2))
ped_re <- as_ped_recurrent(
formula = Surv(tstart, tstop, status) ~ age + enum,
data = cgd2,
transition = "enum")
}
}
\keyword{internal}
pammtools/man/pipe.Rd 0000644 0001750 0001750 00000000400 13662013606 014413 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils-pipe.R
\name{\%>\%}
\alias{\%>\%}
\title{Pipe operator}
\usage{
lhs \%>\% rhs
}
\description{
See \code{magrittr::\link[magrittr]{\%>\%}} for details.
}
\keyword{internal}
pammtools/man/cumulative_coefficient.Rd 0000644 0001750 0001750 00000003023 13662013606 020176 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cumulative-coefficient.R
\name{get_cumu_coef}
\alias{get_cumu_coef}
\alias{get_cumu_coef.gam}
\alias{get_cumu_coef.aalen}
\alias{get_cumu_coef.cox.aalen}
\title{Extract cumulative coefficients (cumulative hazard differences)}
\usage{
get_cumu_coef(model, data = NULL, terms, ...)
\method{get_cumu_coef}{gam}(model, data, terms, ...)
\method{get_cumu_coef}{aalen}(model, data = NULL, terms, ci = TRUE, ...)
\method{get_cumu_coef}{cox.aalen}(model, data = NULL, terms, ci = TRUE, ...)
}
\arguments{
\item{model}{Object from which to extract cumulative coefficients.}
\item{data}{Additional data if necessary.}
\item{terms}{A character vector of variables for which the cumulative
coefficient should be calculated.}
\item{...}{Further arguments passed to methods.}
\item{ci}{Logical. Indicates if confidence intervals should be returned as
well.}
}
\description{
These functions are designed to extract (or mimic) the cumulative coefficients
usually used in additive hazards models (Aalen model) to depict (time-varying)
covariate effects. For PAMMs, these are the differences
between the cumulative hazard rates where all covariates except one have the
identical values. For a numeric covariate of interest, this calculates
\eqn{\Lambda(t|x+1) - \Lambda(t|x)}. For non-numeric covariates
the cumulative hazard of the reference level is subtracted from
the cumulative hazards evaluated at all non reference levels. Standard
errors are calculated using the delta method.
}
pammtools/man/seq_range.Rd 0000644 0001750 0001750 00000002654 14116612001 015424 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/helpers.R
\name{seq_range}
\alias{seq_range}
\title{Generate a sequence over the range of a vector}
\usage{
seq_range(x, n, by, trim = NULL, expand = NULL, pretty = FALSE)
}
\arguments{
\item{x}{A numeric vector}
\item{n, by}{Specify the output sequence either by supplying the
length of the sequence with \code{n}, or the spacing between value
with \code{by}. Specifying both is an error.
I recommend that you name these arguments in order to make it clear to
the reader.}
\item{trim}{Optionally, trim values off the tails.
\code{trim / 2 * length(x)} values are removed from each tail.}
\item{expand}{Optionally, expand the range by \code{expand * (1 + range(x)}
(computed after trimming).}
\item{pretty}{If \code{TRUE}, will generate a pretty sequence. If \code{n}
is supplied, this will use \code{\link{pretty}()} instead of
\code{\link{seq}()}. If \code{by} is supplied, it will round the first
value to a multiple of \code{by}.}
}
\description{
Stolen from
\href{https://github.com/tidyverse/modelr/blob/master/R/seq_range.R}{here}
}
\examples{
x <- rcauchy(100)
seq_range(x, n = 10)
seq_range(x, n = 10, trim = 0.1)
seq_range(x, by = 1, trim = 0.1)
# Make pretty sequences
y <- runif (100)
seq_range(y, n = 10)
seq_range(y, n = 10, pretty = TRUE)
seq_range(y, n = 10, expand = 0.5, pretty = TRUE)
seq_range(y, by = 0.1)
seq_range(y, by = 0.1, pretty = TRUE)
}
pammtools/man/get_intervals.Rd 0000644 0001750 0001750 00000002664 13662013606 016342 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/interval-information.R
\name{get_intervals}
\alias{get_intervals}
\alias{get_intervals.default}
\title{Information on intervals in which times fall}
\usage{
get_intervals(x, times, ...)
\method{get_intervals}{default}(x, times, left.open = TRUE, rightmost.closed = TRUE, ...)
}
\arguments{
\item{x}{An object from which interval information can be obtained,
see \code{\link{int_info}}.}
\item{times}{A vector of times for which corresponding interval information
should be returned.}
\item{...}{Further arguments passed to \code{\link[base]{findInterval}}.}
\item{left.open}{logical; if true all the intervals are open at left
and closed at right; in the formulas below, \eqn{\le} should be
swapped with \eqn{<} (and \eqn{>} with \eqn{\ge}), and
\code{rightmost.closed} means \sQuote{leftmost is closed}. This may
be useful, e.g., in survival analysis computations.}
\item{rightmost.closed}{logical; if true, the rightmost interval,
\code{vec[N-1] .. vec[N]} is treated as \emph{closed}, see below.}
}
\value{
A \code{data.frame} containing information on intervals in which
values of \code{times} fall.
}
\description{
Information on intervals in which times fall
}
\examples{
set.seed(111018)
brks <- c(0, 4.5, 5, 10, 30)
int_info(brks)
x <- runif (3, 0, 30)
x
get_intervals(brks, x)
}
\seealso{
\code{\link[base]{findInterval}} \code{\link{int_info}}
}
pammtools/man/dplyr_verbs.Rd 0000644 0001750 0001750 00000010732 14154722042 016020 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tidyverse-methods.R
\name{dplyr_verbs}
\alias{dplyr_verbs}
\alias{arrange}
\alias{filter}
\alias{distinct}
\alias{full_join}
\alias{group_by}
\alias{inner_join}
\alias{left_join}
\alias{mutate}
\alias{rename}
\alias{right_join}
\alias{sample_frac}
\alias{sample_n}
\alias{select}
\alias{slice}
\alias{summarise}
\alias{transmute}
\alias{ungroup}
\alias{arrange.ped}
\alias{group_by.ped}
\alias{ungroup.ped}
\alias{distinct.ped}
\alias{filter.ped}
\alias{sample_n.ped}
\alias{sample_frac.ped}
\alias{slice.ped}
\alias{select.ped}
\alias{mutate.ped}
\alias{rename.ped}
\alias{summarise.ped}
\alias{summarize.ped}
\alias{transmute.ped}
\alias{inner_join.ped}
\alias{full_join.ped}
\alias{left_join.ped}
\alias{right_join.ped}
\title{\code{dplyr} Verbs for \code{ped}-Objects}
\usage{
\method{arrange}{ped}(.data, ...)
\method{group_by}{ped}(.data, ..., .add = FALSE)
\method{ungroup}{ped}(x, ...)
\method{distinct}{ped}(.data, ..., .keep_all = FALSE)
\method{filter}{ped}(.data, ...)
\method{sample_n}{ped}(tbl, size, replace = FALSE, weight = NULL, .env = NULL, ...)
\method{sample_frac}{ped}(tbl, size = 1, replace = FALSE, weight = NULL, .env = NULL, ...)
\method{slice}{ped}(.data, ...)
\method{select}{ped}(.data, ...)
\method{mutate}{ped}(.data, ...)
\method{rename}{ped}(.data, ...)
\method{summarise}{ped}(.data, ...)
\method{summarize}{ped}(.data, ...)
\method{transmute}{ped}(.data, ...)
\method{inner_join}{ped}(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ...)
\method{full_join}{ped}(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ...)
\method{left_join}{ped}(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ...)
\method{right_join}{ped}(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ...)
}
\arguments{
\item{.data}{an object of class \code{ped}, see \code{\link{as_ped}}.}
\item{...}{see \code{dplyr} documentation}
\item{x}{an object of class \code{ped}, see \code{\link{as_ped}}.}
\item{tbl}{an object of class \code{ped}, see \code{\link{as_ped}}.}
\item{size}{<\code{\link[dplyr:dplyr_tidy_select]{tidy-select}}>
For \code{sample_n()}, the number of rows to select.
For \code{sample_frac()}, the fraction of rows to select.
If \code{tbl} is grouped, \code{size} applies to each group.}
\item{replace}{Sample with or without replacement?}
\item{weight}{<\code{\link[dplyr:dplyr_tidy_select]{tidy-select}}> Sampling weights.
This must evaluate to a vector of non-negative numbers the same length as
the input. Weights are automatically standardised to sum to 1.}
\item{.env}{DEPRECATED.}
\item{y}{A pair of data frames, data frame extensions (e.g. a tibble), or
lazy data frames (e.g. from dbplyr or dtplyr). See \emph{Methods}, below, for
more details.}
\item{by}{A character vector of variables to join by.
If \code{NULL}, the default, \verb{*_join()} will perform a natural join, using all
variables in common across \code{x} and \code{y}. A message lists the variables so that you
can check they're correct; suppress the message by supplying \code{by} explicitly.
To join by different variables on \code{x} and \code{y}, use a named vector.
For example, \code{by = c("a" = "b")} will match \code{x$a} to \code{y$b}.
To join by multiple variables, use a vector with length > 1.
For example, \code{by = c("a", "b")} will match \code{x$a} to \code{y$a} and \code{x$b} to
\code{y$b}. Use a named vector to match different variables in \code{x} and \code{y}.
For example, \code{by = c("a" = "b", "c" = "d")} will match \code{x$a} to \code{y$b} and
\code{x$c} to \code{y$d}.
To perform a cross-join, generating all combinations of \code{x} and \code{y},
use \code{by = character()}.}
\item{copy}{If \code{x} and \code{y} are not from the same data source,
and \code{copy} is \code{TRUE}, then \code{y} will be copied into the
same src as \code{x}. This allows you to join tables across srcs, but
it is a potentially expensive operation so you must opt into it.}
\item{suffix}{If there are non-joined duplicate variables in \code{x} and
\code{y}, these suffixes will be added to the output to disambiguate them.
Should be a character vector of length 2.}
\item{funs}{see \code{\link[dplyr]{summarize_all}}}
\item{.dots}{see \code{dplyr} documentation}
\item{keep_attributes}{conserve attributes? defaults to \code{TRUE}}
}
\value{
a modified \code{ped} object (except for \code{do})
}
\description{
See \code{dplyr} documentation of the respective functions for
description and examples.
}
\keyword{internal}
pammtools/man/predictSurvProb.pamm.Rd 0000644 0001750 0001750 00000001363 13720455275 017564 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/predict.R
\name{predictSurvProb.pamm}
\alias{predictSurvProb.pamm}
\title{S3 method for pamm objects for compatibility with package pec}
\usage{
\method{predictSurvProb}{pamm}(object, newdata, times)
}
\arguments{
\item{object}{A fitted model from which to extract predicted survival
probabilities}
\item{newdata}{A data frame containing predictor variable combinations for
which to compute predicted survival probabilities.}
\item{times}{A vector of times in the range of the response variable, e.g.
times when the response is a survival object, at which to return the
survival probabilities.}
}
\description{
S3 method for pamm objects for compatibility with package pec
}
pammtools/man/gg_fixed.Rd 0000644 0001750 0001750 00000001404 14116612001 015224 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/convenience-plots.R
\name{gg_fixed}
\alias{gg_fixed}
\title{Forrest plot of fixed coefficients}
\usage{
gg_fixed(x, intercept = FALSE, ...)
}
\arguments{
\item{x}{A model object.}
\item{intercept}{Logical, indicating whether intercept term should be included.
Defaults to \code{FALSE}.}
\item{...}{Currently not used.}
}
\description{
Given a model object, returns a data frame with columns \code{variable},
\code{coef} (coefficient), \code{ci_lower} (lower 95\\% CI) and
\code{ci_upper} (upper 95\\% CI).
}
\examples{
g <- mgcv::gam(Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width + Species,
data=iris)
gg_fixed(g, intercept=TRUE)
gg_fixed(g)
}
\seealso{
\code{\link{tidy_fixed}}
}
pammtools/man/get_terms.Rd 0000644 0001750 0001750 00000002076 13662013606 015462 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/get-terms.R
\name{get_terms}
\alias{get_terms}
\title{Extract the partial effects of non-linear model terms}
\usage{
get_terms(data, fit, terms, ...)
}
\arguments{
\item{data}{A data frame containing variables used to fit the model. Only
first row will be used.}
\item{fit}{A fitted object of class \code{\link[mgcv]{gam}}.}
\item{terms}{A character vector (can be length one). Specifies the terms
for which partial effects will be returned}
\item{...}{Further arguments passed to \code{\link{seq_range}}.}
}
\value{
A tibble with 5 columns.
}
\description{
This function basically creates a new \code{df} from \code{data} for
each term in \code{terms}, creating a range from minimum and maximum of the
\code{predict(fit, newdata=df, type="terms")}. Terms are then
stacked to a tidy data frame.
}
\examples{
library(survival)
fit <- coxph(Surv(time, status) ~ pspline(karno) + pspline(age), data=veteran)
terms_df <- veteran \%>\% get_terms(fit, terms = c("karno", "age"))
head(terms_df)
tail(terms_df)
}
pammtools/man/simdf_elra.Rd 0000644 0001750 0001750 00000001222 14154722042 015564 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.R
\docType{data}
\name{simdf_elra}
\alias{simdf_elra}
\title{Simulated data with cumulative effects}
\format{
An object of class \code{nested_fdf} (inherits from \code{sim_df}, \code{tbl_df}, \code{tbl}, \code{data.frame}) with 250 rows and 9 columns.
}
\usage{
simdf_elra
}
\description{
This is data simulated using the \code{\link[pammtools]{sim_pexp}} function.
It contains two time-constant and two time-dependent covariates (observed
on different exposure time grids). The code used for simulation is
contained in the examples of \code{?sim_pexp}.
}
\keyword{datasets}
pammtools/man/split_data.Rd 0000644 0001750 0001750 00000003342 14150243134 015604 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/split-data.R
\name{split_data}
\alias{split_data}
\title{Function to transform data without time-dependent covariates into piece-wise
exponential data format}
\usage{
split_data(formula, data, cut = NULL, max_time = NULL, ...)
}
\arguments{
\item{formula}{A two sided formula with a \code{\link[survival]{Surv}} object
on the left-hand-side and covariate specification on the right-hand-side (RHS).
The RHS can be an extended formula, which specifies how TDCs should be transformed
using specials \code{concurrent} and \code{cumulative}. The left hand-side can
be in start-stop-notation. This, however, is only used to create left-truncated
data and does not support the full functionality.}
\item{data}{Either an object inheriting from data frame or in case of
time-dependent covariates a list of data frames (of length 2), where the first data frame
contains the time-to-event information and static covariates while the second
(and potentially further data frames) contain information on time-dependent
covariates and the times at which they have been observed.}
\item{cut}{Split points, used to partition the follow up into intervals.
If unspecified, all unique event times will be used.}
\item{max_time}{If \code{cut} is unspecified, this will be the last
possible event time. All event times after \code{max_time}
will be administratively censored at \code{max_time}.}
\item{...}{Further arguments passed to the \code{data.frame} method and
eventually to \code{\link[survival]{survSplit}}}
}
\description{
Function to transform data without time-dependent covariates into piece-wise
exponential data format
}
\seealso{
\code{\link[survival]{survSplit}}
}
\keyword{internal}
pammtools/man/get_event_types.Rd 0000644 0001750 0001750 00000002576 14116612001 016667 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/as-ped.R
\name{get_event_types}
\alias{get_event_types}
\title{Exctract event types}
\usage{
get_event_types(data, formula, censor_code)
}
\arguments{
\item{data}{Either an object inheriting from data frame or in case of
time-dependent covariates a list of data frames (of length 2), where the first data frame
contains the time-to-event information and static covariates while the second
(and potentially further data frames) contain information on time-dependent
covariates and the times at which they have been observed.}
\item{formula}{A two sided formula with a \code{\link[survival]{Surv}} object
on the left-hand-side and covariate specification on the right-hand-side (RHS).
The RHS can be an extended formula, which specifies how TDCs should be transformed
using specials \code{concurrent} and \code{cumulative}. The left hand-side can
be in start-stop-notation. This, however, is only used to create left-truncated
data and does not support the full functionality.}
\item{censor_code}{Specifies the value of the status variable that indicates censoring.
Often this will be \code{0}, which is the default.}
}
\description{
Given a formula that specifies the status variable of the outcome, this function
extracts the different event types (except for censoring, specified by
\code{censor_code}).
}
\keyword{internal}
pammtools/man/specials.Rd 0000644 0001750 0001750 00000004755 14116612001 015267 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/formula-specials.R
\name{cumulative}
\alias{cumulative}
\alias{concurrent}
\alias{has_special}
\title{Formula specials for defining time-dependent covariates}
\usage{
cumulative(..., tz_var, ll_fun = function(t, tz) t >= tz, suffix = NULL)
concurrent(..., tz_var, lag = 0, suffix = NULL)
has_special(formula, special = "cumulative")
}
\arguments{
\item{...}{For \code{concurrent} variables that will be transformed to
covariate matrices. The number of columns of each covariate depends on \code{tz}.
Usually, elements that will be specified here are \code{time} (which should be
the name of the time-variable used on the LHS of the formula argument to
\code{as_ped}), \code{tz} which is the variable containing information on
the times at which the TDC was observed (can be wrapped in \code{latency}) and
the TDCs that share the same \code{tz} and Lag-lead window (\code{ll_fun}).}
\item{tz_var}{The name of the variable that stores information on the
times at which the TDCs specified in this term where observed.}
\item{ll_fun}{Function that specifies how the lag-lead matrix
should be constructed. First argument is the follow up time
second argument is the time of exposure.}
\item{lag}{a single positive number giving the time lag between for
a concurrent effect to occur (i.e., the TDC at time of exposure \code{t-lag}
affects the hazard in the interval containing follow-up time \code{t}).
Defaults to 0.}
\item{formula}{A two sided formula with a \code{\link[survival]{Surv}} object
on the left-hand-side and covariate specification on the right-hand-side (RHS).
The RHS can be an extended formula, which specifies how TDCs should be transformed
using specials \code{concurrent} and \code{cumulative}. The left hand-side can
be in start-stop-notation. This, however, is only used to create left-truncated
data and does not support the full functionality.}
\item{special}{The name of the special whose existence in the
\code{formula} should be checked}
}
\description{
So far, two specials are implemented. \code{concurrent} is used when
the goal is to estimate a concurrent effect of the TDC. \code{cumulative}
is used when the goal is to estimate a cumulative effect of the TDC. These
should usually not be called directly but rather as part of the \code{formula}
argument to \code{as_ped}.
See the \href{https://adibender.github.io/pammtools//articles/data-transformation.html}{vignette on data transformation}
for details.
}
\keyword{internal}
pammtools/man/tidy_smooth.Rd 0000644 0001750 0001750 00000001026 13662013606 016025 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tidiers.R
\name{tidy_re}
\alias{tidy_re}
\title{Extract random effects in tidy data format.}
\usage{
tidy_re(x, keep = c("fit", "main", "xlab", "ylab"), ...)
}
\arguments{
\item{x}{ a fitted \code{gam} object as produced by \code{gam()}.}
\item{keep}{A vector of variables to keep.}
\item{...}{Further arguments passed to \code{\link[mgcv]{plot.gam}}}
}
\description{
Extract random effects in tidy data format.
}
\seealso{
\code{\link[stats]{qqline}}
}
pammtools/man/add_tdc.Rd 0000644 0001750 0001750 00000002033 13662013606 015044 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sim-pexp.R
\name{add_tdc}
\alias{add_tdc}
\title{Add time-dependent covariate to a data set}
\usage{
add_tdc(data, tz, rng_fun, ...)
}
\arguments{
\item{data}{A data set with variables specified in \code{formula}.}
\item{tz}{A numeric vector of exposure times (relative to the
beginning of the follow-up time \code{t})}
\item{rng_fun}{A random number generating function that creates
the time-dependent covariates at time points \code{tz}.
First argument of the function should be \code{n}, the number of
random numbers to generate. Within \code{add_tdc}, \code{n} will be set
to \code{length(tz)}.}
\item{...}{Currently not used.}
}
\description{
Given a data set in standard format (with one row per subject/observation),
this function adds a column with the specified exposure time points
and a column with respective exposures, created from \code{rng_fun}.
This function should usually only be used to create data sets passed
to \code{\link[pammtools]{sim_pexp}}.
}
pammtools/man/nest_tdc.Rd 0000644 0001750 0001750 00000002176 13662013606 015275 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/nest-utils.R
\name{nest_tdc}
\alias{nest_tdc}
\alias{nest_tdc.default}
\alias{nest_tdc.list}
\title{Create nested data frame from data with time-dependent covariates}
\usage{
nest_tdc(data, formula, ...)
\method{nest_tdc}{default}(data, formula, ...)
\method{nest_tdc}{list}(data, formula, ...)
}
\arguments{
\item{data}{A suitable data structure (e.g. unnested data frame with
concurrent TDCs or a list where each element is a data frame, potentially
containing TDCs as specified in the RHS of \code{formula}).
Only TDCs present in \code{formula} will be returned.}
\item{formula}{A two sided formula with a two part RHS, where the second
part indicates the structure of the TDC structure.}
\item{...}{Further arguments passed to methods.}
\item{vars}{A character vector of TDCs that will be nested.}
\item{id}{A character giving the name of the ID column.}
}
\description{
Provides methods to nest data with time-dependent covariates (TDCs).
A \code{formula} must be provided where the right hand side (RHS) contains
the structure of the TDCs
}
\keyword{internal}
pammtools/man/get_cumulative.Rd 0000644 0001750 0001750 00000001577 13662013606 016513 0 ustar nilesh nilesh % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/formula-specials.R
\name{get_cumulative}
\alias{get_cumulative}
\alias{expand_cumulative}
\title{Expand time-dependent covariates to functionals}
\usage{
get_cumulative(data, formula)
expand_cumulative(data, func, n_func)
}
\arguments{
\item{data}{Data frame (or similar) in which variables specified in ...
will be looked for}
\item{formula}{A formula containing \code{cumulative} specials,
that specify the type of cumulative effect one wants to estimate. For details
see the vignettes on data transformation and time-dependent covariates.}
\item{func}{Single evaluated \code{\link{cumulative}} term.}
}
\description{
Given formula specification on how time-dependent covariates affect the
outcome, creates respective functional covariate as well as auxiliary
matrices for time/latency etc.
}
\keyword{internal}
pammtools/man/figures/ 0000755 0001750 0001750 00000000000 14116612001 014626 5 ustar nilesh nilesh pammtools/man/figures/logo.png 0000644 0001750 0001750 00000136552 14116612001 016310 0 ustar nilesh nilesh PNG
IHDR X .' pHYs .# .#x?v IDATxyxSU?o4mڦ+JK٩"*0"WaWečqAgՑ:(JJ)KZJtidd'<<MNMss~$It%ȳ
$Izu!"b0
`
$6+@DP(.+
C(y
QbQ9ثQ0WՅ{B sB+DDއ=D~NP4Ј(cR(!
~.
<">1 CN\2pF$I]BD>D~DP5ل^J
^_]=D1 q^vPn$)ӕ "ǀGDvXlFi]CC?7իW"`@D$K9sr/O> Z$I6y"/&2h4