GithubHelp home page GithubHelp logo

xuerui-yang / jmcm Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 1.0 169 KB

Joint mean-covariance models are widely used in longitudinal study. This Python package provides functions to estimate the parameters, do the hypothesis tests, and plot the curves.

License: MIT License

Python 100.00%

jmcm's Introduction

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

jmcm's People

Contributors

xuerui-yang avatar

Stargazers

 avatar  avatar  avatar Yi Pan avatar Erfanul Hoque avatar Nils avatar  avatar

Watchers

 avatar

Forkers

jithu2255

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.