gge_fit: Plot fitted values

gge_fitR Documentation

Plot fitted values

Description

This function plot the fitted value or the predicted probability given the model estimated using lm or glm and the original data.

Usage

gge_fit(
  model,
  data,
  y,
  x,
  formula = NULL,
  n = 200,
  cat.values = NULL,
  model.id = NULL,
  show.points = T,
  pch.col = "#00000044",
  pch.pos = "identity",
  pch.col.cat = NULL,
  linetype = FALSE,
  line.size = 0.8,
  ylim = NULL,
  xlim = NULL,
  xlab = NULL,
  ylab = NULL,
  facets = NULL,
  facets.title.position = "left",
  facets.ncol = NULL,
  facets.scales = "fixed",
  title = NULL,
  title.position = "left",
  subtitle = NULL,
  footnote = NULL,
  legend.show.formulas = TRUE,
  legend.show.cat = FALSE,
  legend.position = "top",
  legend.omit = F,
  legend.title = NULL,
  legend.direction = "horizontal",
  legend.box = "horizontal",
  legend.ncol.colour = NULL,
  legend.ncol.fill = NULL,
  legend.col.title = NULL,
  legend.fill.title = NULL,
  pch.col.palette = c(brewer = "BrBG"),
  fill.palette = c(viridis = "B")
)

Arguments

model

a model object, a list of them, or a tidy data frame with summary(ies) of the estimation(s). A model object can be one produced as output of lm or glm. If the tidy summary is provided instead of the model object it must contain the columns term, estimate (the point estimate), and std.error (standard error of the estimates). The content of the column term must match the name of the covariate associated the estimates as produced by attr(terms(formula), 'term.labels'), and formula must also be provided as a parameter. If there are more than one model in the summary table, it must have a column identifying the models.

data

the original data set used to fit the model

y

a string with the name of the dependent variable

x

a string with the name of the independent variable that will be used to plotted in the x-axis.

formula

a expression as used in lm function. It is used when the parameter model receives a tidy summary. If more than one model is provided in the table, formula must be a named list. The names must match the values in the column in the table that identify each model. The formula must also match the model. See examples.

n

an integer, the number of points of x generated to produce the predicted/fitted values

cat.values

named list of string vectors. The name of each element of the list (the string vectors) must match variable names in the data. The element of the string vectors must be strings with the name of the categories to use in the plot with the fitted values. To generate the fitted values, the numeric columns will be set to their mean value, except the column specified in the parameter x. The categorical values are set to their first category or the first category in alphabetic order. One can set the categorical variables to different values or use more than one category by setting this parameter cat.value as desired. For instance, suppose there is a categorical variable in the data set named education, taking the values of High or Low, which was used in the model. If cat.value=NULL, the plot with the predicted values will be fixed at education=High. One can use education="Low" by setting cat.value=list(eductation="low"). One can generate predicted values for both levels of education by setting cat.value=list(eductation=c("low", "high")). See more examples in the documentation below.

model.id

a string with the name of the column that identifies the model in the table smry.

show.points

boolean, indicating if the points from the original data set must be plotted or not

pch.col

a string or rgb code.

pch.pos

a string with position of the points (e.g., jitter, identity). Default is identity.

pch.col.cat

a string vector with the name of the categorical variable in the data to use as color key for the points

linetype

boolean, if TRUE, the plot displays different line types if there is more than one fitted line. Default is FALSE

line.size

numeric, the size of the fitted line

ylim

two-dimensional numeric vector with the limits of the y-axis

xlim

two-dimensional numeric vector with the limits of the x-axis

xlab

string with text to display in the x-axis

ylab

string with text to display in the y-axis

facets

a string vector with the name of the categorical variable to generate the facets. The fitted values will be produced for each facet.

facets.title.position

a string with left, right, or center. Indicates the position of the title of the facets

facets.ncol

an integer, the number of columns of grid when using facets.

facets.scales

used when facets are used. See facet_wrap

title

a string, the title of the plot

title.position

a string (or an number) with center (or .5), left (or 0), or right (or 1)

subtitle

a string, the subtitle of the plot

footnote

a string, the footnote of the plot

legend.show.formulas

boolean, if TRUE and more than one model is provided, the formula associated with the model is displayed in the legend

legend.show.cat

boolean, if TRUE and both cat.values and more than one model are provided, it shows the categories used to fit the values in each model

legend.position

a string (top, bottom, left (Default)), right

legend.omit

boolean, if TRUE the legend is omitted

legend.title

a string with the title of the legend

legend.direction

see guide_legend

legend.box

see guide_legend

legend.ncol.colour

an integer indicating the number of columns to use in the legend with color code

legend.ncol.fill

an integer indicating the number of columns to use in the legend with fill code (fitted line estimation interval)

legend.col.title

string, the title of the legend with color code of the points. Default: Categories

legend.fill.title

string, the title of the legend with color code of the fitted values estimated interval

pch.col.palette

a named string vector with one element. The name must be the color palette (brewer, viridis and the value a string with the pallete available (ex: "Blues" for brewer palette, "A" for viridis, etc)

fill.palette

same as for pch.col.palette, but it controls the color of the interval around the fitted line. It also accepts unnamed vector with string "grey" (use grey scales) or "plain" to use a single grey color


DiogoFerrari/edar documentation built on May 8, 2022, 8:26 a.m.