effectstars.default {EffectStars2} | R Documentation |
Plot effect stars.
Description
Plots effect stars for grouped coefficients. Effect stars are applicable if the
parameters of a model are grouped in some sense. For example, the parameters of a multinomial
logit models are grouped by the covariates, i.e. per covariate there is one estimate per response category.
But also in many other models, the parameters can have a fixed grouping structure. All estimates have to be positive,
typically the exponentials of the estimates are plotted. Every effect star comes with a circle of radius 1.
This circle represents the case of no effect, i.e. exp(0)=1
.
Usage
## Default S3 method:
effectstars(x, names = NULL, subs = NULL,
labels = NULL, control = star.ctrl(), cols = NULL, fixed = FALSE,
scale = 1, ...)
Arguments
x |
A matrix containing all coefficients to plot, one column per group/covariate,
one row per category. If the arguments |
names |
A vector containing all group/covariate names, will be used as titles of single
effect stars. If NULL, |
subs |
A vector containing all subtitles, one per group/covariate. |
labels |
A vector or a matrix containing labels of the categories. If labels is a matrix,
it needs to have the same dimensions as |
control |
Control argument (to set graphical parameters) for method |
cols |
Number of columns for arranging effect stars |
fixed |
If |
scale |
Global factor to increase ( |
... |
possible further arguments |
Author(s)
Gunther Schauberger
gunther.schauberger@tum.de
https://www.sg.tum.de/epidemiologie/team/schauberger/
References
Tutz, G. and Schauberger, G. (2013): Visualization of Categorical Response Models -
from Data Glyphs to Parameter Glyphs, Journal of Computational and Graphical Statistics 22(1), 156–177.
Gerhard Tutz (2012): Regression for Categorical Data, Cambridge University Press
See Also
star.ctrl
, effectstars.vglm
, effectstars.DIFlasso
, effectstars.DIFboost
Examples
## Not run:
#####################
### Simple example for basic effectstars function
p <- 4; k <- 5
coefs <- matrix(exp(rnorm(p*k,sd=0.5)),ncol=k)
rownames(coefs) <- paste("Variable",1:p)
colnames(coefs) <- paste("Cat",1:k)
effectstars(coefs)
#####################
### Example for effect stars for a multivariate logit model
data(xs.nz, package = "VGAMdata")
xs.nz$age <- scale(xs.nz$age)
library(VGAM)
cats_dogs <- vglm(cbind(cat, dog) ~ age + sex + marital,
data = xs.nz, family = binom2.or(zero = NULL))
summary(cats_dogs)
## quick and dirty
effectstars(exp(coef(cats_dogs, matrix = TRUE)))
## make it pretty
# create the effects matrix you want to plot, name rows and columns
effects <- exp(coef(cats_dogs, matrix = TRUE))
colnames(effects) <- c("cat", "dog", "OR")
rownames(effects) <- c("Intercept", "Age", "Gender", rep("Marital", 3))
# create subtitles containing category labels of predictors
subs <- c(rep("",2), "(male)", "(married)", "(separated/divorced)", "(widowed)")
# create labels containing the response categories and all p-values
p_values <- formatC(summary(cats_dogs)@coef3[,4], format="f", digits=3)
labels <- matrix(paste0(rep(c("cat", "dog", "OR"), nrow(effects)), "\n(", p_values, ")"),
byrow = TRUE, ncol = 3)
# plot effectstars
effectstars(effects, labels = labels, subs = subs)
#####################
## Example for method effectstars.vglm for a multinomial logit model calculated in VGAM
data(election)
library(VGAM)
m_elect <- vglm(Partychoice ~ Gender + West + Age + Union + Highschool + Unemployment
+ Pol.Interest + Democracy + Religion, family = multinomial(), data = election)
effectstars(m_elect)
## End(Not run)