get_fitted: Get fitted values

get_fittedR Documentation

Get fitted values

Description

Get fitted values from summary table

Usage

get_fitted(
  data,
  smry,
  formula = NULL,
  newdata = NULL,
  x = NULL,
  n = 200,
  cat.values = NULL,
  model.id = NULL
)

Arguments

data

the dataset used to estimate the model

smry

the summary table organized in data frame (see function broom::tidy()). It must contain at least three columns: one named term that follows the pattern of the table return by lm function; a column named estimate with the point estimate of the linear coefficient; std.error or a similar measure used to capture the uncertainty of the esitmate. The table may contain results of multiple models, in which case it must contain an additional column whose name must be provided to the parameter model.id.

formula

an R formula used to estimate the model, as used in the function lm, for instance. If the smry contains multiple models, formula must be a named list. Each element of the list must contain the formula of the respective model, and the names must match the names used in the column to identity the models in the summary table passed in the parameter smry.

newdata

either NULL or a data set that will be used to compute the fitted values.

x

a string with the name of the variable that will be used as varying dependent variable to compute the fitted values.

n

an integer with the number of data points that will be used to compute the fitted values. Default: 200.

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.


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