Learn R Programming

CUB (version 1.1.5)

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). No missing value should be present neither for ordinal nor for X.

See Also

GEM, logLik

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
naord<-which(is.na(relgoods$SocialNetwork))
nacov<-which(is.na(relgoods$Gender))
na<-union(nacov,naord)
ordinal<-relgoods$SocialNetwork[-na]; cov<-relgoods$Gender[-na]
omega<-c(-2.29, 0.62)
loglikcov<-loglikCUSH(ordinal,m,param=omega,shelter=1,X=cov)

Run the code above in your browser using DataLab