% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fracregmlogit.plot.R
\name{plot.fracregmlogit.pe}
\alias{plot.fracregmlogit.pe}
\title{Plot Marginal or Discrete Effects}
\usage{
\method{plot}{fracregmlogit.pe}(
  x,
  varlist = NULL,
  X = NULL,
  y = NULL,
  against = NULL,
  against.x = NULL,
  against.y = NULL,
  group.x = NULL,
  group.algebra = NULL,
  mfrow = NULL,
  ...
)
}
\arguments{
\item{x}{A "fracregmlogit.pe" object.}

\item{varlist}{A string vector which provides the names of variables to plot the effect for.
If missing, all variables in the object will be plotted.}

\item{X}{A matrix of independent variables.}

\item{y}{A matrix of dependent variables.}

\item{against}{A vector with the same length as the number of observations in the model. 
Serves as the x-axis in the plots.}

\item{against.x}{A character string, supply the column name in the X matrix to plot against.}

\item{against.y}{A character string, supply the column name in the y matrix to plot against.}

\item{group.x}{A character string. Supply the column name in the X matrix to group upon.}

\item{group.algebra}{A character string. Supply additional algebra imposed on the group variable.}

\item{mfrow}{A numeric vector with two elements. Specifies the number of rows and columns in a panel.
Similar to par(mfrow=c()). Default to NULL, and the program will choose a square panel.}

\item{...}{Additional arguments.}
}
\value{
Panel plots of effects vs. chosen variables.
}
\description{
Plot the desired effect at each observed value for each choice.
}
\details{
This function provides a visualisation tool for potentially heterogeneous marginal and discrete effects.
The function allows the user to plot marginal effects to detect any patterns in the effects, in itself
and against other variables. The plot also allows visualisation of sub-groups in data, which can be
very useful to visualise categorical and dummy variables. 

The function takes a \code{fracregmlogit.pe} object, created by the \code{fracregmlogit.pe()} function. Note that since 
the plotting requires marginal effects for all observations, the object should be created by choosing 
\code{marg.type="aveacr"}, the average across method for effects calculation. 

Additional parameters include \code{varlist}, a vector of string variable names to be plotted. \code{X}
and \code{y} are the dependent and independent variable matrices in the original regression model. 
 
\code{against}, \code{against.x}, and \code{against.y} allow different variables to be chosen
as the x-axis. \code{against} directly supplies the vector to be plotted against, whereas \code{against.x}
and \code{against.y} supply variable names in the original dataset. Note that the user has to provide
\code{X} and \code{y} in order to use the column name options, respectively. 
 
\code{group.x} supplies the column name in the X matrix to group by. The plot will be able to 
differentiate different groups by colours. Additionally, the user can supply a string to \code{group.algebra},
which provides an algebra operation that will be evaluated on the group vector. For example, choosing 
\code{group.x = "a"} and \code{group.algebra = ">0"} will create two groups, one with X$a > 0, and one with X$a <= 0.
}
\examples{
\donttest{
data("fracreg_spending")
X = fracreg_spending[,2:5]
y = fracreg_spending[,6:11]
results1 = fracregmlogit(y, X)

# Calculate marginal effects with marg.type="aveacr" (no standard errors for speed)
effect1 = fracregmlogit.pe(results1, effect="marginal", marg.type="aveacr", se=FALSE)

# Plot effects
plot(effect1, X=results1$X, against.x = "houseval", group.x = "popdens", group.algebra = ">10")
}
}
\seealso{
\code{\link{fracregmlogit.pe}}
}
