Skip to main content

jmcm

Build Status

Description

jmcm is an open-source Python package for fitting the joint mean-covariance models for longitudinal data.

It provides:

  • function to estimate parameters for the mean, innovation variance, and generalised auto-regressive coefficient
  • function to do the Wald hypothesis tests to check the significance of the parameters
  • model selection procedures
  • bootstrap method to plot the curves for the mean, innovation variance, and generalised auto-regressive coefficient

Source code

https://github.com/Xuerui-Yang/jmcm

Installation

pip install jmcm

Usage

The following command computes the estimates of parameters for a joint mean-covariance model.

from jmcm import JointModel
JM=JointModel(df, formula, poly_orders = (), optim_meth = 'default', model_select = False)

Arguments

  • df: The dataset of interest. It should be a 'pandas' DataFrame
  • formula: A formula showing the response, subject id, design matrices. It is a string following the rules defined in R, for example, 'y|id|t~x1+x2|x1+x3'.
    • On the left hand side of '~', there are 3 headers of the data, partitioned by '|':

      - y: The response vector for all the subjects
      - id: The ID number which identifying different subjects
      - t: The vector of time, which constructs the polynomials for modelling the means, innovation variances, and generalised auto regressive parameters.
      
    • On the right hand side of '~', there are two parts partitioned by '|':

      - x1+x2: '+' joints two headers, which are the covariates for the mean. There can be more headers and operators. Package 'patsy' is used to achieve that.
      - x1+x3: Similar to the left part, except that they are for the innovation variances.
      
  • poly_orders: A tuple of length 3. If the format is correct, it specifies the polynomial orders of time for the mean, innovation variance, and generalised auto regressive parameters. Otherwise the model selection procedures would be used.
  • optim_meth: The optimisation algorithm used. There are 2 options:
    1. 'default': use profile likelihood estimation to update the 3 types of parameters.
    2. 'BFGS': use BFGS method to update all 3 parameters together. If not specified, 'default' would be used
  • model_select: True or False. To do model selection or not. If it is True, there are two situations according to poly_orders:
    1. poly_orderes is assigned with a tuple of length 3. Then a traverse under the given triple would be done to find the the triple with the smallest BIC values. And the model would be fitted based on the selected poly_orders
    2. poly_orders is not assigned or assigned in a incorrect format. Then the a profile based search would be done. And the model would be fitted based on the selected poly_orders.

The following commands print the values of MLEs, BICs, test statistics, p-values, and figures of curves.

JM.summary()
JM.wald_test()
JM.boot_curve(num_boot)

Arguments

  • num_boot: The number of bootstrap samples. Note that a large number may cost much time to run

Metadata

Release files for jmcm 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jmcm 0.1.5
File Size Uploaded
jmcm-0.1.5.tar.gz 11.5 kB Details

Release files / jmcm-0.1.5.tar.gz

Download URL jmcm-0.1.5.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
535e2e3476cf982394b17fa2490c8104a992e550ff7636e3aeed15ae048df976
BLAKE2b-256 checksum
How to use checksums
90679d69582775bac22c8860d55677900c18d782c17ec2b2530e9b3218a96ab4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Release history Release notifications | RSS feed

This release

0.1.5 This release

1 release file

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page