Package GrzLinModel
Max-likelihood and bayesian estimation of generalized linear models with prior information and constraining linear inequations.
Weighted Generalized Regresions
Abstract class GrzLinModel::@WgtReg is the base to inherit weighted generalized linear regressions as poisson, binomial, normal or any other, given just the scalar link function and the density function .
In a weighted regression each row of input data has a distinct weight in the likelihood function. For example, it can be very usefull to handle with data extrated from an stratified sample.
Let be
- the regression input matrix
- the vector of weights of each register
- the regression output matrix
- the regression coefficients
- the linear prediction
- the link function
- the inverse-link or mean function
- the density function of a distribution of the exponential family
Then we purpose that the average of the output is the inverse of the link function applyied to the linear predictor
The density function becomes as a real valuated function of at least two parameters
For each row we will know the output and the average
Each particular distribution may have its own additional parameters which will be treated as a different Gibbs block and should implement next methods in order to be able of build both bayesian and max-likelihood estimations
- the mean function:
- the log-density function:
- the first and second partial derivatives of log-density function respect to the linear prediction
The likelihood function of the weigthed regression is then
and its logarithm
The gradient of the logarithm of the likelihood function will be
and the hessian is
This class also implements these common features extending the generalized linear model class:
- linear constraining inequations over linear parameters
- scalar prior information of type normal or uniform, truncated or not in both cases,
- vectorial normal prior information (not implemented)
Weighted Poisson Regresion
It will be implemented in GrzLinModel::@WgtPoisson but is not available yet. There is an example of use in test_0002/test.tol
In this case we have
- the link function
- the mean function
- the probability mass function
- and its logarithm will be
- the partial derivatives of log-density function respect to the linear prediction is
Weighted Qualitative Regresion
For boolean and qualitative response outputs like logit or probit there is an specialization on package QltvRespModel
Extended Regressions
Under certain circumstances, the optimization and simulation methods used over pure exponential family, can be extended to distributions with extra parameters than average.
This extra parameters can be simulated in a Gibbs frame by simple alternating and incorporating prior information about all them. In MLE optimization we can use Expectation–maximization algorithm to take profit of reusing written code.
Weighted Normal Regresion
Is implemented in GrzLinModel::@WgtNormal There is an example of use in test_0001/test.tol
In this case we have
- the identity as link function and mean function
- the density function has the variance as extra parameter
- we can stablish an optional inverse chi-square prior over the variance or even fix it as a known value.
- the log-density function will be
- the partial derivatives of log-density function respect to the linear prediction is
Weighted Zero-Inflated Poisson Regresion
Is implemented in GrzLinModel::@WgtPoisson.ZeroInflated There is an example of use in test_0004/test.tol
This a mixture of Bernouilli and Poisson that inflates the probability of zero occurrences in a certain value
that will be called zero inflation and will be an extra parameter used to fit overdispersion.
When we have a Poisson and when it's a Bernouilli.
- the link function is the same than Poisson one
- the probability mass function is
- and its logarithm will be
- the first and second partial derivatives of log-density function respect to the linear prediction are
- the first partial derivative of log-density function respect to the zero-inflation parameter is