Package iccbeta. January 28, 2019

Similar documents
Package strat. November 23, 2016

Package ECctmc. May 1, 2018

Package RLRsim. November 4, 2016

Package validara. October 19, 2017

Package fastdummies. January 8, 2018

Package messaging. May 27, 2018

Package geojsonsf. R topics documented: January 11, Type Package Title GeoJSON to Simple Feature Converter Version 1.3.

Package cattonum. R topics documented: May 2, Type Package Version Title Encode Categorical Features

Package bigreadr. R topics documented: August 13, Version Date Title Read Large Text Files

Package geogrid. August 19, 2018

Package farver. November 20, 2018

Package embed. November 19, 2018

Package glcm. August 29, 2016

Package pwrab. R topics documented: June 6, Type Package Title Power Analysis for AB Testing Version 0.1.0

Package semver. January 6, 2017

Package datasets.load

Package canvasxpress

Package simr. April 30, 2018

Package jdx. R topics documented: January 9, Type Package Title 'Java' Data Exchange for 'R' and 'rjava'

Package lucid. August 24, 2018

Package spark. July 21, 2017

Package tidyselect. October 11, 2018

Package fastrtext. December 10, 2017

Package rtext. January 23, 2019

Package nmslibr. April 14, 2018

Package coga. May 8, 2018

Package pkgbuild. October 16, 2018

Package PUlasso. April 7, 2018

Package ramcmc. May 29, 2018

Package hyphenatr. August 29, 2016

Package TVsMiss. April 5, 2018

Package projector. February 27, 2018

Package knitrprogressbar

Package wrswor. R topics documented: February 2, Type Package

Package lcc. November 16, 2018

Package readxl. April 18, 2017

Package ibm. August 29, 2016

Package repec. August 31, 2018

Package ompr. November 18, 2017

Package qualmap. R topics documented: September 12, Type Package

Package fst. December 18, 2017

Package elmnnrcpp. July 21, 2018

Package CompGLM. April 29, 2018

Package dbx. July 5, 2018

Package githubinstall

Package crochet. January 8, 2018

Package SimilaR. June 21, 2018

Package eply. April 6, 2018

Package nngeo. September 29, 2018

Package memoise. April 21, 2017

Package docxtools. July 6, 2018

Package mdftracks. February 6, 2017

Package gtrendsr. October 19, 2017

Package kdtools. April 26, 2018

Package pcr. November 20, 2017

Package bisect. April 16, 2018

Package raker. October 10, 2017

Package rprojroot. January 3, Title Finding Files in Project Subdirectories Version 1.3-2

Package clipr. June 23, 2018

Package BiocManager. November 13, 2018

Package Rtsne. April 14, 2017

Package caic4. May 22, 2018

Package readobj. November 2, 2017

Package tidyimpute. March 5, 2018

Package kirby21.base

Package aws.transcribe

Package calpassapi. August 25, 2018

Package swatches. December 21, 2017

Package robotstxt. November 12, 2017

Package available. November 17, 2017

Package rzeit2. January 7, 2019

Package testit. R topics documented: June 14, 2018

Package pkgload. July 8, 2018

Package AhoCorasickTrie

Package ecoseries. R topics documented: September 27, 2017

Package triebeard. August 29, 2016

Package mixsqp. November 14, 2018

Package modules. July 22, 2017

Package ConvergenceClubs

Package vinereg. August 10, 2018

Package diagis. January 25, 2018

Package birtr. October 4, 2017

Package tibble. August 22, 2017

Package samplesizecmh

Package humanize. R topics documented: April 4, Version Title Create Values for Human Consumption

Package fst. June 7, 2018

Package ClusterBootstrap

Package barcoder. October 26, 2018

Package MultiRR. October 21, 2015

Package librarian. R topics documented:

Package sure. September 19, 2017

Package bikedata. April 27, 2018

Package utilsipea. November 13, 2017

Package spelling. December 18, 2017

Package gppm. July 5, 2018

Package SIMLR. December 1, 2017

Package robustreg. R topics documented: April 27, Version Date Title Robust Regression Functions

Package citools. October 20, 2018

Package rdryad. June 18, 2018

Package vip. June 15, 2018

Transcription:

