Generalized additive models for location, scale and shape (GAMLSS) have been developed to do exactly that. As the name implies, they allow not only for explicit modelling of the location but also of scale and shape of the conditional distribution. The gamlss
package in R
makes this easy.
For a simple conditional normal model with a log-link for the standard deviation you could write:
\begin{align}
\mathbf Y &\sim N(\mathbf \mu, \mathbf \sigma) \\
\mathbf \eta_1 &= g_1(\mathbf \mu) = \mathbf \mu = \mathbf X_1\mathbf\beta_1 \\
\mathbf \eta_2 &= g_2(\mathbf \mu) = \log(\mathbf \sigma) = \mathbf X_2\mathbf\beta_2 \\
\end{align}
where $\mathbf Y$ is the response vector, $\mathbf X_1$ and $\mathbf X_2$ are the design matrices for the mean and standard deviation and $\mathbf \beta_1$ and $\mathbf \beta_2$ are the coefficient vectors for the mean and standard deviation.
In R
you'd fit such a model like this:
# Load the package
library(gamlss)
# Fit the model
mod <- gamlss(
y~x1 + x2 + x3
, sigma.formula = ~x1 + x2 + x3
, family = "NO"
, data = dat
)
# Inspect fit
plot(mod)
# Look at summary
summary(mod)
In the function gamlss
, the first formula is the linear predictor for the mean whereas the formula called sigma.formula
specifies the linear predictor for the standard deviation with a log-link.
You can extend this model by adding splines (e.g. pb
) or other nonlinear terms such as polynomials to the formulas. If the conditional distribution has more parameters such as the skew $t$ distribution for example, you can further model the skewness and kurtosis using tau.formula
and nu.formula
, respectively.