gge_coef | R Documentation |
This is a wrap function for the function dwplot
from the package dotwhisker
gge_coef( model, xlab = "Coefficient Estimate", ylab = "", var.order = NULL, model.id = NULL, title = NULL, subtitle = NULL, footnote = NULL, legend.position = "top", legend.title = "", title.position = "left", hc = FALSE, hc.type = c("hc3", "hc0", "hc1", "hc2", "hc4") )
model |
either an object from |
xlab |
string with text to display in the x-axis |
ylab |
string with text to display in the y-axis |
var.order |
A vector of variable names that specifies the order in which the variables are to appear along the y-axis of the plot. If a data.frame is provided, the order of the y-axis will follow the order of the rows in the data.frame |
model.id |
a string with the name of the column that contain the id of each model |
title |
a string, the title of the plot |
subtitle |
a string, the subtitle of the plot |
footnote |
a string, the footnote of the plot |
legend.position |
a string ( |
legend.title |
a string with the title of the legend |
title.position |
a string (or an number) with |
hc |
boolean, if |
hc.type |
a string with the method to compute the standard errors (see |
Robust standard errors are computed when hc=T
only when the parameter model
is an object from lm
, glm
.
library(magrittr) set.seed(77) data = tibble::data_frame(n = 300, x1 = rnorm(n,3,1), x2 = rexp(n), cat1 = sample(c(0,1), n, replace=TRUE), cat2 = sample(letters[1:4], n, replace=TRUE), y = -10*x1*cat1 + 10*x2*(3*(cat2=='a') -3*(cat2=='b') +1*(cat2=='c') -1*(cat2=='d')) + rnorm(n,0,10), y.bin = ifelse(y < mean(y), 0, 1), y.mul = 1+ifelse( - x1 - x2 + rnorm(n,sd=10) < 0, 0, ifelse( - 2*x2 + rnorm(n,sd=10) < 0, 1, 2)), ) model.g1 = lm(y ~ x1, data) model.g2 = lm(y ~ x1 + x2, data) model.g = lm(y ~ x1*cat1 + x2*cat2, data) model.bin = glm(y.bin ~ x1+x2*cat2, data=data, family='binomial') model.mul <- nnet::multinom(y.mul ~ x1 + x2, data) gge_coef(model.g) gge_coef(model.g, hc=TRUE) gge_coef(tidye(model.g) %>% dplyr::arrange(estimate), hc=TRUE) gge_coef(model.bin) gge_coef(model.bin, hc=TRUE) gge_coef(tidye(model.g)) ## many models at once models=tidye(list('Standard Model'=model.bin)) %>% dplyr::bind_rows(tidye(list('Robust std. error'=model.bin), hc=TRUE) ) gge_coef(models) gge_coef(models, model.id='model') ## list of models gge_coef(list(model.g, model.g1, model.g2), model.id='model') gge_coef(list('Complete model'=model.g, "One Covar"=model.g1, "Two covars"=model.g2), model.id='model' ) ## pipe can be used ## modelg %>% gge_coef
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.