Type Package Package iccbeta January 28, 2019 Title Multilevel Model Intraclass Correlation for Slope Heterogeneity Version 1.2.0 Description 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. Depends R (>= 3.4.0) Imports Rcpp, lme4, stats, methods LinkingTo Rcpp (>= 1.0.0), RcppArmadillo (>= 0.9.200) Suggests RLRsim, testthat, covr License GPL (>= 2) URL https://github.com/tmsalab/iccbeta BugReports https://github.com/tmsalab/iccbeta/issues RoxygenNote 6.1.1 Encoding UTF-8 NeedsCompilation yes Author Steven Andrew Culpepper [aut, cph, cre] (<https://orcid.org/0000-0003-4226-6176>), Herman Aguinis [aut, cph] (<https://orcid.org/0000-0002-3485-9484>) Maintainer Steven Andrew Culpepper <sculpepp@illinois.edu> Repository CRAN Date/Publication 2019-01-28 21:50:02 UTC R topics documented: iccbeta-package....................................... 2 Hofmann.......................................... 3 icc_beta........................................... 5 simiccdata......................................... 8 1

2 iccbeta-package Index 10 iccbeta-package iccbeta: Multilevel Model Intraclass Correlation for Slope Heterogeneity Description 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. Author(s) Maintainer: Steven Andrew Culpepper <sculpepp@illinois.edu> (0000-0003-4226-6176) [copyright holder] Authors: References Herman Aguinis <haguinis@gwu.edu> (0000-0002-3485-9484) [copyright holder] Aguinis, H., & Culpepper, S.A. (2015). An expanded decision making procedure for examining cross-level interaction effects with multilevel modeling. Organizational Research Methods. Available at: http://www.hermanaguinis.com/pubs.html See Also Useful links: Examples https://github.com/tmsalab/iccbeta Report bugs at https://github.com/tmsalab/iccbeta/issues ## Not run: if(requirenamespace("lme4") && requirenamespace("rlrsim")){ # Simulated Data Example data(simiccdata) library('lme4') # computing icca vy <- var(simiccdata$y) lmm0 <- lmer(y ~ (1 l2id), data = simiccdata, REML = FALSE) VarCorr(lmm0)$l2id[1,1]/vy # Create simiccdata2 grp_means = aggregate(simiccdata[c('x1','x2')], simiccdata['l2id'],mean) colnames(grp_means)[2:3] = c('m_x1','m_x2')

Hofmann 3 simiccdata2 = merge(simiccdata,grp_means,by='l2id') # Estimating random slopes model lmm1 <- lmer(y ~ I(X1-m_X1) + I(X2-m_X2) + (I(X1-m_X1) + I(X2-m_X2) l2id), data = simiccdata2, REML = FALSE) X <- model.matrix(lmm1) p <- ncol(x) T1 <- VarCorr(lmm1)$l2id[1:p, 1:p] # computing iccb # Notice '+1' because icc_beta assumes l2ids are from 1 to 30. icc_beta(x, simiccdata2$l2id + 1, T1, vy)$rho_beta # Hofmann 2000 Example data(hofmann) library('lme4') # Random-Intercepts Model lmmhofmann0 <- lmer(helping ~ (1 id), data = Hofmann) vy_hofmann <- var(hofmann[,'helping']) # computing icca VarCorr(lmmHofmann0)$id[1,1]/vy_Hofmann # Estimating Group-Mean Centered Random Slopes Model, no level 2 variables lmmhofmann1 <- lmer(helping ~ mood_grp_cent + (mood_grp_cent id), X_Hofmann <- model.matrix(lmmhofmann1) P <- ncol(x_hofmann) T1_Hofmann <- VarCorr(lmmHofmann1)$id[1:P, 1:P] # computing iccb icc_beta(x_hofmann, Hofmann[,'id'], T1_Hofmann, vy_hofmann)$rho_beta # Performing LR test library('rlrsim') lmmhofmann1a <- lmer(helping ~ mood_grp_cent + (1 id), obs.lrt <- 2*(logLik(lmmHofmann1) - loglik(lmmhofmann1a))[1] X <- getme(lmmhofmann1,"x") Z <- t(as.matrix(getme(lmmhofmann1,"zt"))) sim.lrt <- LRTSim(X, Z, 0, diag(ncol(z))) (pval <- mean(sim.lrt > obs.lrt)) } else { stop("please install packages RLRsim and lme4 to run the above example.") } ## End(Not run) Hofmann A multilevel dataset from Hofmann, Griffin, and Gavin (2000).

