Giter Club home page Giter Club logo

lctmtools's Introduction

LCTMtools

Latent Class Trajectory Modelling Tools: an R Package

Maintainer: This R package is no longer maintained. Last Updated: August 2019

To install the R package, in the R console use the command

install.packages("devtools")
devtools::install_github("hlennon/LCTMtools")

All statistical (R and SAS) codes used to implement Latent Class Trajectory Modelling and the tools described in the manuscript "A framework to construct and interpret Latent Class Trajectory Modelling", are available here and can be downloaded from www.github.com/hlennon/LCTMtools.

An example (simulated) dataset 'bmi' and 'bmi_long' (long format version) is provided to describe the steps throughout.

Reference

Lennon H, Kelly S, Sperrin M, et al., Framework to construct and interpret Latent Class Trajectory Modelling, BMJ Open 2018;8:e020683.

Available at https://bmjopen.bmj.com/content/8/7/e020683

Supplementary material contains extra details: https://bmjopen.bmj.com/content/bmjopen/8/7/e020683/DC1/embed/inline-supplementary-material-1.pdf?download=true

Help Files

There are two help manuals available above:

Brief Example

library(LCTMtools)
data(bmi_long, package = "LCTMtools" )


# Use the hlme function from the 'lcmm' R package to fit a 2 class latent class trajectory model
set.seed(100)
library(lcmm)
model2classes <- lcmm::hlme(fixed = bmi ~ age + I(age^2), 
                      mixture= ~ age, 
                      random = ~ age, 
                      ng = 2, 
                      nwg = TRUE,  
                      subject = "id", 
                      data = data.frame(bmi_long[1:500, ]) )


# Compute model adequacy measures
LCTMtoolkit(model2classes)


# Compare with a 3 class model
set.seed(100)
model3classes <- lcmm::hlme(fixed = bmi ~ age + I(age^2), 
                      mixture= ~ age, 
                      random = ~ age, 
                      ng = 3, 
                      nwg = TRUE,  
                      subject = "id", 
                      data = data.frame(bmi_long[1:500, ]) )


LCTMtoolkit(model3classes)

LCTMcompare(model2classes, model3classes)

Citation

Please cite as

Hannah Lennon. {LCTMtools}: Latent Class Trajectory Models tools R Functions. R package version 0.1.2.

Lennon H, Kelly S, Sperrin M, et al Framework to construct and interpret Latent Class Trajectory Modelling BMJ Open 2018;8:e020683. doi: 10.1136/bmjopen-2017-020683

Thanks

A special thank you to Charlotte Watson for testing.

Contributing

Please note this R package is no longer maintained. The R package is open. Fork requests for contributions are encouraged.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

lctmtools's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

lctmtools's Issues

residualplot_step1

Dear Dr Hannah Lennon,

When I used the residualplot_step1 function, only a residual plot was presented. In general, the residual plot for the highest label component is shown.

cannot download the data

Hello Hannah
I hope download your data shown in the website, but it failed. May you upload the data you used in your paper again? Many thanks

Question about function 'residualplot_step1'

Dear Hannah,

I'm having a problem with the function 'residualplot_step1'. When I run the examples:

library(ggplot2)
data(bmi_long, package = "LCTMtools")
require(lcmm)
model2class <- lcmm::hlme(
fixed = bmi ~ age,
mixture = ~age,
random = ~ -1,
nwg = TRUE, ng = 2, subject = "id",
data = data.frame(bmi_long[1:500, ])
)
residualplot_step1(model2class,
nameofoutcome = "bmi",
nameofage = "age",
data = bmi_long,
)

It displays the following error:
<error/rlib_error_dots_nonempty>
Error in dplyr::left_join():
! ... must be empty.
✖ Problematic argument:
• .by = nameofid

Backtrace:

  1. └─LCTMtools::residualplot_step1(...)
  2. ├─dplyr::left_join(preds, model$pprob, .by = nameofid)
  3. └─dplyr:::left_join.data.frame(preds, model$pprob, .by = nameofid)
    Run rlang::last_trace(drop = FALSE) to see 5 hidden frames.

I have updated the 'dplyr' package and it still shows this error. My R version info is:
R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)

I wonder if you know what might be causing these errors?

Best wishes,
Coco

LCTMtools install

Dear Hannah,

I'm having some trouble installing LCTMtools to R. I've used the code:

library(devtools)
devtools::install_github("hlennon/LCTMtools")

And the installation asks me whether I want to update a load of packages. I updated all these manually in the end, but one that still comes up on the list is "backports" (even though I tried installing/updating this package manually). When I choose to update this one through the LCTMtools installation, I get to this error:

Error: Failed to install 'LCTMtools' from GitHub:
(converted from warning) cannot remove prior installation of package ‘backports’

If I choose to update no packages, I get to the error:

Error: Failed to install 'LCTMtools' from GitHub:
(converted from warning) installation of package ‘C:/Users/myusername/AppData/Local/Temp/RtmpmsTViI/file26a415ca7608/LCTMtools_0.1.3.tar.gz’ had non-zero exit
status

I wonder if you know what might be causing these errors?

Best wishes,
James

Error in residualplot_step1

Dear hlennon!
hello, when I use the function "residualplot_step1", and run follow codes:

set.seed(100)
library(lcmm)
model2classes <- lcmm::hlme(fixed = bmi ~ age + I(age^2),
mixture= ~ age,
random = ~ age,
ng = 2,
nwg = TRUE,
subject = "id",
data = data.frame(bmi_long[1:500, ]) )

residualplot_step1(model2classes,

  • nameofoutcome = "bmi",
  • nameofage = "age",
  • data = bmi_long,
  • )

The warning in screen is:
Joining, by = "id"
Joining, by = c("id", "bmi")
Error in aes(x = get(nameofage), y = Residuals, group = class) :
没有"aes"这个函数

and here is my R version information:
R.version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 4
minor 0.5
year 2021
month 03
day 31
svn rev 80133
language R
version.string R version 4.0.5 (2021-03-31)
nickname Shake and Throw

Thanks!

Install LCTM tool

Hello Hannah,

I'm having trouble to install LCTMtools to R. I used the direction and code in the LCTM vignette

install.packages (devtools)
library(devtools)
devtools::install_github("hlennon/LCTMtools")

Please advise. Thanks

Shaminie

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.