Skip to content

Instantly share code, notes, and snippets.

@FrankRuns
Created January 8, 2021 22:27
Show Gist options
  • Save FrankRuns/b9c5e660eb9833d77081b4b10a999b42 to your computer and use it in GitHub Desktop.
Save FrankRuns/b9c5e660eb9833d77081b4b10a999b42 to your computer and use it in GitHub Desktop.
library(tidyverse)
library(ggplot2)
# create holder data frame
data <- data.frame(magic_number=numeric(), equity_fraction=numeric(),
mgmt_span=numeric(), ps_fit=numeric(),
salary_growth=numeric())
# create ranges for variables
s_set <- 1:20
e_set <- c(0.05, 0.10, 0.15, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45, 0.50)
g_set <- c(0.06, 0.12, 0.18, 0.24, 0.30)
f_set <- 1:10/10
# calculate magic number threshold for all combinations of incentive variables
for (v_s in s_set) {
for (v_e in e_set) {
for (v_g in g_set) {
for (v_f in f_set) {
temp_data <- data.frame(v_e, v_s, v_f, v_g)
temp_data$m <- (v_e * v_s^2 * v_f)/v_g
data <- rbind(data, temp_data)
}
}
}
}
# create scatterplot for single level of E & G
df1 <- data %>% filter(e == 0.25 & g == 0.12)
combos1 <- df1 %>% filter(m > 135 & m < 155)
ggplot(combos1, aes(x=f, y=s)) + geom_point() +
geom_smooth(method="lm", aes(color="Exp Model"), formula= (y ~ log(x)), se=FALSE, linetype = 1) +
theme_minimal() +
theme(legend.position = "none") +
labs(x="Project-Skill Fit (1=perfect)", y="Mgmt. Span",
title="Mgmt. Span & Skill-Fit Inverse Relationship at Magic Number Threshold (135-155)",
subtitle="Different combinations of S & F can produce innovative environments.")
# create scatterplot for all levels of E & G
combos <- data %>% filter(m > 135 & m < 155)
ggplot(combos, aes(x=v_f, y=v_s)) + geom_point() +
facet_grid(v_g~v_e) +
geom_smooth(method="lm", aes(color="Exp Model"), formula= (y ~ log(x)), se=FALSE, linetype = 1) +
theme_minimal() +
theme(legend.position = "none") +
labs(x="Project-Skill Fit (1=perfect)", y="Mgmt. Span",
title="Mgmt. Span & Skill-Fit Inverse Relationship at Magic Number Threshold (135-155)",
subtitle="Different combinations of S & F can produce innovative environments.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment