% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/multipliers.R
\name{mplier}
\alias{mplier}
\title{Compute Dynamic Multipliers for kardl Models}
\usage{
mplier(kmodel, horizon = 80, minProb = 0)
}
\arguments{
\item{kmodel}{An object of class \code{kardl_lm} produced by the \code{kardl} function.}

\item{horizon}{Integer. Number of periods ahead for which dynamic multipliers are computed.}

\item{minProb}{Numeric. Minimum p-value threshold for including coefficients in the calculation. Coefficients with p-values above this threshold will be set to zero. Default is \code{0} (no threshold).
This parameter allows users to control the inclusion of coefficients in the calculation based on their statistical significance. Setting a threshold can help focus the analysis on more relevant variables, but it may also exclude potentially important effects if set too stringently.}
}
\value{
A list of class \code{kardl_mplier} containing:
\itemize{
\item \strong{mpsi}: Matrix of cumulative dynamic multipliers.
\item \strong{omega}: Vector of omega coefficients (persistence structure).
\item \strong{lambda}: Matrix of short-run dynamic coefficients.
\item \strong{horizon}: Forecast horizon used.
\item \strong{vars}: Extracted model variable structure.
}
}
\description{
Computes cumulative dynamic multipliers based on a model estimated using the
\code{kardl} framework. The function supports different configurations of
linearity and asymmetry in both short-run and long-run dynamics.
}
\details{
The asymmetry structure is determined internally:
\itemize{
\item Variables in \code{extractedInfo$ASvars} are treated as asymmetric in the short run.
\item Variables in \code{extractedInfo$ALvars} are treated as asymmetric in the long run.
}

This allows four possible configurations:
\itemize{
\item \strong{LL}: Linear in both short-run and long-run
\item \strong{NN}: Asymmetric in both short-run and long-run
\item \strong{SA}: Short-run linear, long-run asymmetric
\item \strong{AS}: Short-run asymmetric, long-run linear
}

When a component is linear, the same coefficient path is used for both positive
and negative changes. When asymmetric, separate positive and negative effects
are computed.

The \code{mplier} function computes dynamic multipliers based on the coefficients and lag structure of a model estimated using the \code{kardl} package. The function extracts necessary
information from the model, such as coefficients, lag structure, and variable names, to compute the dynamic multipliers. It calculates the short-run coefficients, Lambda values, and omega values based on the model's parameters and lag structure. The output includes a matrix of dynamic multipliers (mpsi), which can be used for further analysis or visualization.
The dynamic multipliers provide insight into how changes in the independent variables affect the dependent variable over time, allowing for a deeper understanding of the relationships captured by the model. The function also allows users to set a minimum p-value threshold for including coefficients in the calculation, providing flexibility in focusing on statistically significant effects.

The function constructs dynamic multipliers based on the recursive relationship:

\deqn{
\psi_{h}^{+} = \sum_{i=0}^{h} \frac{\partial y_{t+i}}{\partial x_{t}^{+}}, \quad
\psi_{h}^{-} = \sum_{i=0}^{h} \frac{\partial y_{t+i}}{\partial x_{t}^{-}}
}

where \eqn{\psi_h^{+}} and \eqn{\psi_h^{-}} represent cumulative responses to
positive and negative shocks.

The recursion is defined as:

\deqn{
\psi_h = \lambda_h + \sum_{j=1}^{p} \omega_j \psi_{h-j}
}

where \eqn{\lambda_h} captures short-run effects and \eqn{\omega_j} reflects
persistence through lagged dependent variables.

When asymmetry is present, positive and negative shocks are propagated separately.
Otherwise, the same dynamic path is used.
}
\examples{

# This example demonstrates how to use the mplier function to calculate dynamic multipliers
# from a model estimated using the kardl package. The example includes fitting a model with
# the kardl function, calculating the multipliers, and visualizing the results using both
# base R plotting and ggplot2.

 # Calculating dynamic multipliers for a linear model in short and long run (NN)

 kardl_model<-kardl(imf_example_data, CPI~ER )
 m<-mplier(kardl_model,40)
 head(m$mpsi)
 plot(m)

 # Calculating dynamic multipliers for a model with
 # Short-run linear, long-run asymmetric (SA)
 kardl_model<-kardl(imf_example_data, CPI~lasym(ER) )
 m<-mplier(kardl_model,40)
 head(m$mpsi)
 plot(m)

 # Calculating dynamic multipliers for a model with
 # Short-run asymmetric, long-run linear (AS)
 kardl_model<-kardl(imf_example_data, CPI~sasym(ER) )
 m<-mplier(kardl_model,40)
 head(m$mpsi)
 plot(m)

 # Calculating dynamic multipliers for a model with
 # asymmetric effects in both short and long run (NN)
 kardl_model<-kardl(imf_example_data, CPI~asym(ER) )
 m<-mplier(kardl_model,40)
 head(m$mpsi)
 plot(m)

 # The mpsi matrix contains the cumulative dynamic multipliers for each variable and time horizon.
 # The omega vector contains the persistence structure of the model,
 # while the lambda matrix contains the short-run dynamic coefficients.
 # You can inspect these components to understand the dynamics captured by the model.
 kardl_model<-kardl(imf_example_data, CPI~PPI+asym(ER) )
 m<-mplier(kardl_model,40)
 head(m$mpsi)
 head(m$omega)
 head(m$lambda)

 # For plotting specific variables, you can specify them in the plot function. For example,
 # to plot the multipliers for the variable "PPI":

 plot(m, variable = "PPI")


}
\seealso{
\code{\link{bootstrap}}
}
