mylogLikePoisMix {poisson.glm.mix} | R Documentation |
Function to compute the loglikelihood of the mixture.
Description
This function computes the observed loglikelihood given the means and the mixing proportions of each component. Instead of computing ,
, where
,
are computed for all
. Let
, then
.
Usage
mylogLikePoisMix(y, mean, pi)
Arguments
y |
a numeric array of count data with dimension |
mean |
a list of length K (the number of mixture components) of positive data. Each list element is a matrix with dimension |
pi |
a numeric vector of length K (the number of mixture components) containing the mixture weights. |
Value
ll |
the value of the loglikelihood. |
Author(s)
Panagiotis Papastamoulis
Examples
## This example computes the loglikelihood of a K = 10 component
## Poisson GLM mixture. The number of response variables is
## d = 6, while the sample size equals to n = 5000. They are
## stored in the array sim.data[,-1]. The number of covariates
## equals 1 (corresponding to sim.data[,1]). We will use a
## random generation of the regression coefficients alpha and
## beta, in order to show that the loglikelihood can be computed
## without computational errors even in cases where the parameters
## are quite ''bad'' for the data.
data("simulated_data_15_components_bjk_full")
K <- 10
d <- 6
n <- dim(sim.data)[1]
condmean=vector("list",length=K)
weights<-rep(1,K)/K
ar<-array(data=NA,dim=c(n,d))
for (k in 1:K){
for (i in 1:d){
ar[,i]<-runif(n)+(1+0.1*(runif(n)-1))*sim.data[,1]}
condmean[[k]]<-ar}
mylogLikePoisMix(sim.data[,-1],condmean,weights)
[Package poisson.glm.mix version 1.4 Index]