Title: | Cardiovascular Applications in Research Data |
---|---|
Description: | A collection of cardiovascular research datasets and analytical tools, including methods for cardiovascular procedural data, such as electrocardiography, echocardiography, and catheterization data. Additional methods exist for analysis of procedural billing codes. |
Authors: | Anish S. Shah [aut, cre, cph] |
Maintainer: | Anish S. Shah <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1 |
Built: | 2024-11-07 13:40:12 UTC |
Source: | CRAN |
cosinor
objectAugment accepts a cosinor
model object and adds information about each observation in the dataset. This includes the predicted values in the .fitted
column and the residuals in the .resid
column. New columns always begin with a .
prefix to avoid overwriting columns in original dataset.
## S3 method for class 'cosinor' augment(x, ...)
## S3 method for class 'cosinor' augment(x, ...)
x |
A |
... |
For extensibility |
a tibble
object
Other cosinor:
cosinor()
,
ggcosinor()
cosinor
cosinor()
fits a regression model of a time variable to a
continuous outcome use trigonometric features. This approaches uses the
linearization of the parameters to assess their statistics and
distribution.
cosinor(t, ...) ## Default S3 method: cosinor(t, ...) ## S3 method for class 'data.frame' cosinor(t, y, tau, population = NULL, ...) ## S3 method for class 'matrix' cosinor(t, y, tau, population = NULL, ...) ## S3 method for class 'formula' cosinor(formula, data, tau, population = NULL, ...) ## S3 method for class 'recipe' cosinor(t, data, tau, population = NULL, ...)
cosinor(t, ...) ## Default S3 method: cosinor(t, ...) ## S3 method for class 'data.frame' cosinor(t, y, tau, population = NULL, ...) ## S3 method for class 'matrix' cosinor(t, y, tau, population = NULL, ...) ## S3 method for class 'formula' cosinor(formula, data, tau, population = NULL, ...) ## S3 method for class 'recipe' cosinor(t, data, tau, population = NULL, ...)
t |
Represents the ordered time indices that provide the positions for the cosine wave. Depending on the context:
|
... |
Not currently used, but required for extensibility. |
y |
When t is a
|
tau |
A vector that determines the periodicity of the time index. The number of elements in the vector determine the number of components (e.g. single versus multiple cosinor).
|
population |
Represents the population to be analyzed with a
population-mean cosinor. Defaults to NULL, assuming individual cosinors are
being generated. When a
When a
|
formula |
A formula specifying the outcome terms on the left-hand side, and the predictor terms on the right-hand side. |
data |
When a
|
A cosinor
object.
Other cosinor:
augment.cosinor()
,
ggcosinor()
# Data setup data("twins") # Formula interface model <- cosinor(rDYX ~ hour, twins, tau = 24)
# Data setup data("twins") # Formula interface model <- cosinor(rDYX ~ hour, twins, tau = 24)
Formulas for creating the area of the ellipse to identify confidence intervals, direction, and graphing purposes.
cosinor_area(object, level = 0.95, ...)
cosinor_area(object, level = 0.95, ...)
object |
Model of class |
level |
Confidence level requested |
... |
Not currently used, but required for extensibility. |
Area of potential cosinor for graphical analysis as matrix stored in a list.
Extract the special/global features of a multiple component
cosinor. In a multiple component model, there are specific parameters that
are not within the model itself, but must be extracted from the model fit.
When extracted, can be used to improve the plot of a multiple component
cosinor. However, this is only possible if the cosinor is harmonic (see
details
). For single-component models, the orthophase is the same as the
acrophase and the global amplitude
Global Amplitude (Ag) = the overall amplitude is defined as half the difference between the peak and trough values
Orthophase (Po) = the lag until the peak time
Bathyphase (Pb) = the lag until the trough time
cosinor_features(object, population = TRUE, ...)
cosinor_features(object, population = TRUE, ...)
object |
Model of class |
population |
If the object is a population cosinor, should the features be calculated for the individual cosinors or for the population-cosinors. Default is TRUE. This has no effect on "Individual" cosinor objects.
|
... |
For extensibility |
These calculations can only occur if the periods of the cosinor are harmonic - as in, the longest period is a integer multiple of the smallest period (known as the fundamental frequency). Otherwise, these statistics are not accurate or interpretable.
When returning the cosinor features for a single model, will return
an object of class list
. When returning the cosinor features for every
individual in a population cosinor, will return an object of class
tibble
.
data(twins) model <- cosinor(rDYX ~ hour, twins, c(24, 8), "patid") results <- cosinor_features(model, population = FALSE) head(results)
data(twins) model <- cosinor(rDYX ~ hour, twins, c(24, 8), "patid") results <- cosinor_features(model, population = FALSE) head(results)
Goodness of fit of a cosinor from data that has multiple collections at different timepoints or from multiple cycles. The RSS is partitioned into pure error (SSPE) and lack of fit (SSLOF). An F-test compares the SSPE and SSLOF to detect appropriateness of model.
The fitted values for each time point are:
cosinor_goodness_of_fit(object, level = 0.95, ...)
cosinor_goodness_of_fit(object, level = 0.95, ...)
object |
requires cosinor model generated with cosinor to calculate statistics. |
level |
confidence level desired |
... |
additional parameters may be needed for extensibility |
f-statistic as result of goodness of fit
cosinor_reg()
is a parsnip friendly method for specification of cosinor regression model before fitting.
cosinor_reg(mode = "regression", period = NULL) ## S3 method for class 'cosinor_reg' update(object, period = NULL, fresh = FALSE, ...) ## S3 method for class 'cosinor_reg' print(x, ...)
cosinor_reg(mode = "regression", period = NULL) ## S3 method for class 'cosinor_reg' update(object, period = NULL, fresh = FALSE, ...) ## S3 method for class 'cosinor_reg' print(x, ...)
mode |
A character string that describes the type of model. In this case, it only supports type of "regression". |
period |
A non-negative number or vector of numbers that represent the expected periodicity of the data to be analyzed. |
object |
Cosinor model specification |
fresh |
A logical for whether the arguments should be modified in place or replaced altogether |
... |
Extensible |
x |
Cosinor model specification |
library(parsnip) cosinor_reg(period = c(24, 8)) |> parsnip::set_engine("card") |> parsnip::set_mode("regression")
library(parsnip) cosinor_reg(period = c(24, 8)) |> parsnip::set_engine("card") |> parsnip::set_mode("regression")
Zero amplitude test assesses how well the circadian pattern fits the data, essentially detecting the present of a rhythm to the data.
cosinor_zero_amplitude(object, level = 0.95)
cosinor_zero_amplitude(object, level = 0.95)
object |
model of class |
level |
confidence level |
Returns a list of test statistics, as well prints out a report of analysis.
Used in the model-building examples for repeat testing.
geh
geh
A tibble
ggplot of cosinor model that can visualize a variety of cosinor model subtypes, including single-component, multiple-component, individual, and population cosinor models, built using cosinor. For single component cosinor, the following values are plotted:
M = midline estimating statistic of rhythm
A = amplitude
P = phi or acrophase (shift from 0 to peak)
If using a multiple-component cosinor, the terms are different. If the periods or frequencies resonate or are harmonic, then the following are calculated. If the periods are not harmonic, the values are just descriptors of the curve.
M = midline estimating statistic of rhythm
Ag = global amplitude, which is the distance between peak and trough (this is the same value as the amplitude from single component)
Po = orthophase (the equivalent of the acrophase in a single component), the lag time to peak value
Pb = bathyphase, the lag time to trough value
ggcosinor(object, labels = TRUE, ...)
ggcosinor(object, labels = TRUE, ...)
object |
Model of class |
labels |
Logical value if annotations should be placed on plot, default
= TRUE. The labels depend on the type of plot. The labels are attempted to
be placed "smartly" using the |
... |
For extensibility. This function will use different implementations based on the type of model (single or multiple component). Attributes of the object will be passed down, or calculated on the fly. |
Object of class ggplot
that can be layered
Other cosinor:
augment.cosinor()
,
cosinor()
data(triplets) m1 <- cosinor(rDYX ~ hour, twins, tau = 24) m2 <- cosinor(rDYX ~ hour, twins, tau = c(24, 12)) ggcosinor(m1, labels = FALSE) ggcosinor(m2) ggcosinor(list(single = m1, multiple = m2))
data(triplets) m1 <- cosinor(rDYX ~ hour, twins, tau = 24) m2 <- cosinor(rDYX ~ hour, twins, tau = c(24, 12)) ggcosinor(m1, labels = FALSE) ggcosinor(m2) ggcosinor(list(single = m1, multiple = m2))
This is a ggplot-styled graphical representation of the ellipse region generated by the cosinor analysis. It requires the same data used by cosinor model to be fit with the model cosinor. This includes the amplitude, acrophase,
ggellipse(object, level = 0.95, ...)
ggellipse(object, level = 0.95, ...)
object |
Requires a cosinor model to extract the correct statistics to generate the plot. |
level |
Confidence level for ellipse |
... |
Additional parameters may be needed for extensibility |
Object of class ggplot
to help identify confidence intervals
data("twins") m <- cosinor(rDYX ~ hour, twins, tau = 24) ggellipse(m)
data("twins") m <- cosinor(rDYX ~ hour, twins, tau = 24) ggellipse(m)
Data is a single patient data output from HRV Toolbox. It contains granular data of calculated HRV in 5-second sliding windows.
hrv
hrv
An tibble data frame
cosinor
Predict from a cosinor
## S3 method for class 'cosinor' predict(object, new_data, type = "numeric", ...)
## S3 method for class 'cosinor' predict(object, new_data, type = "numeric", ...)
object |
A |
new_data |
A data frame or matrix of new predictors. |
type |
A single character. The type of predictions to generate. Valid options are:
|
... |
Additional arguments passed to the prediction function |
A tibble of predictions. The number of rows in the tibble is
guaranteed to be the same as the number of rows in new_data
.
This is a generative function used to call CMS procedure codes. It is used to create a dataset that can be generally used to map procedure codes to their descriptions, allowing for understanding of interventions performed. The currently supported codes are explained in the details.
The following procedure codes are currently supported:
ICD9 procedure codes, most recently updated on 2014-10-01
ICD10 procedure codes, most recently updated on 2023-01-11
HCPCS prcoedure codes, most recently updated on 2023-11-29
CPT procedure codes, most recently updated on 2023-11-29
procedure_codes(format, version)
procedure_codes(format, version)
format |
The format of the procedure codes, written as a |
version |
The version of the procedure codes, which are generally
written as a year. Currently supported: |
CMS will usually release updated version of these codes on an annual basis. Each dataset that is supported below can be identified by the year it was published (not the go-live date, but the publically-available date). The previous versions that are included in the package are as below.
ICD9: 2014
ICD10: 2023
HCPCS: 2023
CPT: 2023
A tbl_df
with two columns: code
and description
. The code
refers to the procedure code, while the description
refers to the
description of the procedure.
# Procedure codes from the 2014 version of ICD-9 icd9 <- procedure_codes(format = "icd9", version = 2014)
# Procedure codes from the 2014 version of ICD-9 icd9 <- procedure_codes(format = "icd9", version = 2014)
Data is from a outcomes study on cardiovascular outcomes. It contains the first visit date, the last known date, and times of various events that have happened. They document death at right censoring as well. These events are non-ordered.
stress
stress
An tibble data frame
Tidy summarizes information about the components of a cosinor
model.
## S3 method for class 'cosinor' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
## S3 method for class 'cosinor' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
A |
conf.int |
Logical indicating whether or not to include confidence interval in tidied output |
conf.level |
The confidence level to use if between 0 and 1, with default to 0.95 (the 95% confidence interval). |
... |
For extensibility |
cosinor
objects do not necessarily have a T-statistic as the
standard error is not based on a mean value, but form a joint-confidence
interval. The standard error is generated using Taylor series expansion as
the object is a subspecies of harmonic regressions.
a tibble
object
Clinical data is also available for visualization and comparison. Other HRV measures are used here for comparison and testing out functions.
triplets
triplets
A tbl_df
Data is from an algorithm that generates a summary HRV measure using the Poincare phase-space plot, generated from kurtoses of the x and y axis. Clinical data is also available for visualization and comparison. There are repeat rows for each hour that Dyx was taken.
twins
twins
An tibble data frame
This is a dataset from the archived/orphaned zipcode
package.
zipcode
zipcode
A data frame with character vector zipcodes and latitude/longitude