4 Hofmann Description Usage Format Source A multilevel dataset from Hofmann, Griffin, and Gavin (2000). Hofmann A data frame with 1,000 observations and 7 variables. id a numeric vector of group ids. helping a numeric vector of the helping outcome variable construct. mood a level 1 mood predictor. mood_grp_mn a level 2 variable of the group mean of mood. cohesion a level 2 covariate measuring cohesion. mood_grp_cent group-mean centered mood predictor. mood_grd_cent grand-mean centered mood predictor. Hofmann, D.A., Griffin, M.A., & Gavin, M.B. (2000). The application of hierarchical linear modeling to management research. In K.J. Klein, & S.W.J. Kozlowski (Eds.), Multilevel theory, research, and methods in organizations: Foundations, extensions, and new directions (pp. 467-511). Hoboken, NJ: Jossey-Bass. References Aguinis, H., & Culpepper, S.A. (2015). An expanded decision making procedure for examining cross-level interaction effects with multilevel modeling. Organizational Research Methods. Available at: http://hermanaguinis.com/pubs.html See Also lmer, model.matrix, VarCorr, LRTSim, simiccdata Examples ## Not run: if(requirenamespace("lme4") && requirenamespace("rlrsim")){ data(hofmann) library("lme4") # Random-Intercepts Model lmmhofmann0 = lmer(helping ~ (1 id), data = Hofmann) vy_hofmann = var(hofmann[,'helping']) # Computing icca

icc_beta 5 VarCorr(lmmHofmann0)$id[1,1]/vy_Hofmann # Estimating Group-Mean Centered Random Slopes Model, no level 2 variables lmmhofmann1 <- lmer(helping ~ mood_grp_cent + (mood_grp_cent id), X_Hofmann = model.matrix(lmmhofmann1) P = ncol(x_hofmann) T1_Hofmann = VarCorr(lmmHofmann1)$id[1:P,1:P] # Computing iccb icc_beta(x_hofmann, Hofmann[,'id'], T1_Hofmann, vy_hofmann)$rho_beta # Performing LR test # Need to install 'RLRsim' package library("rlrsim") lmmhofmann1a <- lmer(helping ~ mood_grp_cent + (1 id), obs.lrt <- 2*(logLik(lmmHofmann1) - loglik(lmmhofmann1a))[1] X <- getme(lmmhofmann1,"x") Z <- t(as.matrix(getme(lmmhofmann1,"zt"))) sim.lrt <- LRTSim(X, Z, 0, diag(ncol(z))) (pval <- mean(sim.lrt > obs.lrt)) } else { stop("please install packages RLRsim and lme4 to run the above example.") } ## End(Not run) icc_beta Intraclass correlation used to assess variability of lower-order relationships across higher-order processes/units. Description A function and vignettes for computing the intraclass correlation described in Aguinis & Culpepper (2015). iccbeta quantifies the share of variance in an outcome variable that is attributed to heterogeneity in slopes due to higher-order processes/units. Usage icc_beta(x,...) ## S3 method for class 'lmermod' icc_beta(x,...) ## Default S3 method: icc_beta(x, l2id, T, vy,...)

6 icc_beta Arguments x A lmer model object or a design matrix with no missing values.... Additional parameters... l2id T vy Value A list with: J means XcpXc Nj Author(s) rho_beta Steven Andrew Culpepper References A vector that identifies group membership. The vector must be coded as a sequence of integers from 1 to J, the number of groups. A matrix of the estimated variance-covariance matrix of a lmer model fit. The variance of the outcome variable. Aguinis, H., & Culpepper, S.A. (2015). An expanded decision making procedure for examining cross-level interaction effects with multilevel modeling. Organizational Research Methods. Available at: http://hermanaguinis.com/pubs.html See Also lme4::lmer(), model.matrix(), lme4::varcorr(), RLRsim::LRTSim(), iccbeta::hofmann, and iccbeta::simiccdata Examples ## Not run: if(requirenamespace("lme4") && requirenamespace("rlrsim")){ ## Example 1: Simulated Data Example from Aguinis & Culpepper (2015) ---- data(simiccdata) library("lme4") # Computing icca vy <- var(simiccdata$y) lmm0 <- lmer(y ~ (1 l2id), data = simiccdata, REML = FALSE) VarCorr(lmm0)$l2id[1, 1]/vy

