Package

Description of the regulation of cardiovascular physiology. The this to: 1) study electrocardiography (both intervals and morphology) as extensions of signal processing, 2) study circadian rhythms and how it effects autonomic physiology, 3) assess clinical risk of autonomic dysfunction on cardiovascular health through the perspective of epidemiology and causality.


Description
Simplify the process of building multiple models in a sequential order. This is particularly helpful in epidemiological cases of testing effect of additional parameters. Every parameter should be theoretically a part of the causal model for the exposure-outcome relationship.
Usage build_sequential_models(formula, data, exposure = NULL, engine = "lm") Arguments formula an object of class formula that shows the names of the outcomes (can be more than 1) and the names of the predictors (which should contain the exposure variable).
data data frame or data table (or tibble) that contains the named variables exposure Variable that is forced to be maintained in every model as a predictor.
engine Set the "engine" or the regression tool that will be used

Details
This is considering what is available with the modelr package and the tidymodels approach, and finding an in-between for the causality / epidemiology approach of building intentional, sequentional models. Expect changes in the process, and potential future dependencies on the tidymodels appraoches.
circ_center Value A tidy tibble of models. Each one will likely be grouped by its outcome, and then with sequential columns using increased/additive models. Each model, in a tidy format, will have two additional columns.
• outcomes identifies which outcome was used for the specific regression • covar number of covariates used in sequence of predictors given, with exposure always being placed in position 1 Examples data(geh) f <-svg_mag + qrs_tang~lab_hba1c + bmi build_sequential_models(f, data = geh) circ_center

Description
Based on a centering time point, shifts a vector to a "before" and "after" system to help align multiple individuals to a universal time, like the sunrise or any other appropriate zeitgeiber. Originally intended to expand upon the card::circ_sun function.

Arguments times
Vector of time series. The earliest time point is presumed to be the time series onset. Built with the assumption that the duration would be approximately 24 hours (or less) to remove issues with circadian rhythms and repeat zeitgeibers (e.g. sunrise). Most importantly, the time series should be roughly equally spaced, such as 1 hour apart.
zeitgeiber A single timestamp that should exist within the proposed times. It can be a POSIX* variable or it can just be a character of a time stamp in an HMS format. Its used to create a centering point.

Value
Vector of centered times around zeitgeiber. Function guesses units of time based on time series that is input (e.g. duration / number of events). It returns a vector of relative time in guessed units as double, which allows centering around the zeitgeiber (Z=0). y Grouping variable to apply to the cvar (x~y). Must be binary for t-test, otherwise will return data set without pvalues time Name of the time-dependent variable, usually hours

Details
Applies a simple data transformation to identify the summary statistics of the data frame by the stated variables. Results in a mean, standard deviation, and standard error term. This data is also used for making a t-test based table, which can then also be graphed in card::ggcircadian.

Value
Returns a dataframe that has the time variable, the categorical variable, and the statistics (including p-value) of the continuous variable Examples data("twins") circ_compare_groups(data = twins, x = "rDYX", y = "sad_cat", time = "hour") circ_odds circ_odds Odds Ratio Zenith is the sun's zenith. There are several types, with different values. "official" = 90.8333 degrees, "civil" = 96 degrees, "nautical" = 102 degrees, "astronomical" = 108 degrees. They refer to the angle at which light allows for visibility, which can be affected by atmosphere and refraction. sunset Logical value for if sunset is wanted instead of sunrise. Default is FALSE (thus returning sunrises).

Value
Returns vector of sunrise/sunset times based on the date and location given. The time zone offset is included for the time zone represented by the latitude/longitude. The vector always returns UTC, but it has actually been corrected to the appropriate time-zone. Can use as.character() to strip the time zone away. Arguments t Represents the ordered time indices that provide the positions for the cosine wave. Depending on the context: • A data frame of a time-based predictor/index. • A matrix of time-based predictor/index. • A recipe specifying a set of preprocessing steps created from recipes::recipe().
... Not currently used, but required for extensibility.
y When t is a data frame or matrix, y is the outcome specified as: • A data frame with 1 numeric column.
• A matrix with 1 numeric column.
• A numeric vector.
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).
• A vector with a single element = single-component cosinor, e.g. period = c(24) • A vector with multiple elements = multiple-component cosinor, e.g. period = c(24, 12) population Represents the population to be analyzed with a population-mean cosinor. Defaults to NULL, assuming individual cosinors are being generated. When a recipe or formula is used, population is specified as: • A character name of the column contained in data that contains identifiers for each subject. Every row will have a subject name which should be duplicated for each time index given.
When a data frame or matrix is used, population is specified as: • A vector of the same length as t, with values representing each subject at the correct indices.
formula A formula specifying the outcome terms on the left-hand side, and the predictor terms on the right-hand side.
data When a recipe or formula is used, data is specified as: • A data frame containing both the predictors and the outcome.

Value
A cosinor object.

