
Last chance! 50% off unlimited learning
Sale ends in
Calculates the log-likelihood, the score functions of the log-likelihood, the weighted mean of scores, and fits the parameters of the Compound Distribution based on the GB2.
vofp.cgb2(pl)
pofv.cgb2(vl)
logl.cgb2(fac, pl, w=rep(1, dim(fac)[1]))
scores.cgb2(fac, pl, w=rep(1, dim(fac)[1]))
ml.cgb2(fac, pl0, w=rep(1, dim(fac)[1]), maxiter=100, fnscale=length(w))
numeric; 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 fitted proportions. Sums to one. If pl
is equal to pl0
, we obtain the GB2 distribution.
numeric; matrix of Gamma factors (output of fac.cgb2
.
numeric; vector of parameters. Its length is equal to the length of pl
- 1.
numeric; vector of weights of length the number of rows of the matrix fac
. By default w
is a vector of 1.
numeric; maximum number of iterations to perform. By default maxiter
= 100.
numeric; an overall scaling parameter used in the function optim
. By default it is equal to the length of the vector of weights w
.
vofp.cgb2
returns a vector of length pofv.cgb2
returns a vector of length logl.cgb2
returns the value of the pseudo log-likelihood.
scores.cgb2
returns a vector of the weighted mean of the scores of length ml.cgb2
returns a list containing two objects - the vector of fitted proportions
There are only vofp.cgb2
. pofv.cgb2
calculates the w
ml.cgb2
performs maximum likelihood estimation through the general-purpose optimization function optim
from package stats
. The considered method of optimization is BFGS.
# NOT RUN {
# GB2 parameters:
a <- 4
b <- 1950
p <- 0.8
q <- 0.6
# Proportions defining the component densities:
pl0 <- rep(1/3,3)
# Mixture probabilities
pl <- c(0.1,0.8,0.1)
# Random generation:
n <- 10000
set.seed(12345)
x <- rcgb2(n,a,b,p,q,pl0,pl,decomp="l")
# Factors in component densities
fac <- fg.cgb2(x,a,b,p,q, pl0,decomp="l")
# Estimate the mixture probabilities:
estim <- ml.cgb2(fac,pl0)
# estimated mixture probabilities:
estim[[1]]
#[1] 0.09724319 0.78415797 0.11859883
# }
Run the code above in your browser using DataLab