icc_beta 7 # Create simiccdata2 grp_means = aggregate(simiccdata[c('x1', 'X2')], simiccdata['l2id'], mean) colnames(grp_means)[2:3] = c('m_x1', 'm_x2') simiccdata2 = merge(simiccdata, grp_means, by='l2id') # Estimating random slopes model lmm1 <- lmer(y ~ I(X1 - m_x1) + I(X2 - m_x2) + (I(X1 - m_x1) + I(X2 - m_x2) l2id), data = simiccdata2, REML = FALSE) ## iccbeta calculation on lmer object icc_beta(lmm1) ## Manual specification of iccbeta # Extract components from model. X <- model.matrix(lmm1) p <- ncol(x) T1 <- VarCorr(lmm1)$l2id[1:p,1:p] # Note: vy was computed under "icca" # Computing iccb # Notice '+1' because icc_beta assumes l2ids are from 1 to 30. icc_beta(x, simiccdata2$l2id + 1, T1, vy)$rho_beta ## Example 2: Hofmann et al. (2000) ---- data(hofmann) library("lme4") # Random-Intercepts Model lmmhofmann0 = lmer(helping ~ (1 id), data = Hofmann) vy_hofmann = var(hofmann[,'helping']) # Computing icca VarCorr(lmmHofmann0)$id[1,1]/vy_Hofmann # Estimating Group-Mean Centered Random Slopes Model, no level 2 variables lmmhofmann1 <- lmer(helping ~ mood_grp_cent + (mood_grp_cent id), ## Automatic calculation of iccbeta using the lmer model amod = icc_beta(lmmhofmann1) ## Manual calculation of iccbeta X_Hofmann <- model.matrix(lmmhofmann1) P <- ncol(x_hofmann) T1_Hofmann <- VarCorr(lmmHofmann1)$id[1:P,1:P] # Computing iccb bmod = icc_beta(x_hofmann, Hofmann[,'id'], T1_Hofmann, vy_hofmann)$rho_beta

8 simiccdata # Performing LR test library("rlrsim") lmmhofmann1a <- lmer(helping ~ mood_grp_cent + (1 id), obs.lrt <- 2*(logLik(lmmHofmann1) - loglik(lmmhofmann1a))[1] X <- getme(lmmhofmann1,"x") Z <- t(as.matrix(getme(lmmhofmann1,"zt"))) sim.lrt <- LRTSim(X, Z, 0, diag(ncol(z))) (pval <- mean(sim.lrt > obs.lrt)) } else { stop("please install packages RLRsim and lme4 to run the above example.") } ## End(Not run) simiccdata Simulated data example from Aguinis and Culpepper (2015). Description A simulated data example from Aguinis and Culpepper (2015) to demonstrate the icc_beta function for computing the proportion of variance in the outcome variable that is attributed to heterogeneity in slopes due to higher-order processes/units. Usage simiccdata Format A data frame with 900 observations (i.e., 30 observations nested within 30 groups) on the following 6 variables. l1id A within group ID variable. l2id A group ID variable. one A column of 1 s for the intercept. X1 A simulated level 1 predictor. X2 A simulated level 1 predictor. Y A simulated outcome variable. Details See Aguinis and Culpepper (2015) for the model used to simulate the dataset.

simiccdata 9 Source Aguinis, H., & Culpepper, S.A. (2015). An expanded decision making procedure for examining cross-level interaction effects with multilevel modeling. Organizational Research Methods. Available at: http://www.hermanaguinis.com/pubs.html See Also lmer, model.matrix, VarCorr, LRTSim, Hofmann Examples ## Not run: data(simiccdata) if(requirenamespace("lme4")){ library("lme4") # computing icca vy <- var(simiccdata$y) lmm0 <- lmer(y ~ (1 l2id), data = simiccdata, REML = FALSE) VarCorr(lmm0)$l2id[1,1]/vy # Create simiccdata2 grp_means = aggregate(simiccdata[c('x1','x2')], simiccdata['l2id'],mean) colnames(grp_means)[2:3] = c('m_x1','m_x2') simiccdata2 = merge(simiccdata, grp_means, by='l2id') # Estimating random slopes model lmm1 <- lmer(y ~ I(X1-m_X1) + I(X2-m_X2) + (I(X1-m_X1) + I(X2-m_X2) l2id), data = simiccdata2, REML = FALSE) X <- model.matrix(lmm1) p <- ncol(x) T1 <- VarCorr(lmm1) $l2id[1:p,1:p] # computing iccb # Notice '+1' because icc_beta assumes l2ids are from 1 to 30. icc_beta(x, simiccdata2$l2id+1, T1, vy)$rho_beta } else { stop("please install lme4 to run the above example.") } ## End(Not run)

Index Topic datasets Hofmann, 3 simiccdata, 8 Hofmann, 3, 9 icc_beta, 5, 8 iccbeta (iccbeta-package), 2 iccbeta-package, 2 iccbeta::hofmann, 6 iccbeta::simiccdata, 6 lme4::lmer(), 6 lme4::varcorr(), 6 lmer, 4, 9 LRTSim, 4, 9 model.matrix, 4, 9 model.matrix(), 6 RLRsim::LRTSim(), 6 simiccdata, 4, 8 VarCorr, 4, 9 10