Model of class cosinor level
Confidence level requested ...
Not currently used, but required for extensibility.

Value
Area of potential cosinor for graphical analysis as matrix stored in a list. 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.
• If TRUE, then will calculate features for entire population.
• If FALSE, then will calculate features for every individual cosinor in the population. ...

Details
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.

Value
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.

Description
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:

Details
Generate residuals versus fitted plot. Functions as an additional geom layer on ggplot. Models must be linear/gaussian in nature. Covariates can be included in the model.

Value
Returns a ggplot object of geom type, other layers can be added on as seen in example.

Description
Converts the output of card::circ_compare_groups into a complex geom that is broken down by time/hour and HRV (or any other continuous variable). Each hour is then separated by the grouping variable.

Arguments data
Table generated which has time variable, categorical outcome variable, and summary statistics, including a possible column called "pval" which, if present, will document statistical significance in plot.
outcome Name of categorical variable to stratify the y-axis time Name of time group variable, such as hours of day, which ends up being the x-axis mean, n, sd, se, pval Summary statistics to be included in graphics.

Details
Currently creates a ggplot that shows a error bar and point estimate of values by group (e.g. clinical status). If t-test values are available in the data frame, shows points of significance.

Value
Returns a ggplot object of geom type, other layers can be added on as seen in example.
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.

Value
Object of class ggplot that can be layered

Graphical Assessment of Amplitude and Acrophase
Description 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 card::cosinor. This includes the amplitude, acrophase, Model to be analyzed. The function will detect what type of family the model is (e.g. linear = "gaussian", logistic = "binomial") and plot the appropriate type of model.

Details
Generate residuals for models. Currently accepts only linear models. Does not account for covariates yet, although may be able to do this in the future.

Value
Returns a ggplot object of geom type, other layers can be added on as seen in example.

Description
Creates an OR plot for each hour of data given. Its a ggplot format so additional variables, like titles, can be added in.

Details
This function creates a forest plot using the OR developed by the card::circ_odds function in this package. By default, it takes the output, which is a tibble named "ot", and will generate a forest plot based on the grouping variable (default is time of day). Original data can be restricted or the hours can be reduced).

Value
A ggplot of forest plot that can be extended. Default theme is minimal and default color scheme is viridis.
Examples # Data data(twins) ot <-circ_odds(twins, "hour", "sad_bin", "rDYX") # Plot library(ggplot2) ggforest(ot) + labs(title = "Example") + scale_color_viridis_c(option = "A") heart-class heart class Description heart is an S4 class that serves as an object that holds together different components that represent the anatomical heart. A heart object allows for storing clinical information about a patient together, which may more readily allow for analytical approaches to be developed. The heart has plumbing (the coronary arteries), electricity (the nerves), and walls (cardiac chambers). The slots represent these objects.

Slots
pipes the epicardial and resistance vessels electric the conduction system of nerves structural the cardiac chambers and valves hrv Output from MATLAB HRV Toolbox

Description
Data is a single patient data output from HRV Toolbox. It contains granular data of calculated HRV in 5-second sliding windows.

Format
An tibble data frame hrv_linear_model

HRV Linear Modeling
Description hrv_linear_model Linear models for each HRV measure.
Usage hrv_linear_model(data, covar, hrv, prop.weight = FALSE) Arguments data Data frame that contains all covariates and outcomes. First column should be ID covar Vector names of the covariates, with first covariate being the primary exposure variable for linear regression hrv Vector names of the HRV measures, contained in data, that should be used. Can be generalized to any dependent variable set.

prop.weight
This is a logical value if propensity weighting should be done instead of traditional covariate adjustment. This calls for the propensity weighting function defined by card::recurrent_propensity that will generate both a PROP_SCORE column and PROP_WEIGHT column. Defaults to FALSE

Details
Linear models built with dependent variable being the HRV measures (e.g. HF, LF, SDNN, etc). Allows for covariates to be included as available.

Value
List of models with names mims

Description
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.

Format
An tibble data frame predict.cosinor Predict from a cosinor

new_data
A data frame or matrix of new predictors.
type A single character. The type of predictions to generate. Valid options are: • "numeric" for numeric predictions.
... Not used, but required for extensibility.

Value
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. proc_hrv_matlab

Description
Takes the output from HRV Toolbox and converts it for analysis. Uses the package data.table::fread() for reading in data due to size/speed.

Arguments loc
Location of the folder that contains all of the patients that were analyzed by the Main_HRV_Analysis.m function from the Toolbox.
name Name of the patient/ID. There should exist a folder with the name inside the loc folder. Inside this folder are all the Toolbox parameters and HRV results in CSV format.
time Number of seconds to group the HRV data by. Defaults to 3600 seconds (which is 1 hour)

Details
The data is taken sequentially (sliding windows), and summarized over the course of certain time lengths. The data comes in a standardized pattern from the toolbox. It requires processing due to its large file sizes (e.g. 24 hours of data for a single patient can be up to 2 MB in size).

