cubecsi: Main function for CUBE models with covariates only for...

Description Usage Arguments Value See Also Examples

View source: R/cubecsi.R

Description

Estimate and validate a CUBE model for ordinal data, with covariates only for explaining the feeling component.

Usage

1
cubecsi(m, ordinal, W, starting, maxiter, toler)

Arguments

m

Number of ordinal categories

ordinal

Vector of ordinal responses

W

Matrix of selected covariates for explaining the feeling component

starting

Vector of initial parameters estimates to start the optimization algorithm, with length equal to NCOL(W) + 3 to account for an intercept term for the feeling component (first entry)

maxiter

Maximum number of iterations allowed for running the optimization algorithm

toler

Fixed error tolerance for final estimates

Value

An object of the class "CUBE". For cubecsi, $niter will return a NULL value since the optimization procedure is not iterative but based on "optim" (method = "L-BFGS-B", option hessian=TRUE).
$varmat will return the inverse of the numerically computed Hessian when it is positive definite, otherwise the procedure will return a matrix of NA entries.

See Also

loglikcubecsi, inibestcubecsi, CUBE

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
### Applying \donttest option since the proposed examples require a long run time for check

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]
starting=rep(0.1,4)
fit=cubecsi(m, ordinal, W, starting, maxiter=100, toler=1e-3)
param=fit$estimates
pai=param[1]                        ## ML estimates for the uncertainty parameter
gama=param[2:(length(param)-1)]     ## ML estimates for the coefficients of the feeling covariates
phi=param[length(param)]            ## ML estimates for the overdispersion parameter
loglik=fit$loglik
varmat=fit$varmat
BIC=fit$BIC
##########################################################
data(univer)
m<-7
ordinal=univer[,8]
gender=univer[,4]
initial=inibestcube(m,ordinal)
starting=inibestcubecsi(m,ordinal,W=gender,initial,maxiter=500,toler=1e-6)
fitcsi=cubecsi(m, ordinal, W=gender, starting, maxiter=100, toler=1e-3)
param=fitcsi$estimates
pai=param[1]                       ## ML estimates for the uncertainty parameter
gama=param[2:(length(param)-1)]    ## ML estimates for the coefficients of the feeling covariates
phi=param[length(param)]           ## ML estimates for the overdispersion parameter
loglik=fitcsi$loglik
varmat=fitcsi$varmat
BIC=fitcsi$BIC

CUB documentation built on Nov. 17, 2017, 6:37 a.m.