Skip to content

Instantly share code, notes, and snippets.

View benlistyg's full-sized avatar

Benjamin Listyg benlistyg

View GitHub Profile
@benlistyg
benlistyg / fixed_choice_design_sim.R
Last active March 9, 2019 16:42
How does the degree distribution of a FCD network differ from the "true" network of interest?
# Fixed Choice Design Lunchtime Simulation
# 2019-02-06
library(igraph)
library(dplyr)
library(ggplot2)
#Experimental Conditions
conds <- expand.grid(
c(150),
# Multinomial Logit Model vs Random Forest
# Predicting College Major from Items
library(data.table) # For fread function (v fast!)
library(dplyr) # For pre-processing
library(tm) # For cleaning text / pre-processing
library(nnet) #for MNL
library(randomForest) #For rf
# Helper function for making training / testing sets.
outersect <- function(x, y) {
@benlistyg
benlistyg / twitter_vi_prediction.R
Created June 21, 2019 21:21
Messing around with predicting college majors with vocational interest data.
# Multinomial Logit Model vs Random Forest
# Predicting College Major from Items
library(data.table) # For fread function (v fast!)
library(dplyr) # For pre-processing
library(tm) # For cleaning text / pre-processing
library(nnet) #for MNL
library(randomForest) #For rf
# Helper function for making training / testing sets.
outersect <- function(x, y) {
# Multinomial Logit Model vs Random Forest
# Predicting College Major from Items
library(data.table) # For fread function (v fast!)
library(dplyr) # For pre-processing
library(tm) # For cleaning text / pre-processing
library(nnet) #for MNL
library(randomForest) #For rf
# Helper function for making training / testing sets.
outersect <- function(x, y) {
@benlistyg
benlistyg / twitter_vi_prediction.R
Created June 21, 2019 21:22
Messing around with predicting college major from vocational interest data.
# Multinomial Logit Model vs Random Forest
# Predicting College Major from Items
library(data.table) # For fread function (v fast!)
library(dplyr) # For pre-processing
library(tm) # For cleaning text / pre-processing
library(nnet) #for MNL
library(randomForest) #For rf
# Helper function for making training / testing sets.
outersect <- function(x, y) {
@benlistyg
benlistyg / twitter_recode.R
Created December 12, 2019 18:04
Programmatically recode variables (for @lpsatchell)
# Generate Fake Data
fake_data <- sample(x = c(1:5), size = 100, replace = T) %>%
matrix(ncol = 10)
# We want to programmatically recode these.
# 5 to 1 (and vice versa)
# 4 to 2 (and vice versa)
recoding_function <- function(x){