Skip to content

Instantly share code, notes, and snippets.

View svmiller's full-sized avatar
🤷‍♂️
¯\_(ツ)_/¯

Steven V. Miller svmiller

🤷‍♂️
¯\_(ツ)_/¯
View GitHub Profile
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),
@vincentarelbundock
vincentarelbundock / bboot_vab.R
Last active February 7, 2022 21:38
Bayesian bootstrap in `R` with `update()`
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.")
@grantmcdermott
grantmcdermott / bboot.R
Last active May 6, 2022 18:50
Bayesian bootstrap
# 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'))
#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)
@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))
@casallas
casallas / multinomial.md
Last active January 14, 2023 22:12
R Packages/Functions/Resources for multinomial (ordinal & categorical) regression
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/