Compute the log-likelihood value of a CUB model fitting given data, with or without covariates to explain the feeling and uncertainty components, or for extended CUB models with shelter effect.
loglikCUB(ordinal,m,param,Y=0,W=0,X=0,shelter=0)
Arguments
ordinal: Vector of ordinal responses
m: Number of ordinal categories
param: Vector of parameters for the specified CUB 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)
X: Matrix of selected covariates to explain the shelter effect (default: no covariate is included in the model)
shelter: Category corresponding to the shelter choice (default: no shelter effect is included in the model)
Details
If no covariate is included in the model, then param should be given in the form (π,ξ). More generally, it should have the form (β,γ) where, respectively, β and γ are the vectors of coefficients explaining the uncertainty and the feeling components, with length NCOL(Y)+1 and NCOL(W)+1 to account for an intercept term in the first entry. When shelter effect is considered, param corresponds to the first possibile parameterization and hence should be given as (pai1,pai2,csi). No missing value should be present neither for ordinal nor for covariate matrices: thus, deletion or imputation procedures should be preliminarily run.
Examples
## Log-likelihood of a CUB model with no covariatem<-9; n<-300pai<-0.6; csi<-0.4ordinal<-simcub(n,m,pai,csi)param<-c(pai,csi)loglikcub<-loglikCUB(ordinal,m,param)#################################### Log-likelihood of a CUB model with covariate for uncertaintydata(relgoods)m<-10naord<-which(is.na(relgoods$Physician))nacov<-which(is.na(relgoods$Gender))na<-union(naord,nacov)ordinal<-relgoods$Physician[-na]; Y<-relgoods$Gender[-na]bbet<-c(-0.81,0.93); ccsi<-0.2param<-c(bbet,ccsi)loglikcubp0<-loglikCUB(ordinal,m,param,Y=Y)######################### Log-likelihood of a CUB model with covariate for feelingdata(relgoods)m<-10naord<-which(is.na(relgoods$Physician))nacov<-which(is.na(relgoods$Gender))na<-union(naord,nacov)ordinal<-relgoods$Physician[-na]; W<-relgoods$Gender[-na]pai<-0.44; gama<-c(-0.91,-0.7)param<-c(pai,gama)loglikcub0q<-loglikCUB(ordinal,m,param,W=W)######################### Log-likelihood of a CUB model with covariates for both parametersdata(relgoods)m<-10naord<-which(is.na(relgoods$Walking))nacovpai<-which(is.na(relgoods$Gender))nacovcsi<-which(is.na(relgoods$Smoking))na<-union(naord,union(nacovpai,nacovcsi))ordinal<-relgoods$Walking[-na]Y<-relgoods$Gender[-na]; W<-relgoods$Smoking[-na]bet<-c(-0.45,-0.48); gama<-c(-0.55,-0.43)param<-c(bet,gama)loglikcubpq<-loglikCUB(ordinal,m,param,Y=Y,W=W)########################## Log-likelihood of a CUB model with shelter effectm<-7; n<-400pai<-0.7; csi<-0.16; delta<-0.15shelter<-5ordinal<-simcubshe(n,m,pai,csi,delta,shelter)pai1<- pai*(1-delta); pai2<-1-pai1-delta
param<-c(pai1,pai2,csi)loglik<-loglikCUB(ordinal,m,param,shelter=shelter)