Dear Community,
I am trying to fit a model to my ordered categorical data. I have been using : Bayesian ordinal regression with random effects using brms to help, as well as https://journals.sagepub.com/doi/full/10.1177/2515245918823199.
There is a useful function Kevin Stadler describes to select a link, it looks like this;
cumulativemodelfit <- function(formula, data, links=c("logit", "probit", "cloglog", "cauchit"),
thresholds=c("flexible", "equidistant"), verbose=TRUE) {
names(links) <- links
names(thresholds) <- thresholds
llks <- outer(links, thresholds,
Vectorize(function(link, threshold)
# catch error for responses with 2 levels
tryCatch(ordinal::clm(formula, data=data, link=link, threshold=threshold)$logLik,
error = function(e) NA)))
print(llks)
if (verbose) {
bestfit <- which.max(llks)
cat("\nThe best link function is ", links[bestfit %% length(links)], " with a ",
thresholds[1 + bestfit %/% length(thresholds)], " threshold (logLik ", llks[bestfit],
")\n", sep="")
}
invisible(llks)
}
I applied it to my data which is a score for sentiment (negative, neutral, positive)
linkfunction<-cumulativemodelfit(sentiment ~ 1, data=iddf)
The output is below:
> linkfunction
> flexible equidistant
> logit -2066.537 -2066.537
> probit -2066.537 -2066.537
> cloglog -2066.537 -2066.537
> cauchit -2066.537 -2066.537
> The best link function is cloglog with a equidistant threshold (logLik -2066.537)
I’m wondering if anyone can help me understand what is happening? I am new to Brms, and not sure why all the links provide the same result, but then clog log is selected?
Thank you so much