Value
Data frame of HRV summarized by the grouping variable (e.g. 3600 seconds = 1 hour). Also returns an additional column of percent missing (e.g. 20.0% missing data) by time group. read_hrv_matlab

Description
Takes the output from HRV Toolbox and reads it in for an individual patient. Unlike card::proc_hrv_matlab, this does not process or summarize the data, it just reads it the raw analysis. Uses the package data.

Details
The data is taken sequentially (sliding windows), and is not processed. It is reported and is likely a large file.

Value
Data frame of HRV summarized by the grouping variable (e.g. 3600 seconds = 1 hour). Also returns an additional column of percent missing (e.g. 20.0% missing data) by time group. recurrent_model_building

Recurrent Event Sequential Model Building
Description Takes a different covariate groups to generate several models for recurrent event survival analyses.
Usage recurrent_model_building(data, covar.builds, model.type, prop.scores = NULL) Arguments data Data frame that is the survival format, potentially made by the card::recur_survival_table.
Has to be merged with the superset of covariates that are being tested.

covar.builds
This is a vector that names the individual vectors for each model, likely sequential and additive. The individual vectors contain the names of the columns in the data frame that will generate regressions.

model.type
Type of recurrent event data, selected from c("marginal", "pwptt", "pwpgt") prop.scores This is a vector of the names of which covar.builds should be performed with propensity weighting. This will call a separate function card::recurrent_propensity that will generate both a PROP_SCORE column and PROP_WEIGHT column. Optional parameter, defaults to NULL.

Details
Using the survival models in different types (e.g. marginal, PWP, etc), to create Cox regressions that are in a sequential order. Using the covariates given, will create the models on the fly. Need to specify model type and provide data in a certain format.

Value
List of models in sequential order.
recur_followup_table recurrent_propensity Propensity Score Weighting Description recurrent_propensity Adds propensity score to any data set that is being regressed upon.
Usage recurrent_propensity(data, vars) Arguments data Data frame that contains all covariates and outcomes. First column should be ID vars Variables used for regression. Outcome variable must be first.

Details
Using a logistic regression, will take covariates and create propensity scores, and adds the weights. Uses the standard logistic regression to evaluate the propensity score.

Value
Returns a modified table from what was originally given with the new columns propensity scores. Essentially original df + 2 columns.
recur_followup_table Initial and Final Visit Table   Description Makes a before/after dataset using a unique ID that follows patients between studies, to allow for comparison over time.
Usage recur_followup_table(data, studyid, keyid, date) Arguments data Data frame containing all clinical covariates of interest studyid Should be one ID for every study date/visit. Can have multiples ONLY if there were several data points gathered on a single visit (e.g. heart rate measured multiple times on the same day). keyid Should be the ID that corresponds to each studyid throughout each visit date Name of column containing the date of each visit

Details
Currently functions by taking two input IDs, one being a ID that is the same between studies (a true key ID) and an ID that is unique to that study itself. It will arrange by dates, and and slice data into an initial visit and the most recent visit. Each row should have a KEY ID and a STUDY ID. The data is in a long format, such that the STUDY IDs are unique / not duplicated.

Value
Returns list of initial and most recent data sets. These can easily be merged after with any naming nomenclature as chosen, or with any merging keys as chosen (in case there are several merging variables, like keyid + hour of day for circadian data).
recur_summary Arguments data Recurrent event data in marginal format. There must be an ID column. Must merge in the covariate of interest into this data set.

Recurrent Event Summary
covar Name of covariate of interest to serve as grouping variable.

Details
This function allows for taking the output of card::recur_survival_table marginal format repeat event data, and creates a summary table that describes the number of events by strata/event.

Value
Summary table by grouping variable, can be placed into a latex environment with kableExtra. Assumes that death events may be present when most recent non-EVENT has status 1.

Description
Reformats recurrent event data (wide) into different models for survival analysis, but can also be used for simple survival analysis tables as well. Importantly, for large datasets, this function will show significant slow-down since it uses an intuitive approach on defining the datasets. Future iterations will create a vectorized approach that should provide performance speed-ups.
• For recurrent events, the final censoring event can include death, or can be ignored if its not considered a failure event.
• For simple survival analysis, death censoring should be left as NULL, and the event (e.g. "date_of_death"), should be used as a single event.dates parameter. The function will do the rest.

Details
This function takes every data event date, and creates several types of recurrent event tables. It orders the data chronologically for repeat events. Currently does marginal and conditional A and B models. The large

Description
Tidy summarizes information about the components of a cosinor model.

Arguments
x A cosinor object created by card::cosinor() conf.int Logical indicating whether or not to include confidence interval in tidied output conf.level The confidence level to use if conf.int = TRUE. Must be between 0 and 1, with default to 0.95 (the 95% confidence interval). ...

For extensibility
Details 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. 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.

Format
An tibble data frame