library(tidyverse)
library(tidybayes)
library(brms)
library(ggtext)
priors <- c(prior(normal(20, 5), class = Intercept),
prior(normal(0, 2), class = b),
prior(exponential(1), class = sigma),
prior(exponential(1), class = sd),
🤷♂️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(fixest) | |
library(data.table) | |
library(insight) | |
bboot_vab <- function(model, reps = 1e3, conf.level = .95, cluster = NULL) { | |
data <- insight::get_data(model) | |
setDT(data) | |
if (!is.null(cluster)) { | |
if (anyNA(data[[cluster]])) { | |
stop("The cluster variable cannot include missing values.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Context: https://twitter.com/grant_mcdermott/status/1487528757418102787 | |
library(data.table) | |
library(fixest) | |
bboot = | |
function(object, reps = 100L, cluster = NULL, ...) { | |
fixest_obj = inherits(object, c('fixest', 'fixest_multi')) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#code from start to finish | |
##install or update packages if neccessary | |
#install.packages("tidyverse") | |
#install.packages("haven") | |
##load packages in | |
library(tidyverse) #loads all "core" tidyverse packages like dplyr, tidyr, forcats, and ggplot2 | |
library(haven) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)) |
Package | Ordinal | Multinomial | Partial proportional odds | Scale Effects | Random Effects |
---|---|---|---|---|---|
nnet | no | multinom |
N/A | N/A | No |
MASS | polr |
No | No | No | No |
ordinal | clm /clm2 |
all X's in nominal (may not converge) |
offending X's in nominal |
via scale |
clmm /clmm2 |
VGAM | yes | ? | ? | ? | No |
MCMCglmm | yes | ? | ? | ? | ? |
Mixcat | yes | ? | ? | npmlt |
|
mlogit | ? | mlogit |
N/A | N/ |