% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lpr_coef.R
\name{lpr_coef}
\alias{lpr_coef}
\title{LAPOP Regression Coefficients Graph Pre-Processing}
\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{
\item{outcome}{Dependent variable for the svyglm regression model. (e.g., "outcome_name"). Only one variable allowed.}

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

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

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

\item{data}{Survey design data from lpr_data() output.}

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

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

\item{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.}

\item{filesave}{Character. Path and file name with csv extension to save the dataframe output.}

\item{replace}{Logical. Replace the dataset output if it already exists. Default is FALSE.}

\item{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
}
\description{
This function creates a data frame which can then be input in lapop_coef() for
plotting regression coefficients graph using LAPOP formatting.
}
\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")

}
\author{
Robert Vidigal, \email{robert.vidigal@vanderbilt.edu}
}
