lpr_coef: LAPOP Regression Coefficients Graph Pre-Processing

View source: R/lpr_coef.R

lpr_coefR Documentation

LAPOP Regression Coefficients Graph Pre-Processing

Description

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(s)

Robert Vidigal, robert.vidigal@vanderbilt.edu

Examples


require(lapop); data(bra23)

# Set Survey Context
bra23lpr <- lpr_data(bra23, wt = TRUE)

# Example 1: Linear model
lpr_coef(data = bra23lpr,
 outcome = "ing4",
 xvar = "wealth+idio2",
 model = "linear",
 estimate = "coef")

# Example 2: Logit model with contrasts
lpr_coef(data = bra23lpr,
 outcome = "fs2",
 xvar = "wealth+idio2",
 model = "binomial",
 estimate = "contrast")

# Example 3: Interactive linear model
lpr_coef(data = bra23lpr,
 outcome = "ing4",
 xvar = "wealth+idio2",
 interact = "wealth*idio2",
 model = "linear",
 estimate = "coef")

# Example 4: Interactive logit model
lpr_coef(data = bra23lpr,
         outcome = "fs2",
         xvar = "wealth+idio2",
         interact = "wealth*idio2",
         model = "binomial",
         estimate = "contrast")


lapop documentation built on April 30, 2026, 1:07 a.m.