Calculates the log-likelihood, the score functions of the log-likelihood and fits the compound distribution based on the GB2 and using auxiliary information.
pkl.cavgb2(z, lambda)
lambda0.cavgb2(pl0, z, w=rep(1, dim(z)[1]))
logl.cavgb2(fac, z, lambda, w=rep(1, dim(fac)[1]))
scores.cavgb2(fac, z, lambda, w=rep(1, dim(fac)[1]))
ml.cavgb2(fac, z, lambda0, w = rep(1, dim(fac)[1]), maxiter = 100, fnscale=length(w))
pkl.cavgb2
returns a matrix of probabilities. lambda0.cavgb2
returns a matrix of size \(I \times L-1\).
logl.cavgb2
returns the value of the pseudo log-likelihood.
scores.cavgb2
returns the weighted sum of the scores of the log-likelihood.
ml.cavgb2
returns a list containing two objects - the vector of fitted coefficients \(\hat{\lambda_\ell}\) and the output of the "BFGS" fit.
numeric; a matrix of auxiliary variables.
numeric; a matrix of parameters.
numeric; a vector of initial proportions defining the number of components and the weight of each component density in the decomposition. Sums to one.
numeric; vector of weights of length the number of rows of the matrix fac
. By default w
is a vector of 1.
numeric; a matrix of Gamma factors.
numeric; a matrix of initial parameters.
numeric; maximum number of iterations to perform. By default maxiter
= 100.
numeric; parameter of the optim
function. By default fnscale
is equal to the lenth of the vector of weights (value of fnscale
in
the preceding version of the package). Permits to solve some convergence problems (see optim
).
Monique Graf and Desislava Nedyalkova
We model the probabilities \(p_\ell\) with auxiliary variables. Let \(z_k\) denote the vector of auxiliary information for unit \(k\). This auxiliary information modifies the probabilities \(p_\ell\) at the unit level. Denote by \(p_{k,\ell}\) the weight of the density \(f_\ell\) for unit \(k\). For \(\ell=1,...,L-1\), we pose a linear model for the log-ratio \(v_{k,\ell}\):
$$\log(p_{k,\ell}/p_{k,L}) = v_{k,\ell} =\sum_{i=1}^I \lambda_{\ell i} z_{k i}= \mathbf{z}_k^{T} \boldsymbol{\lambda_{\ell}}.$$
Function pkl.cavgb2
calculates the \(p_{k,\ell}\). Function lambda0.cavgb2
calculates the initial values \(\lambda_{\ell i}\), \(i= 1, ..., I\), \(\ell = 1, ..., L-1\) . Let $$\bar{z}_{i}=\sum_k w_k z_{ki}/\sum_k w_k$$ be the mean value of the \(i\)-th explanatory variable.
Writing $$\log(\hat{p}^{(0)}_\ell / \hat{p}^{(0)}_L)=v^{(0)}_\ell = \sum_{i=1}^I \lambda^{(0)}_{\ell i} \bar{z}_{i},$$ we can choose \(\lambda^{(0)}_{\ell i}= v^{(0)}_\ell / (I \bar{z}_{i}).\) Analogically to the ordinary fit of the compound distribution based on the GB2 CompoundFit
, we express the log-likelihood as a weighted mean of \(log(f) = log(\sum(p_{k,\ell} f_\ell(x_k))\), evaluated at the data points, where \(f\) is the GB2 compound density.
The scores are obtained as the weighted sums of the first derivatives of the log-likelihood, with respect to the parameters \(\lambda_\ell, \ \ell=1, ..., L-1\), evaluated at the data points.
Function ml.cavgb2
performs maximum likelihood estimation through the general-purpose optimization function optim
from package stats
.
The considered method of optimization is "BFGS" (optim
). Once we have the fitted parameters \(\hat{\lambda}\) we can deduce the fitted parameters \(\hat{v{k\ell}}\) and
\(\hat{p_{k\ell}}\) in function of \(\bar{z}\) and \(\hat{\lambda}_{\ell}\).