Learn R Programming

lgpr

R-package for interpretable nonparametric modeling of longitudinal data using additive Gaussian processes. Contains functionality for inferring covariate effects and assessing covariate relevances. Various models can be specified using a convenient formula syntax.

Getting started

See overview, tutorials, vignettes and documentation at https://jtimonen.github.io/lgpr-usage/index.html.

Requirements

  • The package should work on all major operating systems.
  • R 3.4 or later is required, R 4.0.2 or later is recommended

Installing from CRAN

  • The latest released version that is available from CRAN can be installed simply via
install.packages("lgpr")

Installing from CRAN is probably the easiest option since they might have binaries for your system (so no need to build the package from source yourself).

Installing from source

  • The latest released version (which might not be in CRAN yet) can be installed via
install.packages('devtools') # if you don't have devtools already
devtools::install_github('jtimonen/lgpr', build_vignettes = TRUE)
  • The latest development version can be installed via
devtools::install_github('jtimonen/lgpr', ref = "develop")

Github installations are source installations (they require a C++ compiler).

  • If you have trouble installing the dependency rstan, see these instructions
  • Installing from source requires that you have your toolchain setup properly.

See the instructions for:

Real data and reproducing the experiments

For code to reproduce the experiments of our manuscript see https://github.com/jtimonen/lgpr-usage. Preprocessed longitudinal proteomics data is also provided there. See also the built-in read_proteomics_data() function.

Copy Link

Version

Install

install.packages('lgpr')

Monthly Downloads

193

Version

1.2.4

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Juho Timonen

Last Published

September 24th, 2023

Functions in lgpr (1.2.4)

create_model.likelihood

Parse the response variable and its likelihood model
create_model.options

Parse the given modeling options
plot_data

Vizualizing longitudinal data
lgpscaling-class

An S4 class to represent variable scaling
operations

Operations on formula terms and expressions
lgpfit-class

An S4 class to represent the output of the lgp function
ppc

Graphical posterior predictive checks
lgpexpr-class

An S4 class to represent an lgp expression
lgp

Main function of the 'lgpr' package
lgprhs-class

An S4 class to represent the right-hand side of an lgp formula
lgpformula-class

An S4 class to represent an lgp formula
plot_api_c

Plot a generated/fit model component
plot_draws

Visualize the distribution of parameter draws
pred

Posterior predictions and function posteriors
lgpmodel-class

An S4 class to represent an additive GP model
lgpr-package

The 'lgpr' package.
plot_invgamma

Plot the inverse gamma-distribution pdf
plot_inputwarp

Visualize input warping function with several steepness parameter values
create_model.formula

Create a model formula
plot_sim

Visualize an lgpsim object (simulated data)
model_summary

Print a model summary.
get_pred

Extract model predictions and function posteriors
new_x

Create test input points for prediction
sample_model

Fitting a model
select

Select relevant components
plot_pred

Visualizing model predictions or inferred covariate effects
priors

Prior definitions
plot_components

Visualize all model components
show

Printing formula object info using the show generic
plot_api_g

Plot longitudinal data and/or model fit so that each subject/group has their own panel
kernel

Compute a kernel matrix (covariance matrix)
testdata_001

A very small artificial test data, used mostly for unit tests
read_proteomics_data

Function for reading the built-in proteomics data
split

Split data into training and test sets
sim.create_y

Simulate noisy observations
var_mask

Variance masking function
lgpsim-class

An S4 class to represent a data set simulated using the additive GP formalism
sim.create_x

Create an input data frame X for simulated data
warp_input

Input warping function
sim.create_f

Simulate latent function components for longitudinal data analysis
lgpterm-class

An S4 class to represent one formula term
prior_pred

Prior (predictive) sampling
sim.kernels

Compute all kernel matrices when simulating data
simulate_data

Generate an artificial longitudinal data set
relevances

Assess component relevances
prior_to_num

Convert given prior to numeric format
s4_generics

S4 generics for lgpfit, lgpmodel, and other objects
testdata_002

Medium-size artificial test data, used mostly for tutorials
validate

Validate S4 class objects
adjusted_c_hat

Set the GP mean vector, taking TMM or other normalization into account
add_factor_crossing

Add a crossing of two factors to a data frame
add_factor

Easily add a categorical covariate to a data frame
Prediction-class

An S4 class to represent prior or posterior draws from an additive function distribution.
create_model

Create a model
KernelComputer-class

An S4 class to represent input for kernel matrix computations
GaussianPrediction-class

An S4 class to represent analytically computed predictive distributions (conditional on hyperparameters) of an additive GP model
as_character

Character representations of different formula objects
apply_scaling

Apply variable scaling
add_dis_age

Easily add the disease-related age variable to a data frame
create_model.prior

Parse given prior
create_model.covs_and_comps

Parse the covariates and model components from given data and formula
draw_pred

Draw pseudo-observations from posterior or prior predictive distribution
example_fit

Quick way to create an example lgpfit, useful for debugging
create_scaling

Create a standardizing transform
create_plot_df

Helper function for plots
dinvgamma_stanlike

Density and quantile functions of the inverse gamma distribution
get_draws

Extract parameter draws from lgpfit or stanfit
fit_summary

Print a fit summary.