gg_coefsplot_data: Prepare data for caterpillar plots of boral regression...

Description Usage Arguments Value See Also

View source: R/coefsplot.R

Description

This function takes a fitted boral model and returns a data frame to use with ggplot to draw 'caterpillar plots' of regression coefficients. It is used by function gg_coefsplot but you can also use it directly.

Usage

1

Arguments

model

A boral model fitted with one or more latent variables.

Value

A data frame to use with ggplot that has the following columns:

label

y variable labels (e.g. species names)

var

X (explanatory) variable names

lower95

lower bound of the 95 for coefficient value

upper95

upper bound of the 95 for coefficient value

median

median coefficent value

revlabel

Factor variable based on label with levels in reverse order so that graphs will show, for example, species names in A-Z order from top to bottom.

## Not run: dat.gg <- gg_coefsplot_data(mymodel) # Draw 'manually' with ggplot as an alternative to using # the gg_coefsplot function. First we add a variable # for how central zero is in the intervals which we will # use to colour the intervals. # library(dplyr) dat.gg <- dat.gg mutate(zeroness = ifelse(lower95 > 0 | upper95 < 0, 0, min(abs(lo), hi) / max(abs(lo), hi))) ggplot(data = dat.gg, aes(y = revlabel)) + geom_segment(aes(yend = revlabel, x = lower95, y = upper95, colour = zeroness)) + scale_colour_grey(start = 1.0, end = 0.2) + geom_point(aes(x = median)) + geom_vline(xintercept = 0, linetype = "dashed") facet_wrap(~ var) ## End(Not run)

See Also

gg_lvsplot


mbedward/ggboral documentation built on June 27, 2020, 10:15 a.m.