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
| gistr |
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
| gistr |
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
| #' Helper function to create arrays | |
| #' | |
| #' Function takes a data.frame in long mode and converts it to an array. Function can also repeat a | |
| #' single matrix to fill out an array. | |
| #' | |
| #' @param input_matrix Either a data.frame in long mode or a single matrix | |
| #' @param arr_dim If \code{input_matrix} is a single matrix, \code{arr_dim} determines the length of the resulting array | |
| #' @param row_var Unquoted variable name that identifies the data.frame column corresponding to the rows (1st dimension) of the array (must be unique) | |
| #' @param col_var_name Unquoted variable name that identifies the data.frame column corresponding names of the columns (2nd dimension) of the array | |
| #' @param col_var_value Unquoted variable name that identifies the data.frame column corresponding to the values that populate the cells of the array |
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
| # Ordinal versus binary outcome power calculation | |
| # Robert Kubinec | |
| # New York University Abu Dhabi | |
| # January 31, 2022 | |
| library(dplyr) | |
| library(ordinal) | |
| library(ggplot2) | |
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
| # test glmmTMB's MLE implementation of the ordered beta regression model | |
| # and compare it to the ordbetareg package, which uses | |
| # Bayesian estimation (Stan/brms) | |
| library(glmmTMB) | |
| library(ordbetareg) | |
| library(dplyr) | |
| data("pew") |
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
| # calculate Pr(Y=1) and Pr(Y=0) (i.e. the discrete categories of the scale) | |
| # for different groups in the data | |
| # useful for treatment/control comparisons | |
| library(ordbetareg) | |
| library(dplyr) | |
| library(tidyr) | |
| library(posterior) | |
| library(tidybayes) | |
| library(ggplot2) |
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(DeclareDesign) | |
| library(ordbetareg) | |
| library(fabricatr) | |
| library(future) | |
| library(marginaleffects) | |
| library(broom) | |
| library(glmmTMB) | |
| set.seed(20241125) |
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
| # ChatGPT 4o created this distribution with the following prompt: | |
| # "can you define a new statistical distribution that no one | |
| # has ever used before and | |
| # write out the stan code for the likelihood" | |
| # it required one additional prompt to ask it to provide | |
| # a function for initial starting values after Stan | |
| # failed to initialize the MCMC chain | |
| # it did so successfully and no alterations were made to the code below |
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(dplyr) | |
| # define code as emojis | |
| # simulate data from Normal distribution and fit OLS regression | |
| `🙄` <- lm | |
| `🤩` <- tibble | |
| `🤪` <- mutate |
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
| # generate google drive files for class | |
| library(googledrive) | |
| library(readr) | |
| library(readxl) | |
| library(tidyverse) | |
| library(stringr) | |
| # need class roster/blackboard export |