Skip to content

Instantly share code, notes, and snippets.

View mainambui's full-sized avatar

mainambui mainambui

  • Macquarie University
  • Sydney, Australia
  • X @mainambui
View GitHub Profile
@mainambui
mainambui / fake.predict.clmm
Last active February 22, 2020 16:35 — forked from Martin-Jung/fake.predict.clmm
Predicting model averaged clmm models to new data
# Arguments:
# - model = a clmm model
# - modelAvg = a clmm model average (object of class averaging)
# - newdata = a dataframe of new data to apply the model to
# Returns a dataframe of predicted probabilities for each row and response level
fake.predict.clmm <- function(modelAvg, newdata) {
# Actual prediction function
pred <- function(eta, theta, cat = 1:(length(theta) + 1), inv.link = plogis) {
Theta <- c(-1000, theta, 1000)
sapply(cat, function(j) inv.link(Theta[j + 1] - eta) - inv.link(Theta[j] - eta))