Learn R Programming

CUB (version 0.1)

loglikCUBE: Log-likelihood function for CUBE models

Description

Compute the log-likelihood function for CUBE models. It is possible to include covariates in the model for explaining the feeling component or all the three parameters.

Usage

loglikCUBE(ordinal,m,param,Y=0,W=0,Z=0)

Arguments

ordinal
Vector of ordinal responses
m
Number of ordinal categories
param
Vector of parameters for the specified CUBE model
Y
Matrix of selected covariates to explain the uncertainty component (default: no covariate is included in the model)
W
Matrix of selected covariates to explain the feeling component (default: no covariate is included in the model)
Z
Matrix of selected covariates to explain the overdispersion component (default: no covariate is included in the model)

Details

If no covariate is included in the model, then "param" has the form $(\pi,\xi,\phi)$. More generally, it has the form $(\beta,\gamma,\alpha)$ where, respectively, $\beta$,$\gamma$, $\alpha$ are the vectors of coefficients explaining the uncertainty, the feeling and the overdispersion components, with length NCOL(Y)+1, NCOL(W)+1, NCOL(Z)+1 to account for an intercept term in the first entry.

See Also

CUBE, cubeforsim

Examples

Run this code
#### Log-likelihood of a CUBE model with no covariate
m<-7; n<-400
pai<-0.83; csi<-0.19; phi<-0.045
ordinal<-simcube(n,m,pai,csi,phi)
loglik<-loglikCUBE(ordinal,m,param=c(pai,csi,phi))
##################################
#### Log-likelihood of a CUBE model with covariate for feeling
data(relgoods)
m<-10
ordinal<-relgoods[,37]
age<-2014-relgoods[,4]
lage<-log(age)-mean(log(age))
nona<-na.omit(cbind(ordinal,lage))
ordinal<-nona[,1]
W<-nona[,2]
pai<-0.63; gama<-c(-0.61,-0.31); phi<-0.16
param<-c(pai,gama,phi)
loglik<-loglikCUBE(ordinal,m,param,W=W)
########## Log-likelihood of a CUBE model with covariates for all parameters
Y<-W<-Z<-nona[,2]
bet<-c(0.18, 1.03); gama<-c(-0.6, -0.3); alpha<-c(-2.3,0.92)
param<-c(bet,gama,alpha)
loglik<-loglikCUBE(ordinal,m,param,Y=Y,W=W,Z=Z)

Run the code above in your browser using DataLab