[R-sig-ME] Log-likelihood for each datapoint
Yashree Mehta
y@@hree19 @end|ng |rom gm@||@com
Thu Mar 18 16:23:10 CET 2021
Hi,
I have the following cluster dataset:
1050 Households who own multiple plots (2 on an average). Thus I have a
dataset of 2799 observations.
I am trying to calculate the log-likelihood value for each datapoint (Here,
for each household). I need this value because I have to compute a test
statistic for non-nested model comparison for comparing the lme model with
another model.
At present, I am using the logged value of the multivariate normal pdf. I
extracted the residual variance-covariance matrix, assigned the sigma
matrix (the dimension depending upon number of plots owned by the
household), and composed the following code for log likelihood value of
each household.
llk<-c()
for (i in unique(dataset$household_ID)){
llk[i] <- log(
(2*pi)^(- (# of plots/household)/2)*
determinant^-0.5*
exp(-0.5*t(as.matrix( dataset [ dataset $household_ID ==i,
"observedminusfitted"]))%*%as.matrix(inverse)%*% as.matrix( dataset [
dataset $ household_ID ==i,"observedminusfitted"]))
)
However, the sum of individual likelihood values is not equal to the total
log likelihood value reported by logLik function.
Is this the correct path? If not, is there another way to calculate
loglikelihood value of a single datapoint?
Thank you,
Regards,
Yashree
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list