Giter Club home page Giter Club logo

tmsalab / iccbeta Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 111 KB

A function and vignettes for computing an intraclass correlation described in Aguinis & Culpepper (2015) <doi:10.1177/1094428114563618>. This package quantifies the share of variance in a dependent variable that is attributed to group heterogeneity in slopes.

Home Page: https://tmsalab.github.io/iccbeta

R 81.01% C++ 18.99%
r rcpparmadillo armadillo correlation rcpp intraclass-correlation

iccbeta's Introduction

iccbeta: Intraclass Correlation

Build Status Package-License CRAN Version Badge CRAN Status RStudio CRAN Mirror’s Monthly Downloads RStudio CRAN Mirror’s Total Downloads Coverage status

A function and vignettes for computing an intraclass correlation described in Aguinis & Culpepper (in press). iccbeta quantifies the share of variance in a dependent variable that is attributed to group heterogeneity in slopes.

Installation

You can install iccbeta from CRAN using:

install.packages("iccbeta")

Or, you can be on the cutting-edge development version on GitHub using:

if(!requireNamespace("devtools")) install.packages("devtools")
devtools::install_github("tmsalab/iccbeta")

Usage

To use the iccbeta package, load it into R using:

library("iccbeta")

From there, calling the icc_beta() function with either a lmer() model object or the desired individual components will compute the intraclass correlation:

# Automatically calculate icc from model
results_model = icc_beta(<lmer-model>)

# Calculate icc from individual terms.
results_component = icc_beta(X, l2id, T, vy)

Authors

Steven Andrew Culpepper and Herman Aguinis

Citing the iccbeta package

To ensure future development of the package, please cite iccbeta package if used during an analysis or simulation studies. Citation information for the package may be acquired by using in R:

citation("iccbeta")

License

GPL (>= 2)

iccbeta's People

Contributors

coatless avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

iccbeta's Issues

lmer wrapper buglet

In #6, there was a wrapper added to perform the extraction. However, we extracted a bit too many terms. In particular, we only want to extract elements corresponding to the random-effects, not all effects (p). c.f.

T1 <- VarCorr(x)[[group_term]][1:p,1:p]

Consider revising given:

iccbeta/R/iccbeta.R

Lines 145 to 152 in f649ced

# Figure out the class term:
term_labels <- attr(mf, "names")
# Retrieve the _LAST_ variable (assume it is a group variable.)
# To Do: What is the best way to make this approach robust ?
group_term <- term_labels[length(term_labels)]
T1 <- VarCorr(x)[[group_term]][1:p,1:p]

Issue arose with:

m <- lmer(DV ~ P + P:H + (1+P||id), data = data)

No data was given, so an equivalent test case should be:

fm1 <- lmer(Reaction ~ Days + (1+Days || Subject), data = sleepstudy)

icc_beta throws error: "Mat::row(): index out of bounds"

The icc_beta threw the following error:

error: Mat::row(): index out of bounds
Error in icc_beta(X, df_icc[, "L2id"], T1, vy) : 
  Mat::row(): index out of bounds

I just tried to calculate the icc_beta for a dataset with the following structure:
I have a dataset where L1 = time point, L2 = person. Each L2 unit has several L1 units.

However,

  • the L1 are not equal between L2 (different group sizes).
  • and sometimes persons skipped time points, resulting in cases where L1 may be NA for, say, L1id 1, 2, 3, but have a value for L1id 4,5,6. In such cases, the L1id rows 1,2,3 are retained, even if NA for the Y variable.

My hunch is that this data structure leads to the aforementioned error. Specifically, df_icc[, "L2id"] is 444, whereas nrow(X) is 297.

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.