Returns the estimated effect of a variable. The effect accounts for both sides
of the market. If the given variable belongs only to the demand side, the name of
result is prefixed by `"D_"`

. If the given variable belongs only to the supply
side, the name of result is prefixed by `"S_"`

. If the variable can be found
both sides, the result name is prefixed by `"B_"`

.

## Usage

```
shortage_marginal(fit, variable, model, parameters)
shortage_probability_marginal(
fit,
variable,
aggregate = "mean",
model,
parameters
)
# S4 method for missing,ANY,market_model,ANY
shortage_marginal(variable, model, parameters)
# S4 method for missing,ANY,ANY,market_model,ANY
shortage_probability_marginal(variable, aggregate, model, parameters)
# S4 method for missing,ANY,market_model,ANY
shortage_marginal(variable, model, parameters)
# S4 method for market_fit,ANY,missing,missing
shortage_marginal(fit, variable)
# S4 method for market_fit,ANY,ANY,missing,missing
shortage_probability_marginal(fit, variable, aggregate)
```

## Arguments

- fit
A fitted market model.

- variable
Variable name for which the effect is calculated.

- model
A market model object.

- parameters
A vector of parameters.

- aggregate
Mode of aggregation. Valid options are "mean" (the default) and "at_the_mean".

## Functions

`shortage_marginal()`

: Marginal effect on market systemReturns the estimated marginal effect of a variable on the market system. For a system variable \(x\) with demand coefficient \(\beta_{d, x}\) and supply coefficient \(\beta_{s, x}\), the marginal effect on the market system is given by $$M_{x} = \frac{\beta_{d, x} - \beta_{s, x}}{\sqrt{\sigma_{d}^{2} + \sigma_{s}^{2} - 2 \rho_{ds} \sigma_{d} \sigma_{s}}}.$$

`shortage_probability_marginal()`

: Marginal effect on shortage probabilitiesReturns the estimated marginal effect of a variable on the probability of observing a shortage state. The mean marginal effect (

`aggregate = "mean"`

) on the shortage probability is given by $$M_{x} \mathrm{E} \phi\left(\frac{D - S}{\sqrt{\sigma_{d}^2 + \sigma_{s}^2 - 2 rho \sigma_{d} \sigma_{s}}}\right)$$. and the marginal effect at the mean (`aggregate = "at_the_mean"`

) by $$M_{x} \phi\left(\mathrm{E}\frac{D - S}{\sqrt{\sigma_{d}^2 + \sigma_{s}^2 - 2 rho \sigma_{d} \sigma_{s}}}\right)$$ where \(M_{x}\) is the marginal effect on the system, \(D\) is the demanded quantity, \(S\) the supplied quantity, and \(\phi\) is the standard normal density.

## Examples

```
# \donttest{
# estimate a model using the houses dataset
fit <- diseq_deterministic_adjustment(
HS | RM | ID | TREND ~
RM + TREND + W + CSHS + L1RM + L2RM + MONTH |
RM + TREND + W + L1RM + MA6DSF + MA3DHF + MONTH,
fair_houses(),
correlated_shocks = FALSE,
estimation_options = list(control = list(maxit = 1e+5))
)
# mean marginal effect of variable "RM" on the shortage probabilities
#' shortage_probability_marginal(fit, "RM")
# marginal effect at the mean of variable "RM" on the shortage probabilities
shortage_probability_marginal(fit, "CSHS", aggregate = "at_the_mean")
#> D_CSHS
#> 0.0003055982
# marginal effect of variable "RM" on the system
shortage_marginal(fit, "RM")
#> B_RM
#> -0.1830798
# }
```