Learn R Programming

CUB (version 0.1)

loglikCUSH: Log-likelihood function for CUSH models

Description

Compute the log-likelihood function for CUSH models with or without covariates to explain the shelter effect.

Usage

loglikCUSH(ordinal,m,param,shelter,X=0)

Arguments

ordinal
Vector of ordinal responses
m
Number of ordinal categories
param
Vector of parameters for the specified CUSH model
shelter
Category corresponding to the shelter choice
X
Matrix of selected covariates to explain the shelter effect (default: no covariate is included in the model)

Details

If no covariate is included in the model, then "param" is the estimate of the shelter parameter (delta), otherwise "param" has length equal to NCOL(X) + 1 to account for an intercept term (first entry)

See Also

CUSH

Examples

Run this code
## Log-likelihood of CUSH model without covariates
n<-300
m<-7
shelter<-2
delta<-0.4
ordinal<-simcush(n,m,delta,shelter)
loglik<-loglikCUSH(ordinal,m,param=delta,shelter)
#####################
## Log-likelihood of CUSH model with covariates
data(relgoods)
m<-10
ordinal<-relgoods[,44]
cov<-relgoods[,2]
nona<-na.omit(cbind(ordinal,cov))
ordinal<-nona[,1]
cov<-nona[,2]
shelter<-1
omega<-c(-2.29, 0.62)
loglikcov<-loglikCUSH(ordinal,m,param=omega,shelter,X=cov)

Run the code above in your browser using DataLab