Skip to contents

This function creates a data frame which can then be input in lapop_coef() for plotting regression coefficients graph using LAPOP formatting.

Usage

lpr_coef(
  outcome = NULL,
  xvar = NULL,
  interact = NULL,
  model = "linear",
  data = NULL,
  estimate = c("coef"),
  vlabs = NULL,
  omit = NULL,
  filesave = NULL,
  replace = FALSE,
  level = 95
)

Arguments

outcome

Dependent variable for the svyglm regression model. (e.g., "outcome_name"). Only one variable allowed.

xvar

Vector of independent variables for the svyglm regression model (e.g., "xvar1+xvar2+xvar3" and so on). Multiple variables are allowed.

interact

Interaction terms (e.g., "xvar1`*`xvar2 + xvar3`:`xvar4"). Supports `:` and `*` operators for interacting variables. Optional, default is NULL.

model

Model family object for glm. Default is gaussian regression (i.e., "linear"). For a logit model, use model="binomial"

data

Survey design data from lpr_data() output.

estimate

Character. Graph either the coefficients (i.e., `coef`) or the change in probabilities (i.e., `contrast`). Default is "coef."

vlabs

Character. Rename variable labels to be displayed in the graph produced by lapop_coef(). For instance, vlabs=c("old_varname" = "new_varname").

omit

Character. Do not display coefficients for these independent variables. Default is to display all variables included in the model. To omit any variables you need to include the raw "varname" in the omit argument.

filesave

Character. Path and file name with csv extension to save the dataframe output.

replace

Logical. Replace the dataset output if it already exists. Default is FALSE.

level

Numeric. Set confidence level in numeric values; default is 95 percent.

Value

Returns a data frame, with data formatted for visualization by lapop_coef

Author

Robert Vidigal, robert.vidigal@vanderbilt.edu

Examples

if (FALSE) { # \dontrun{
# Example 1: Linear model using lpr_coef()
lpr_coef(
 outcome = "l1",
 xvar = "it1+idio2",
 data = dataLAPOP,
 model = "linear",
 est = "coef")} # }
if (FALSE) { # \dontrun{
# Example 2: Logit model using lpr_coef()
lpr_coef(
 outcome = "fs2",
 xvar = "it1+idio2",
 data = dataLAPOP,
 model = "binomial",
 est = "contrast")} # }


if (FALSE) { # \dontrun{
# Example 3: Interactive model using lpr_coef()
lpr_coef(
 outcome = "fs2",
 xvar = "it1+idio2",
 interact = "it1*idio2",
 data = dataLAPOP,
 model = "linear",
 est = "coef")} # }