GithubHelp home page GithubHelp logo

stephensrmmartin / lmmelsm Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 1.0 729 KB

R Package for fitting latent multivariate mixed effects location scale models.

License: Other

R 73.23% C++ 0.03% Stan 26.64% Shell 0.10%
mixed-effects multilevel-models bayesian stan statistics

lmmelsm's Introduction

LMMELSM

LMMELSM stands for latent, multidimensional mixed effects location scale models.

The mixed effects location scale model is a multilevel model in which both the location ($\mu$) and scale ($\sigma$) are modeled and have random effects. That is, in addition to random intercepts and coefficients, the MELSM allows variance to differ between groups, and across covariates. Within the MELSM framework, variances are meaningful, and can be directly modeled. MELSMs are useful for predicting volatility, variance, uncertainty, variation between group means, measurement error variance, and much more. As an added side effect, prediction intervals are tailored to each individual or group (differing predictive uncertainty), and fixed effects are more robust because those with less variance (more reliability) are implicitly weighted more.

LMMELSM extends the MELSM to include latent variables. Instead of predicting the expected values and variances of observed or computed variables, the LMMELSM predicts expected values and variances of multiple correlated latent factors. Assuming an adequate measurement model, the LMMELSM therefore models the variance of a reduced-error score.

LMMELSM is therefore useful for modeling conditional and group-specific latent means and variances. One such example is modeling the intraindividual variability of latent scores of a persons over time in an experience sampling methodology. Another example is modeling the heterogeneity of individuals' latent means from person-level covariates.

LMMELSM currently supports:

  • Observed outcomes
  • Latent outcomes
  • Single or multiple outcomes
  • Location modeling, with random intercepts and coefficients
  • Within-group scale modeling, with random intercepts and coefficients
  • Between-group scale modeling (on the between-group mean variances)

Installation

You can install the released version of LMMELSM from github with:

remotes::install_github("stephensrmmartin/LMMELSM")

Example

In this example, increasingly complex MELSMs are modeled, and demonstrate the simple formula syntax.

library(LMMELSM)

data(sim_data)

# Intercept-only model
fit <- lmmelsm(Agreeableness ~ A_1 + A_2 + A_3 + A_4 + A_5 + A_6, subject, sim_data)

# Random Time-varying predictor on location
fit <- lmmelsm(list(Agreeableness ~ A_1 + A_2 + A_3 + A_4 + A_5 + A_6,
                    location ~ x1 | x1),
               subject, sim_data)

# Random Time-varying predictors on both location and scale
fit <- lmmelsm(list(Agreeableness ~ A_1 + A_2 + A_3 + A_4 + A_5 + A_6,
                    location ~ x1 | x1,
                    scale ~ x2 | x2),
               subject, sim_data)

# Time-varying predictors, person-level predictors on location, scale, and between-group variance
# Multidimensional!
fit <- lmmelsm(list(Agreeableness ~ A_1 + A_2 + A_3 + A_4 + A_5 + A_6,
                    Neuroticism ~ N_1 + N_2 + N_3 + N_4 + N_5 + N_6,
                    location ~ x1 + baseline | x1,
                    scale ~ x2 + baseline | x2,
                    between ~ baseline),
               subject, sim_data)

# Time-varying predictors, person-level predictors on location, scale, and between-group variance
fit <- lmmelsm(list(Agreeableness ~ A_1 + A_2 + A_3 + A_4 + A_5 + A_6,
                    Neuroticism ~ N_1 + N_2 + N_3 + N_4 + N_5 + N_6,
                    location ~ x1 + baseline | x1,
                    scale ~ x1 + x2 + baseline | x1 + x2,
                    between ~ baseline),
               subject, sim_data)


# Non-latent Multivariate MELSM
fit <- lmmelsm(list(observed ~ A_1 + N_1,
                    location ~ x1 + baseline|x1,
                    scale ~ x2 + baseline|x2,
                    between ~ baseline),
               subject, sim_data)

# Summarize
summary(fit)

# Get subject-specific random effects
ranef(fit)

# Get subject-specific coefficients
coef(fit)

lmmelsm's People

Contributors

stephensrmmartin avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

andrjohns

lmmelsm's Issues

Random Scale Effect Variance Model Feature Request

Hello @stephensrmmartin ,

I'd like to request the option to estimate a homogeneous random scale effect variance while also modeling the random intercept effect variance as a function of covariates.

  • One option is to create a boolean so that the covariates specified in the "between ~" model only predict the random intercept effect variance.
  • Another (ultimately better) option is for the user interface to separate out the equation for the random scale effect variance and the random intercept effect variance. That is, there would be two separate "between ~" equations.

Thank you!
Madeline

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.