-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 871e41f
Showing
20 changed files
with
494 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
^README\.Rmd$ | ||
^README-.*\.png$ | ||
^\.travis\.yml$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.RData | ||
.Ruserdata | ||
src/*.o | ||
src/*.so | ||
src/*.dll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r | ||
|
||
language: R | ||
sudo: false | ||
cache: packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Package: iccbeta | ||
Type: Package | ||
Title: Multilevel model intraclass correlation for slope heterogeneity | ||
Version: 1.0 | ||
Date: 2014-11-21 | ||
Authors@R: c(person("Steven Andrew", "Culpepper", role = c("aut", "cph","cre"), email = | ||
"sculpepp@illinois.edu"),person("Herman", "Aguinis", role = c("aut", "cph"), email = | ||
"haguinis@indiana.edu")) | ||
Maintainer: Steven Andrew Culpepper <sculpepp@illinois.edu> | ||
Description: 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. | ||
License: GPL (>= 2) | ||
Imports: Rcpp (>= 0.11.1) | ||
LinkingTo: Rcpp (>= 0.11.1), RcppArmadillo | ||
Depends: R (>= 3.0.2), lme4 | ||
Packaged: 2014-11-25 02:21:38 UTC; sculpepp | ||
Author: Steven Andrew Culpepper [aut, cph, cre], | ||
Herman Aguinis [aut, cph] | ||
NeedsCompilation: yes | ||
Repository: CRAN | ||
Date/Publication: 2014-11-25 08:52:58 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
useDynLib(iccbeta) | ||
#import(RcppArmadillo) | ||
import(lme4) | ||
importFrom("Rcpp", evalCpp) | ||
exportPattern("^[[:alpha:]]+") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# This file was generated by Rcpp::compileAttributes | ||
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 | ||
|
||
#' @title Compute ICCbeta intraclass correlation | ||
#' @description Computes the proportion of variance attributed to group heterogeneity in slopes as described by Aguinis & Culpepper (2015). | ||
#' The function uses lmer model information. | ||
#' @usage icc_beta(X,l2id,T,vy) | ||
#' @param X The design \code{matrix} of fixed effects from a lmer model. | ||
#' @param l2id A \code{vector} that identifies group membership. The vector must be coded as a sequence from 1 to J, the number of groups. | ||
#' @param T A \code{matrix} of the estimated variance-covariance matrix of a lmer model fit. | ||
#' @return vy The variance of the dependent variable. | ||
#' @author Steven A Culpepper | ||
NULL | ||
|
||
icc_beta <- function(X, l2id, T, vy) { | ||
.Call('iccbeta_icc_beta', PACKAGE = 'iccbeta', X, l2id, T, vy) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
output: github_document | ||
--- | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
||
```{r, echo = FALSE} | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>", | ||
fig.path = "README-" | ||
) | ||
``` | ||
|
||
[](https://travis-ci.org/tmsalab/iccbeta)[](http://www.r-pkg.org/pkg/iccbeta)[](https://cran.r-project.org/package=iccbeta) | ||
|
||
# `iccbeta` R Package | ||
|
||
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
[](https://travis-ci.org/tmsalab/iccbeta)[](http://www.r-pkg.org/pkg/iccbeta)[](https://cran.r-project.org/package=iccbeta) | ||
|
||
`iccbeta` R Package | ||
=================== | ||
|
||
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. |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Version: 1.0 | ||
|
||
RestoreWorkspace: Default | ||
SaveWorkspace: Default | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 4 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: knitr | ||
LaTeX: pdfLaTeX | ||
|
||
BuildType: Package | ||
PackageUseDevtools: Yes | ||
PackageInstallArgs: --no-multiarch --with-keep.source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
citHeader("To cite package iccbeta in publications use:") | ||
|
||
citEntry(entry="Article", | ||
title = "An expanded decision making procedure for examining cross-level interaction effects with multilevel modeling", | ||
author = personList(as.person("Herman Aguinis"), | ||
as.person("Steven Andrew Culpepper")), | ||
journal = "Organization Research Methods", | ||
year = "in press", | ||
url = "http://mypage.iu.edu/~haguinis/pubs.html", | ||
pdf = "http://mypage.iu.edu/~haguinis/ORMinpress.pdf", | ||
textVersion = "Agunis, H. & Culpepper, S. A. (in press). An expanded decision making procedure for examining cross-level interaction effects with multilevel modeling. Organizational Research Methods.") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
\name{Hofmann} | ||
\alias{Hofmann} | ||
\docType{data} | ||
\title{ | ||
A multilevel dataset from Hofmann, Griffin, and Gavin (2000). | ||
} | ||
\description{ | ||
A multilevel dataset from Hofmann, Griffin, and Gavin (2000). | ||
} | ||
\usage{data(Hofmann)} | ||
\format{ | ||
A data frame with 1,000 observations and 7 variables. | ||
\describe{ | ||
\item{\code{id}}{a numeric vector of group ids.} | ||
\item{\code{helping}}{a numeric vector of the helping outcome variable construct.} | ||
\item{\code{mood}}{a level 1 mood predictor.} | ||
\item{\code{mood_grp_mn}}{a level 2 variable of the group mean of mood.} | ||
\item{\code{cohesion}}{a level 2 covariate measuring cohesion.} | ||
\item{\code{mood_grp_cent}}{group-mean centered mood predictor.} | ||
\item{\code{mood_grd_cent}}{grand-mean centered mood predictor.} | ||
} | ||
} | ||
%\details{ | ||
%% ~~ If necessary, more details than the __description__ above ~~ | ||
%} | ||
\author{ | ||
Steven Andrew Culpepper, | ||
Herman Aguinis | ||
|
||
Maintainer: Steven Andrew Culpepper <sculpepp@illinois.edu> | ||
} | ||
\source{ | ||
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. (in press). An expanded decision making procedure for examining cross-level interaction effects with multilevel modeling. \emph{Organizational Research Methods}. Available at: \url{http://mypage.iu.edu/~haguinis/pubs.html} | ||
} | ||
\seealso{ | ||
\code{\link[lme4]{lmer}}, \code{\link{model.matrix}}, \code{\link[lme4]{VarCorr}}, \code{\link[RLRsim]{LRTSim}}, \code{\link{simICCdata}} | ||
} | ||
\examples{ | ||
\dontrun{ | ||
data(Hofmann) | ||
require(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),data=Hofmann,REML=F) | ||
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),data=Hofmann,REML=F) | ||
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)) | ||
} | ||
} | ||
\keyword{datasets} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
\name{icc_beta} | ||
\alias{icc_beta} | ||
\docType{package} | ||
\title{ | ||
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 (in press). 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, l2id, T, vy) | ||
} | ||
|
||
\arguments{ | ||
\item{X}{The design \code{matrix} of fixed effects from a lmer model.} | ||
|
||
\item{l2id}{A \code{vector} that identifies group membership. The vector must be coded as a sequence of integers from 1 to J, the number of groups.} | ||
|
||
\item{T}{A \code{matrix} of the estimated variance-covariance matrix of a lmer model fit.} | ||
|
||
\item{vy}{The variance of the outcome variable.} | ||
} | ||
|
||
\author{ | ||
Steven Andrew Culpepper, | ||
Herman Aguinis | ||
|
||
Maintainer: Steven Andrew Culpepper <sculpepp@illinois.edu> | ||
} | ||
|
||
\references{ | ||
Aguinis, H., & Culpepper, S.A. (in press). An expanded decision making procedure for examining cross-level interaction effects with multilevel modeling. \emph{Organizational Research Methods}. Available at: \url{http://mypage.iu.edu/~haguinis/pubs.html} | ||
} | ||
\seealso{ | ||
\code{\link[lme4]{lmer}}, \code{\link{model.matrix}}, \code{\link[lme4]{VarCorr}}, \code{\link[RLRsim]{LRTSim}}, \code{\link{Hofmann}}, \code{\link{simICCdata}} | ||
} | ||
\examples{ | ||
\dontrun{ | ||
#Simulated Data Example from Aguinis & Culpepper (in press) | ||
data(simICCdata) | ||
require(lme4) | ||
|
||
#computing icca | ||
vy = var(simICCdata$Y) | ||
lmm0 <- lmer(Y ~ (1|l2id),data=simICCdata,REML=F) | ||
VarCorr(lmm0)$l2id[1,1]/vy | ||
|
||
#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=F) | ||
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 et al. (2000) Example | ||
data(Hofmann) | ||
require(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),data=Hofmann,REML=F) | ||
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),data=Hofmann,REML=F) | ||
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)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
\name{iccbeta-package} | ||
\alias{iccbeta-package} | ||
\alias{iccbeta} | ||
\docType{package} | ||
\title{ | ||
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 (in press). iccbeta quantifies the share of variance in an outcome variable that is attributed to heterogeneity in slopes due to higher-order processes/units. | ||
} | ||
\details{ | ||
\tabular{ll}{ | ||
Package: \tab iccbeta\cr | ||
Type: \tab Package\cr | ||
Version: \tab 1.0\cr | ||
Date: \tab 2014-11-21\cr | ||
License: \tab GPL (>= 2)\cr | ||
} | ||
} | ||
\author{ | ||
Steven Andrew Culpepper, | ||
Herman Aguinis | ||
|
||
Maintainer: Steven Andrew Culpepper <sculpepp@illinois.edu> | ||
} | ||
\references{ | ||
Aguinis, H., & Culpepper, S.A. (in press). An expanded decision making procedure for examining cross-level interaction effects with multilevel modeling. \emph{Organizational Research Methods}. Available at: \url{http://mypage.iu.edu/~haguinis/pubs.html} | ||
} | ||
|
||
\keyword{ package } | ||
|
||
\examples{ | ||
\dontrun{ | ||
#Simulated Data Example | ||
data(simICCdata) | ||
require(lme4) | ||
|
||
#computing icca | ||
vy = var(simICCdata$Y) | ||
lmm0 <- lmer(Y ~ (1|l2id),data=simICCdata,REML=F) | ||
VarCorr(lmm0)$l2id[1,1]/vy | ||
|
||
#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=F) | ||
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) | ||
require(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),data=Hofmann,REML=F) | ||
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),data=Hofmann,REML=F) | ||
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)) | ||
} | ||
} |
Oops, something went wrong.