This file contains 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
#' Installs any packages not already installed | |
#' @examples | |
#' \dontrun{ | |
#' install_if_missing(c('tidyverse','github.com/stan-dev/cmdstanr')) | |
#' } | |
install_if_missing = function(pkgs){ | |
missing_pkgs = NULL | |
for(this_pkg in pkgs){ |
This file contains 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
#This code assumes data is a matrix, stored as "a", where rows specify samples through time and columns specify different electrodes. | |
#This code also assumes that the colnames of the matrix specify the names of the electrodes using the 10-20 naming system | |
#get the last character of the 10-20 name (which should be the electrode number) | |
enum = substr(colnames(a),nchar(colnames(a)),nchar(colnames(a))) | |
#change any enums of zero to 10 | |
enum[enum=='0']='10' | |
#create a list of column numbers |
This file contains 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
Mike’s Podcast picks | |
———— | |
Comedic (all should be started at S01E01) | |
———— | |
The adventure zone | |
Mission to Zyxx | |
Beef & Dairy Network Podcast | |
———— |
This file contains 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
functions{ | |
real partial_lpdf( | |
array[] real real_array_to_slice | |
, int start | |
, int end | |
, real sigma | |
, vector Zc | |
, matrix iZc_chol_mat | |
, matrix iZc | |
, array[] matrix iZc_ |
This file contains 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
#import used modules | |
import sys | |
import time | |
import multiprocessing | |
#create a multiprocessing Queue object for sending messages to an input process | |
queueToInputProcess = multiprocessing.Queue() | |
#create a multiprocessing Queue object for receiving messages from an input process |
This file contains 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
data{ | |
# n_subj: number of subjects | |
int n_subj ; | |
# n_y: number of outcomes | |
int n_y ; | |
# y: matrix of outcomes | |
matrix[n_subj,n_y] y ; | |
# n_fac: number of latent factors | |
int n_fac ; | |
# y_fac: list of which factor is associated with each outcome |
This file contains 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
Version: 1.0 | |
RestoreWorkspace: No | |
SaveWorkspace: No | |
AlwaysSaveHistory: No | |
QuitChildProcessesOnExit: Yes | |
EnableCodeIndexing: Yes | |
UseSpacesForTab: No | |
NumSpacesForTab: 4 |
This file contains 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
#' Installs any packages not already installed | |
#' @examples | |
#' \dontrun{ | |
#' install_if_missing(c('tidyverse','github.com/stan-dev/cmdstanr')) | |
#' } | |
install_if_missing = function(pkgs){ | |
missing_pkgs = NULL | |
for(this_pkg in pkgs){ |
This file contains 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
#preamble (installs/imports & custom functions) ---- | |
# specify the packages used: | |
required_packages = c( | |
'rethinking' #for rlkjcorr & rmvrnom2 | |
, 'crayon' #for coloring terminal output | |
, 'tidyverse' #for all that is good and holy | |
, 'progress' #for progress bar | |
, 'github.com/stan-dev/cmdstanr' #for Stan stuff | |
, 'github.com/mike-lawrence/ezStan' #for extra Stan stuff (here just get_contrast_matrix) |
This file contains 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
# load packages and define helper functions ---- | |
library(cmdstanr) #for bayes goodness | |
library(posterior) #for posterior::as_draws_df() | |
library(progress) # for progress bars | |
library(viridis) #for better color scales | |
library(tidyverse) #for all that is good and holy | |
# helper function to create a progess bar in the global env | |
create_global_pb = function(x){ | |
pb <<- progress::progress_bar$new( |
NewerOlder