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 and labels are not specified, the colnames and rownames of x are used.

names

A vector containing all group/covariate names, will be used as titles of single effect stars. If NULL, colnames of x is used.

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 x. Otherwise, labels is a vector with length equal to the number of categories, i.e. number rows of x. If NULL, rownames of x is used.

control

Control argument (to set graphical parameters) for method effectstars, see star.ctrl.

cols

Number of columns for arranging effect stars

fixed

If TRUE, all circles have the same radius. If FALSE, every star is scaled so that the length of the longest ray is equal for all stars.

scale

Global factor to increase (scale>1) or decrease (scale<1) the size of the stars.

...

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)

[Package EffectStars2 version 0.1-3 Index]