Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
glmm.hp
https://www.rdocumentation.org/packages/glmm.hp/versions/0.1-4
Admin
glmm.hp is an R package that conducts hierarchical partitioning to calculate individual
...
Tokens:
648
Snippets:
5
Trust Score:
9.8
Update:
1 year ago
Context
Chat
Benchmark
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Install glmm.hp R Package Source: https://www.rdocumentation.org/packages/glmm.hp/versions/0.1-4/index Provides the command to install the glmm.hp package from CRAN. This is necessary to use the package's functionalities. ```r install.packages('glmm.hp') ``` -------------------------------- ### Calculate Marginal R2 for LM with custom R2 type and commonality analysis Source: https://www.rdocumentation.org/packages/glmm.hp/versions/0.1-4/topics/glmm This example shows how to use glmm.hp with a standard linear model (lm) object. It demonstrates specifying a different R2 type ('R2' instead of the default 'adjR2') and enabling commonality analysis by setting the 'commonality' argument to TRUE. ```R mod3 <- lm(Sepal.Length ~ Petal.Length + Petal.Width + Petal.Length:Petal.Width, data = iris) glmm.hp(mod3,type="R2") glmm.hp(mod3,commonality=TRUE) ``` -------------------------------- ### Plotting glmm.hp Objects in R Source: https://www.rdocumentation.org/packages/glmm.hp/versions/0.1-4/topics/plot This R code demonstrates how to plot objects created by the glmm.hp function. It shows generating a glmm.hp object from a mixed-effects model and plotting it, as well as plotting with different options like 'R2' type and custom colors. ```r library(MuMIn) library(lme4) mod1 <- lmer(Sepal.Length ~ Petal.Length + Petal.Width +(1 | Species), data = iris) a <- glmm.hp(mod1) plot(a) mod3 <- lm(Sepal.Length ~ Petal.Length+Petal.Width,data = iris) plot(glmm.hp(mod3,type="R2")) plot(glmm.hp(mod3,commonality=TRUE),color = c("#8DD3C7", "#FFFFB3")) ``` -------------------------------- ### Calculate Marginal R2 for GLM using glmm.hp Source: https://www.rdocumentation.org/packages/glmm.hp/versions/0.1-4/topics/glmm Demonstrates calculating hierarchical partitioning of marginal R2 for a generalized linear model (GLM) using the glmm.hp function. It uses a fitted glm object and shows how to obtain and plot the results, similar to mixed-effect models. ```R mod2 <- glm(Sepal.Length ~ Petal.Length + Petal.Width, data = iris) r.squaredGLMM(mod2) glmm.hp(mod2) b <- glmm.hp(mod2) plot(b) plot(glmm.hp(mod2)) ``` -------------------------------- ### Calculate Marginal R2 for Mixed Models using glmm.hp Source: https://www.rdocumentation.org/packages/glmm.hp/versions/0.1-4/topics/glmm This function calculates the hierarchical partitioning of marginal R2 for generalized linear mixed-effect models. It takes a fitted model object from packages like lme4, nlme, or glmmTMB as input. Outputs include the R2 for the full model and a matrix detailing individual predictor effects and their contribution to the total marginal R2. ```R library(MuMIn) library(lme4) mod1 <- lmer(Sepal.Length ~ Petal.Length + Petal.Width+(1|Species),data = iris) r.squaredGLMM(mod1) glmm.hp(mod1) a <- glmm.hp(mod1) plot(a) ```