数据:2022.01.01–2024.09.01 全部的random PK pair
# data = read.csv("Within_Random_Pk_final_clean_1.csv")
data <- read_parquet("../../0.DataCleaning/1.Input/synthetic_data2.parquet")
source("Plot_CI_function.R")
data <- data %>%
mutate(
p_date = as_date(as.character(p_date)), # Convert to Date format
day = day(p_date), # Extract day as numeric
month = month(p_date), # Extract month as numeric
year = year(p_date), # Extract year in "YYYY" format
quarter = paste0(year(p_date), "-Q", quarter(p_date)) # Extract quarter in "YYYY-QN" format
) %>%
mutate(other_before_fans_count = other_fans_user_num,
before_fans_count = fans_user_num,
live_operation_tag = author_type, # 此处可能是错的, 需要double check tag是否是type
other_live_operation_tag = other_author_type) %>%
mutate(fan_size_pair = case_when(
(before_fans_count>=10000) & (other_before_fans_count>=10000)~ 3,
(before_fans_count>=10000) & (other_before_fans_count<10000)~ 2,
(before_fans_count<10000) & (other_before_fans_count>= 10000)~ 1,
(before_fans_count<10000) & (other_before_fans_count<10000)~ 0
)) %>%
mutate(fan_size_pair = factor(fan_size_pair, level = c(0,1,2,3),
labels = c("Small vs Small ", "Small vs Big", "Big vs Small", "Big vs Big"))) %>%
mutate(is_same_category = case_when(
(live_operation_tag == other_live_operation_tag) ~ 1,
TRUE ~ 0
))
table(data$fan_size_pair)
##
## Small vs Small Small vs Big Big vs Small Big vs Big
## 125844 27850 27411 6021
table(data$is_same_category)
##
## 0 1
## 85903 101223
# table(data$total_cost_amt) # 119056 为0
# (1) 人均粉丝打赏
data$avg_fan_total_cost_amt <- (data$total_cost_amt)/(data$before_fans_count + 1)
# (1.1) 人均(viewer)打赏= 总打赏/总的viewer人数
data$avg_viewer_total_cost_amt <- (data$total_cost_amt)/(data$valid_play_user_num + 1)
# (1.2) 单位观看时长的打赏 = 总打赏/总观看时长
data$avg_time_total_cost_amt <- (data$total_cost_amt)/(data$valid_play_duration + 1)
# (2) 涨粉
data$follow_author_fans_count <- sample(0:1000, nrow(data), replace = TRUE) #这里是生成的数据,实际数据要comment掉
# (3) 掉粉
data$unfollow_author_fans_count <- sample(0:100, nrow(data), replace = TRUE) #这里是生成的数据,实际数据要comment掉
# (4) net 涨粉
data$net_follow_fans <- data$follow_author_fans_count - data$unfollow_author_fans_count
summary(data$net_follow_fans)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -100.0 198.0 450.0 449.2 699.0 1000.0
min_net_follow_fans <- min(data$net_follow_fans, na.rm = TRUE)
# (5) 吸粉
data$already_follow_other_fans_count <- sample(0:500, nrow(data), replace = TRUE) #这里是生成的数据,实际数据要comment掉
# (6) 粉丝被对方吸走
data$other_already_follow_other_fans_count <- sample(0:20, nrow(data), replace = TRUE) #这里是生成的数据,实际数据要comment掉
# (7) net吸粉
data$net_attract_fans <- data$already_follow_other_fans_count - data$other_already_follow_other_fans_count
summary(data$net_attract_fans)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -20.0 114.0 240.0 239.9 366.0 500.0
min_net_attract_fans <- min(data$net_attract_fans, na.rm = TRUE)
data <- data %>%
mutate(
log_avg_fan_total_cost_amt = log(avg_fan_total_cost_amt + 1),
log_avg_viewer_total_cost_amt = log(avg_viewer_total_cost_amt + 1),
log_avg_time_total_cost_amt = log(avg_time_total_cost_amt + 1),
log_follow_author_fans_count = log(follow_author_fans_count + 1),
log_unfollow_author_fans_count = log(unfollow_author_fans_count + 1),
log_net_follow_fans = log(net_follow_fans - min_net_follow_fans + 1),
log_already_follow_other_fans_count = log(already_follow_other_fans_count + 1),
log_other_already_follow_other_fans_count = log(other_already_follow_other_fans_count + 1),
log_net_attract_fans = log(net_attract_fans - min_net_attract_fans + 1)
)
crs <- c(
# Independent Variables
"is_same_category" = "Same Category in PK",
"fan_size_pair" = "Fan Size Pair in PK",
# Control Variables
"gender" = "Gender",
"age_range" = "Age Category",
"author_type" = "Streamer Type",
"fre_country_region" = "Region",
"fre_city_level" = "City Level",
"log_fans_num" = "Follower Count (log)",
"log_history_total_cost" = "Historical Gifting (log)",
"log_history_valid_play_duration" = "Historical View Time (log)",
"log_history_comment_cnt" = "Historical Comment Count (log)",
"log_history_like_cnt" = "Historical Like Count (log)",
# Dependent Variables
"log_avg_fan_total_cost_amt" = "Avg Gifting per Follower (log)",
"log_avg_viewer_total_cost_amt" = "Avg Gifting per Viewer (log)",
"log_already_follow_other_fans_count" = "Opponent Followers Attracted by Focal (log)",
"log_other_already_follow_other_fans_count" = "Focal Followers Attracted by Opponent (log)",
"log_follow_author_fans_count" = "New Followers Gained (log)",
"log_unfollow_author_fans_count" = "Followers Lost (log)",
"log_net_follow_fans" = "Net Follower Gain (log)"
)
# Call the functions with your data and formula
plot_pct_change(data)
savesave <- function(p, var) {
ggsave(paste0("../2.Output/RANDOM_PK_", var, ".pdf"), plot = p, device = "pdf", width = 16, height = 9, units = "in")
ggsave(paste0("../2.Output/RANDOM_PK_", var, ".png"), plot = p, device = "png", width = 16, height = 9, dpi = 300, units = "in")
}
library(checkmate)
modelsummary_fun2 <- function(modp, export = FALSE, new_cate_name, cate_name) {
# Define the check_controls function
check_controls <- function(variables, yes = "YES", no = "NO") {
assert_character(variables, min.len = 1)
assert_string(no)
assert_string(yes)
reg <- paste0("^", paste(variables, collapse = "$|^"), "$")
fun <- function(model) {
est <- modelsummary::get_estimates(model)
df <- if (all(variables %in% est$term)) yes else no
df <- data.frame(Controls = df)
return(df)
}
list("fun" = fun, "regex" = reg)
}
control_vars <- c("factor(gender)M")
cc <- check_controls(control_vars)
# List of models
mod <- modp
# Specify the coefficients of interest
coef_interest <- c(
"factor(fan_size_pair)Small vs Big" = "Small vs Big",
"factor(fan_size_pair)Big vs Small" = "Big vs Small",
"factor(fan_size_pair)Big vs Big" = "Big vs Big",
"is_same_category" = "Same Category",
"factor(fan_size_pair)Small vs Big:is_same_category" = "Small vs Big * Same Category",
"factor(fan_size_pair)Big vs Small:is_same_category" = "Big vs Small * Same Category",
"factor(fan_size_pair)Big vs Big:is_same_category" = "Big vs Big * Same Category"
)
f <- function(x) format(round(x, 0), scientific=FALSE)
f2 <- function(x) format(round(x, 3), scientific=FALSE)
gm <- list(
list("raw" = "nobs", "clean" = "Obs", "fmt" = f),
list("raw" = "r.squared", "clean" = "R2", "fmt" = f2),
list("raw" = "Controls", "clean" = "Controls", "fmt" = f)
)
# Generate the summary table
modelsummary(
mod,
# fmt = 3,
# coef_omit = "^factor\\(gender\\)|^factor\\(age_range\\)",
coef_map = coef_interest,
# statistic = c("std.error"),
gof_map = gm,
# gof_omit = "^(AIC|BIC|Log.Lik|RMSE)",
stars = TRUE,
# title = "Regression Results",
# notes = "Standard errors in parentheses. * p < 0.1, ** p < 0.05, *** p < 0.01",
# output = "kableExtra",
gof_function = cc$fun
)
if (export == TRUE) {
title = paste0('The Dynamics Within Random PK Events: ', cate_name,
'\\label{tab:', new_cate_name, '}')
modelsummary(mod, coef_map = coef_interest, gof_map = gm, gof_function = cc$fun,
output = "latex", stars = c('+' = .1, '*' = .05, '**' = .01, '***' = .001),
title = title, escape = FALSE) |>
theme_tt("resize") |>
save_tt(paste0("../2.Output/", new_cate_name, ".tex"), overwrite = TRUE)
}
}
model1 <- feols(log_avg_viewer_total_cost_amt ~ factor(fan_size_pair)*is_same_category, data = data,vcov = ~ author_id)
model1_with_ctrls <- feols(log_avg_viewer_total_cost_amt ~ factor(fan_size_pair)*is_same_category + factor(gender) + factor(age_range) +
factor(fre_country_region) + factor(fre_city_level) + factor(year) + factor(month) + factor(day),
data = data, vcov = ~ author_id)
summary(model1)
## OLS estimation, Dep. Var.: log_avg_viewer_total_cost_amt
## Observations: 187,126
## Standard-errors: Clustered (author_id)
## Estimate Std. Error
## (Intercept) 0.470260 0.002684
## factor(fan_size_pair)Small vs Big 0.009908 0.006390
## factor(fan_size_pair)Big vs Small -0.008281 0.006238
## factor(fan_size_pair)Big vs Big 0.011619 0.012885
## is_same_category 0.001794 0.003678
## factor(fan_size_pair)Small vs Big:is_same_category -0.001770 0.008653
## factor(fan_size_pair)Big vs Small:is_same_category 0.001168 0.008562
## factor(fan_size_pair)Big vs Big:is_same_category -0.021913 0.017053
## t value Pr(>|t|)
## (Intercept) 175.234975 < 2.2e-16 ***
## factor(fan_size_pair)Small vs Big 1.550599 0.12100
## factor(fan_size_pair)Big vs Small -1.327602 0.18431
## factor(fan_size_pair)Big vs Big 0.901756 0.36719
## is_same_category 0.487631 0.62581
## factor(fan_size_pair)Small vs Big:is_same_category -0.204554 0.83792
## factor(fan_size_pair)Big vs Small:is_same_category 0.136381 0.89152
## factor(fan_size_pair)Big vs Big:is_same_category -1.285025 0.19879
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.649447 Adj. R2: 2.08e-5
summary(model1_with_ctrls)
## OLS estimation, Dep. Var.: log_avg_viewer_total_cost_amt
## Observations: 187,126
## Standard-errors: Clustered (author_id)
## Estimate Std. Error
## (Intercept) 0.459660 0.011095
## factor(fan_size_pair)Small vs Big 0.009785 0.006392
## factor(fan_size_pair)Big vs Small -0.008194 0.006238
## factor(fan_size_pair)Big vs Big 0.011584 0.012894
## is_same_category 0.001741 0.003679
## factor(gender)M 0.001321 0.002988
## factor(age_range)24-30 0.005539 0.004693
## factor(age_range)31-40 0.006604 0.004671
## factor(age_range)41-50 0.003155 0.004678
## factor(age_range)50+ 0.008544 0.004704
## factor(fre_country_region)南方 0.001119 0.002988
## factor(fre_city_level)三线城市 0.003142 0.004711
## factor(fre_city_level)二线城市 0.001761 0.004718
## factor(fre_city_level)四线及以下 -0.001886 0.004705
## factor(fre_city_level)新一线城市 0.001861 0.004759
## factor(year)2023 -0.002016 0.003462
## factor(year)2024 -0.002628 0.004089
## factor(month)2 -0.002279 0.007013
## factor(month)3 0.000667 0.006814
## factor(month)4 0.002968 0.006873
## factor(month)5 0.012139 0.006843
## factor(month)6 0.005706 0.006926
## factor(month)7 0.010371 0.006910
## factor(month)8 0.003726 0.006856
## factor(month)9 0.018304 0.007914
## factor(month)10 0.006103 0.007750
## factor(month)11 -0.006582 0.007674
## factor(month)12 0.006669 0.007839
## factor(day)2 -0.005646 0.011650
## factor(day)3 0.001427 0.011815
## factor(day)4 -0.007504 0.011711
## factor(day)5 0.006387 0.011882
## factor(day)6 0.000982 0.011879
## factor(day)7 0.002325 0.011724
## factor(day)8 -0.000844 0.011654
## factor(day)9 0.007675 0.011925
## factor(day)10 0.002196 0.011908
## factor(day)11 0.001301 0.011925
## factor(day)12 -0.004638 0.011572
## factor(day)13 -0.001137 0.011858
## factor(day)14 0.003682 0.011872
## factor(day)15 0.014661 0.012008
## factor(day)16 -0.000245 0.011664
## factor(day)17 -0.008684 0.011478
## factor(day)18 0.004330 0.011949
## factor(day)19 -0.017955 0.011476
## factor(day)20 0.020588 0.012055
## factor(day)21 -0.000265 0.011819
## factor(day)22 0.016187 0.011940
## factor(day)23 0.005404 0.011783
## factor(day)24 -0.003961 0.011725
## factor(day)25 -0.003933 0.011721
## factor(day)26 0.006052 0.011964
## factor(day)27 -0.013647 0.011503
## factor(day)28 0.000472 0.011759
## factor(day)29 -0.011947 0.011767
## factor(day)30 -0.006768 0.011877
## factor(day)31 0.003810 0.013886
## factor(fan_size_pair)Small vs Big:is_same_category -0.001571 0.008654
## factor(fan_size_pair)Big vs Small:is_same_category 0.001070 0.008562
## factor(fan_size_pair)Big vs Big:is_same_category -0.022180 0.017060
## t value Pr(>|t|)
## (Intercept) 41.430437 < 2.2e-16 ***
## factor(fan_size_pair)Small vs Big 1.530776 0.125828
## factor(fan_size_pair)Big vs Small -1.313511 0.189014
## factor(fan_size_pair)Big vs Big 0.898453 0.368946
## is_same_category 0.473189 0.636079
## factor(gender)M 0.442063 0.658444
## factor(age_range)24-30 1.180213 0.237919
## factor(age_range)31-40 1.413748 0.157439
## factor(age_range)41-50 0.674341 0.500096
## factor(age_range)50+ 1.816335 0.069322 .
## factor(fre_country_region)南方 0.374539 0.708004
## factor(fre_city_level)三线城市 0.667064 0.504733
## factor(fre_city_level)二线城市 0.373302 0.708925
## factor(fre_city_level)四线及以下 -0.400883 0.688507
## factor(fre_city_level)新一线城市 0.391050 0.695761
## factor(year)2023 -0.582254 0.560397
## factor(year)2024 -0.642740 0.520394
## factor(month)2 -0.324917 0.745245
## factor(month)3 0.097910 0.922004
## factor(month)4 0.431800 0.665888
## factor(month)5 1.774006 0.076066 .
## factor(month)6 0.823928 0.409983
## factor(month)7 1.500900 0.133385
## factor(month)8 0.543412 0.586848
## factor(month)9 2.312846 0.020733 *
## factor(month)10 0.787545 0.430965
## factor(month)11 -0.857741 0.391038
## factor(month)12 0.850750 0.394910
## factor(day)2 -0.484616 0.627950
## factor(day)3 0.120809 0.903842
## factor(day)4 -0.640811 0.521647
## factor(day)5 0.537506 0.590920
## factor(day)6 0.082627 0.934148
## factor(day)7 0.198333 0.842785
## factor(day)8 -0.072459 0.942236
## factor(day)9 0.643583 0.519848
## factor(day)10 0.184392 0.853707
## factor(day)11 0.109117 0.913110
## factor(day)12 -0.400828 0.688548
## factor(day)13 -0.095845 0.923644
## factor(day)14 0.310127 0.756465
## factor(day)15 1.220966 0.222102
## factor(day)16 -0.021021 0.983229
## factor(day)17 -0.756584 0.449301
## factor(day)18 0.362375 0.717073
## factor(day)19 -1.564650 0.117669
## factor(day)20 1.707833 0.087671 .
## factor(day)21 -0.022445 0.982093
## factor(day)22 1.355745 0.175184
## factor(day)23 0.458582 0.646535
## factor(day)24 -0.337832 0.735491
## factor(day)25 -0.335576 0.737191
## factor(day)26 0.505905 0.612924
## factor(day)27 -1.186403 0.235466
## factor(day)28 0.040127 0.967992
## factor(day)29 -1.015286 0.309972
## factor(day)30 -0.569807 0.568810
## factor(day)31 0.274350 0.783816
## factor(fan_size_pair)Small vs Big:is_same_category -0.181510 0.855968
## factor(fan_size_pair)Big vs Small:is_same_category 0.124913 0.900593
## factor(fan_size_pair)Big vs Big:is_same_category -1.300149 0.193553
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.649357 Adj. R2: 1.386e-5
modelsummary_fun2(modp = list("Avg Gifting per Follower (log)" = model1, "Avg Gifting per Follower (log)" = model1_with_ctrls),
export = TRUE, new_cate_name = "Random_PK_Gifting", cate_name = "Gifting")
## Warning: To compile a LaTeX document with this table, the following commands must be placed in the document preamble:
##
## \usepackage{tabularray}
## \usepackage{float}
## \usepackage{graphicx}
## \usepackage{codehigh}
## \usepackage[normalem]{ulem}
## \UseTblrLibrary{booktabs}
## \UseTblrLibrary{siunitx}
## \newcommand{\tinytableTabularrayUnderline}[1]{\underline{#1}}
## \newcommand{\tinytableTabularrayStrikeout}[1]{\sout{#1}}
## \NewTableCommand{\tinytableDefineColor}[3]{\definecolor{#1}{#2}{#3}}
##
## To disable `siunitx` and prevent `modelsummary` from wrapping numeric entries in `\num{}`, call:
##
## options("modelsummary_format_numeric_latex" = "plain")
## This warning appears once per session.
savesave(plot_predictions_with_ci(model1, data, "log_avg_viewer_total_cost_amt"), "log_avg_viewer_total_cost_amt")
model <- feols(log_avg_viewer_total_cost_amt ~ factor(fan_size_pair), data = data, vcov = ~author_id)
summary(model)
## OLS estimation, Dep. Var.: log_avg_viewer_total_cost_amt
## Observations: 187,126
## Standard-errors: Clustered (author_id)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.471230 0.001834 256.975646 < 2.2e-16 ***
## factor(fan_size_pair)Small vs Big 0.008951 0.004329 2.067666 0.038674 *
## factor(fan_size_pair)Big vs Small -0.007652 0.004251 -1.800107 0.071847 .
## factor(fan_size_pair)Big vs Big -0.000165 0.008448 -0.019492 0.984449
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.64945 Adj. R2: 3.247e-5
savesave(plot_predictions_fans(model, data, "log_avg_viewer_total_cost_amt"), "log_avg_viewer_total_cost_amt_fan_size_pair")
model <- feols(log_avg_viewer_total_cost_amt ~ is_same_category, data = data,vcov = ~author_id)
summary(model)
## OLS estimation, Dep. Var.: log_avg_viewer_total_cost_amt
## Observations: 187,126
## Standard-errors: Clustered (author_id)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.47089 0.002193 214.709423 < 2.2e-16 ***
## is_same_category 0.00101 0.003006 0.335948 0.73691
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.649465 Adj. R2: -4.744e-6
savesave(plot_predictions_cate(model, data, "log_avg_viewer_total_cost_amt"), "log_avg_viewer_total_cost_amt_is_same_category")
# plot_coefficients(data, "log_avg_viewer_total_cost_amt")
savesave(plot_coefficients(data, "log_avg_viewer_total_cost_amt"), "log_avg_viewer_total_cost_amt_evolution")
heatmap_plot <- plot_heatmap(
data = data,
y_var = "log_avg_viewer_total_cost_amt",
crs = crs,
limits = c(0, 0.2),
gradient_values = scales::rescale(c(0, 0.05, 0.1, 0.15, 0.2))
)
## Warning: There were 49 warnings in `summarize()`.
## The first warning was:
## ℹ In argument: `Y = ifelse(...)`.
## ℹ In group 1: `fans_new_range = "0-1k"` and `other_fans_new_range = "0-1k"`.
## Caused by warning in `mean.default()`:
## ! argument is not numeric or logical: returning NA
## ℹ Run `dplyr::last_dplyr_warnings()` to see the 48 remaining warnings.
savesave(heatmap_plot, "log_avg_viewer_total_cost_amt_heatmap")
# Display the plot
print(heatmap_plot)
model1 <- feols(log_already_follow_other_fans_count ~ factor(fan_size_pair)*is_same_category, data = data,vcov = ~ author_id)
model1_with_ctrls <- feols(log_already_follow_other_fans_count ~ factor(fan_size_pair)*is_same_category + factor(gender) + factor(age_range) +
factor(fre_country_region) + factor(fre_city_level) + factor(year) + factor(month) + factor(day),
data = data, vcov = ~ author_id)
summary(model1)
## OLS estimation, Dep. Var.: log_already_follow_other_fans_count
## Observations: 187,126
## Standard-errors: Clustered (author_id)
## Estimate Std. Error
## (Intercept) 5.227633 0.004090
## factor(fan_size_pair)Small vs Big -0.018633 0.009582
## factor(fan_size_pair)Big vs Small 0.001763 0.009475
## factor(fan_size_pair)Big vs Big 0.004946 0.018364
## is_same_category -0.006887 0.005548
## factor(fan_size_pair)Small vs Big:is_same_category 0.018953 0.013007
## factor(fan_size_pair)Big vs Small:is_same_category -0.003520 0.013025
## factor(fan_size_pair)Big vs Big:is_same_category -0.016802 0.025704
## t value Pr(>|t|)
## (Intercept) 1278.052776 < 2.2e-16 ***
## factor(fan_size_pair)Small vs Big -1.944629 0.051823 .
## factor(fan_size_pair)Big vs Small 0.186020 0.852429
## factor(fan_size_pair)Big vs Big 0.269339 0.787669
## is_same_category -1.241339 0.214484
## factor(fan_size_pair)Small vs Big:is_same_category 1.457109 0.145090
## factor(fan_size_pair)Big vs Small:is_same_category -0.270254 0.786966
## factor(fan_size_pair)Big vs Big:is_same_category -0.653695 0.513310
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.97812 Adj. R2: -5.307e-6
summary(model1_with_ctrls)
## OLS estimation, Dep. Var.: log_already_follow_other_fans_count
## Observations: 187,126
## Standard-errors: Clustered (author_id)
## Estimate Std. Error
## (Intercept) 5.216230 0.016750
## factor(fan_size_pair)Small vs Big -0.018570 0.009584
## factor(fan_size_pair)Big vs Small 0.001787 0.009478
## factor(fan_size_pair)Big vs Big 0.005406 0.018378
## is_same_category -0.006853 0.005549
## factor(gender)M -0.002072 0.004516
## factor(age_range)24-30 0.009756 0.007133
## factor(age_range)31-40 0.008581 0.007187
## factor(age_range)41-50 0.007757 0.007169
## factor(age_range)50+ 0.012802 0.007165
## factor(fre_country_region)南方 0.001324 0.004517
## factor(fre_city_level)三线城市 0.008437 0.007111
## factor(fre_city_level)二线城市 0.016758 0.007104
## factor(fre_city_level)四线及以下 0.004143 0.007231
## factor(fre_city_level)新一线城市 0.015524 0.007173
## factor(year)2023 -0.001670 0.005215
## factor(year)2024 0.004315 0.006156
## factor(month)2 -0.000713 0.010760
## factor(month)3 0.006635 0.010361
## factor(month)4 0.007387 0.010426
## factor(month)5 -0.004593 0.010430
## factor(month)6 -0.013888 0.010569
## factor(month)7 -0.005177 0.010356
## factor(month)8 -0.001834 0.010392
## factor(month)9 0.002540 0.011762
## factor(month)10 0.012512 0.011651
## factor(month)11 -0.006618 0.011967
## factor(month)12 0.001959 0.011832
## factor(day)2 -0.009970 0.017788
## factor(day)3 0.011673 0.017614
## factor(day)4 0.001716 0.017681
## factor(day)5 -0.001613 0.017631
## factor(day)6 -0.012544 0.017967
## factor(day)7 -0.011829 0.017715
## factor(day)8 -0.007139 0.017712
## factor(day)9 -0.022512 0.017645
## factor(day)10 -0.008537 0.017771
## factor(day)11 -0.001626 0.017737
## factor(day)12 -0.018950 0.017841
## factor(day)13 -0.001755 0.017812
## factor(day)14 -0.009622 0.017560
## factor(day)15 -0.015020 0.017822
## factor(day)16 0.017506 0.017493
## factor(day)17 -0.017901 0.017801
## factor(day)18 -0.007094 0.017763
## factor(day)19 -0.015219 0.017962
## factor(day)20 -0.039006 0.018054
## factor(day)21 0.013543 0.017675
## factor(day)22 0.007249 0.017804
## factor(day)23 -0.020845 0.017831
## factor(day)24 -0.011976 0.017712
## factor(day)25 0.003187 0.017692
## factor(day)26 0.009203 0.017843
## factor(day)27 0.003842 0.017435
## factor(day)28 0.005570 0.017466
## factor(day)29 0.003312 0.017847
## factor(day)30 -0.001327 0.018040
## factor(day)31 0.012903 0.020584
## factor(fan_size_pair)Small vs Big:is_same_category 0.018639 0.013010
## factor(fan_size_pair)Big vs Small:is_same_category -0.003535 0.013027
## factor(fan_size_pair)Big vs Big:is_same_category -0.017258 0.025715
## t value Pr(>|t|)
## (Intercept) 311.415778 < 2.2e-16 ***
## factor(fan_size_pair)Small vs Big -1.937585 0.052677 .
## factor(fan_size_pair)Big vs Small 0.188554 0.850443
## factor(fan_size_pair)Big vs Big 0.294176 0.768624
## is_same_category -1.235038 0.216819
## factor(gender)M -0.458761 0.646407
## factor(age_range)24-30 1.367734 0.171399
## factor(age_range)31-40 1.193811 0.232555
## factor(age_range)41-50 1.081955 0.279275
## factor(age_range)50+ 1.786714 0.073987 .
## factor(fre_country_region)南方 0.293055 0.769481
## factor(fre_city_level)三线城市 1.186421 0.235459
## factor(fre_city_level)二线城市 2.359093 0.018322 *
## factor(fre_city_level)四线及以下 0.572937 0.566689
## factor(fre_city_level)新一线城市 2.164046 0.030463 *
## factor(year)2023 -0.320234 0.748792
## factor(year)2024 0.700863 0.483390
## factor(month)2 -0.066288 0.947149
## factor(month)3 0.640409 0.521908
## factor(month)4 0.708551 0.478605
## factor(month)5 -0.440334 0.659696
## factor(month)6 -1.313991 0.188853
## factor(month)7 -0.499886 0.617157
## factor(month)8 -0.176478 0.859918
## factor(month)9 0.215974 0.829008
## factor(month)10 1.073870 0.282884
## factor(month)11 -0.552987 0.580274
## factor(month)12 0.165609 0.868465
## factor(day)2 -0.560465 0.575163
## factor(day)3 0.662726 0.507508
## factor(day)4 0.097029 0.922704
## factor(day)5 -0.091504 0.927093
## factor(day)6 -0.698129 0.485098
## factor(day)7 -0.667714 0.504318
## factor(day)8 -0.403065 0.686902
## factor(day)9 -1.275863 0.202007
## factor(day)10 -0.480392 0.630950
## factor(day)11 -0.091698 0.926938
## factor(day)12 -1.062136 0.288177
## factor(day)13 -0.098538 0.921505
## factor(day)14 -0.547921 0.583748
## factor(day)15 -0.842793 0.399347
## factor(day)16 1.000723 0.316963
## factor(day)17 -1.005646 0.314588
## factor(day)18 -0.399393 0.689605
## factor(day)19 -0.847325 0.396816
## factor(day)20 -2.160591 0.030730 *
## factor(day)21 0.766212 0.443552
## factor(day)22 0.407154 0.683896
## factor(day)23 -1.169076 0.242376
## factor(day)24 -0.676167 0.498936
## factor(day)25 0.180110 0.857067
## factor(day)26 0.515754 0.606028
## factor(day)27 0.220365 0.825587
## factor(day)28 0.318893 0.749808
## factor(day)29 0.185556 0.852793
## factor(day)30 -0.073563 0.941358
## factor(day)31 0.626846 0.530762
## factor(fan_size_pair)Small vs Big:is_same_category 1.432748 0.151933
## factor(fan_size_pair)Big vs Small:is_same_category -0.271369 0.786108
## factor(fan_size_pair)Big vs Big:is_same_category -0.671126 0.502142
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.977985 Adj. R2: -1.38e-5
savesave(plot_predictions_with_ci(model1, data, "log_already_follow_other_fans_count"), "log_already_follow_other_fans_count")
model <- feols(log_already_follow_other_fans_count ~ factor(fan_size_pair), data = data, vcov = ~author_id)
summary(model)
## OLS estimation, Dep. Var.: log_already_follow_other_fans_count
## Observations: 187,126
## Standard-errors: Clustered (author_id)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.223908 0.002766 1888.658443 < 2.2e-16
## factor(fan_size_pair)Small vs Big -0.008357 0.006460 -1.293617 0.19580
## factor(fan_size_pair)Big vs Small -0.000134 0.006455 -0.020828 0.98338
## factor(fan_size_pair)Big vs Big -0.004061 0.012878 -0.315366 0.75248
##
## (Intercept) ***
## factor(fan_size_pair)Small vs Big
## factor(fan_size_pair)Big vs Small
## factor(fan_size_pair)Big vs Big
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.978131 Adj. R2: -6.642e-6
savesave(plot_predictions_fans(model, data, "log_already_follow_other_fans_count"), "log_already_follow_other_fans_count_fan_size_pair")
model <- feols(log_already_follow_other_fans_count ~ is_same_category, data = data,vcov = ~author_id)
summary(model)
## OLS estimation, Dep. Var.: log_already_follow_other_fans_count
## Observations: 187,126
## Standard-errors: Clustered (author_id)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.225291 0.003335 1566.84379 < 2.2e-16 ***
## is_same_category -0.005133 0.004539 -1.13102 0.25805
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.978132 Adj. R2: 1.496e-6
savesave(plot_predictions_cate(model, data, "log_already_follow_other_fans_count"), "log_already_follow_other_fans_count_is_same_category")
# plot_coefficients(data, "log_already_follow_other_fans_count")
savesave(plot_coefficients(data, "log_already_follow_other_fans_count"), "log_already_follow_other_fans_count_evolution")
heatmap_plot <- plot_heatmap(
data = data,
y_var = "log_already_follow_other_fans_count",
crs = crs,
limits = c(0, 0.2),
gradient_values = scales::rescale(c(0, 0.05, 0.1, 0.15, 0.2))
)
## Warning: There were 49 warnings in `summarize()`.
## The first warning was:
## ℹ In argument: `Y = ifelse(...)`.
## ℹ In group 1: `fans_new_range = "0-1k"` and `other_fans_new_range = "0-1k"`.
## Caused by warning in `mean.default()`:
## ! argument is not numeric or logical: returning NA
## ℹ Run `dplyr::last_dplyr_warnings()` to see the 48 remaining warnings.
savesave(heatmap_plot, "log_already_follow_other_fans_count_heatmap")
# Display the plot
print(heatmap_plot)
model2 <- feols(log_other_already_follow_other_fans_count ~ factor(fan_size_pair)*is_same_category, data = data,vcov = ~ author_id)
model2_with_ctrls <- feols(log_other_already_follow_other_fans_count ~ factor(fan_size_pair)*is_same_category + factor(gender) + factor(age_range) +
factor(fre_country_region) + factor(fre_city_level) + factor(year) + factor(month) + factor(day),
data = data, vcov = ~ author_id)
summary(model2)
## OLS estimation, Dep. Var.: log_other_already_follow_other_fans_count
## Observations: 187,126
## Standard-errors: Clustered (author_id)
## Estimate Std. Error
## (Intercept) 2.163534 0.003321
## factor(fan_size_pair)Small vs Big -0.008899 0.007871
## factor(fan_size_pair)Big vs Small 0.000660 0.007860
## factor(fan_size_pair)Big vs Big 0.004671 0.015431
## is_same_category -0.002037 0.004515
## factor(fan_size_pair)Small vs Big:is_same_category 0.007078 0.010645
## factor(fan_size_pair)Big vs Small:is_same_category 0.002333 0.010667
## factor(fan_size_pair)Big vs Big:is_same_category 0.004649 0.020979
## t value Pr(>|t|)
## (Intercept) 651.403839 < 2.2e-16 ***
## factor(fan_size_pair)Small vs Big -1.130645 0.25821
## factor(fan_size_pair)Big vs Small 0.083923 0.93312
## factor(fan_size_pair)Big vs Big 0.302670 0.76214
## is_same_category -0.451126 0.65190
## factor(fan_size_pair)Small vs Big:is_same_category 0.664860 0.50614
## factor(fan_size_pair)Big vs Small:is_same_category 0.218704 0.82688
## factor(fan_size_pair)Big vs Big:is_same_category 0.221578 0.82464
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.796838 Adj. R2: -2.538e-5
summary(model2_with_ctrls)
## OLS estimation, Dep. Var.: log_other_already_follow_other_fans_count
## Observations: 187,126
## Standard-errors: Clustered (author_id)
## Estimate Std. Error
## (Intercept) 2.160585 0.013654
## factor(fan_size_pair)Small vs Big -0.008923 0.007874
## factor(fan_size_pair)Big vs Small 0.000699 0.007863
## factor(fan_size_pair)Big vs Big 0.004849 0.015428
## is_same_category -0.002082 0.004516
## factor(gender)M -0.000850 0.003688
## factor(age_range)24-30 -0.008124 0.005855
## factor(age_range)31-40 -0.015642 0.005866
## factor(age_range)41-50 -0.007195 0.005814
## factor(age_range)50+ -0.003790 0.005780
## factor(fre_country_region)南方 0.000778 0.003688
## factor(fre_city_level)三线城市 0.001196 0.005834
## factor(fre_city_level)二线城市 -0.000421 0.005838
## factor(fre_city_level)四线及以下 -0.005047 0.005841
## factor(fre_city_level)新一线城市 -0.004501 0.005792
## factor(year)2023 -0.004302 0.004243
## factor(year)2024 -0.004523 0.005008
## factor(month)2 0.006957 0.008723
## factor(month)3 -0.009822 0.008562
## factor(month)4 -0.000105 0.008547
## factor(month)5 0.015170 0.008465
## factor(month)6 0.007416 0.008566
## factor(month)7 -0.007786 0.008532
## factor(month)8 0.000573 0.008475
## factor(month)9 0.005322 0.009561
## factor(month)10 0.000051 0.009576
## factor(month)11 -0.008872 0.009764
## factor(month)12 -0.001875 0.009620
## factor(day)2 0.009008 0.014542
## factor(day)3 0.012432 0.014574
## factor(day)4 0.015182 0.014577
## factor(day)5 0.018243 0.014425
## factor(day)6 0.022262 0.014599
## factor(day)7 0.003942 0.014488
## factor(day)8 0.017435 0.014451
## factor(day)9 0.027219 0.014343
## factor(day)10 0.004497 0.014557
## factor(day)11 0.025349 0.014515
## factor(day)12 0.029043 0.014336
## factor(day)13 0.027809 0.014527
## factor(day)14 0.000211 0.014489
## factor(day)15 0.010081 0.014395
## factor(day)16 0.024264 0.014379
## factor(day)17 0.021957 0.014392
## factor(day)18 0.025801 0.014531
## factor(day)19 0.012930 0.014468
## factor(day)20 -0.002494 0.014480
## factor(day)21 0.007657 0.014577
## factor(day)22 0.010713 0.014439
## factor(day)23 -0.002800 0.014570
## factor(day)24 0.004733 0.014512
## factor(day)25 0.013718 0.014468
## factor(day)26 0.016845 0.014539
## factor(day)27 0.007398 0.014455
## factor(day)28 0.022973 0.014417
## factor(day)29 0.008317 0.014625
## factor(day)30 0.012516 0.014919
## factor(day)31 0.016533 0.016802
## factor(fan_size_pair)Small vs Big:is_same_category 0.007210 0.010649
## factor(fan_size_pair)Big vs Small:is_same_category 0.002381 0.010669
## factor(fan_size_pair)Big vs Big:is_same_category 0.004617 0.020975
## t value Pr(>|t|)
## (Intercept) 158.239932 < 2.2e-16 ***
## factor(fan_size_pair)Small vs Big -1.133183 0.2571403
## factor(fan_size_pair)Big vs Small 0.088885 0.9291732
## factor(fan_size_pair)Big vs Big 0.314297 0.7532961
## is_same_category -0.461034 0.6447751
## factor(gender)M -0.230456 0.8177380
## factor(age_range)24-30 -1.387454 0.1653068
## factor(age_range)31-40 -2.666382 0.0076686 **
## factor(age_range)41-50 -1.237543 0.2158889
## factor(age_range)50+ -0.655636 0.5120601
## factor(fre_country_region)南方 0.210824 0.8330248
## factor(fre_city_level)三线城市 0.204978 0.8375900
## factor(fre_city_level)二线城市 -0.072097 0.9425249
## factor(fre_city_level)四线及以下 -0.864086 0.3875428
## factor(fre_city_level)新一线城市 -0.777054 0.4371290
## factor(year)2023 -1.013784 0.3106888
## factor(year)2024 -0.903103 0.3664737
## factor(month)2 0.797527 0.4251470
## factor(month)3 -1.147072 0.2513547
## factor(month)4 -0.012342 0.9901529
## factor(month)5 1.791990 0.0731379 .
## factor(month)6 0.865730 0.3866407
## factor(month)7 -0.912638 0.3614357
## factor(month)8 0.067594 0.9461088
## factor(month)9 0.556618 0.5777898
## factor(month)10 0.005307 0.9957655
## factor(month)11 -0.908659 0.3635325
## factor(month)12 -0.194868 0.8454970
## factor(day)2 0.619468 0.5356097
## factor(day)3 0.853072 0.3936217
## factor(day)4 1.041535 0.2976300
## factor(day)5 1.264679 0.2059897
## factor(day)6 1.524882 0.1272921
## factor(day)7 0.272109 0.7855388
## factor(day)8 1.206473 0.2276385
## factor(day)9 1.897698 0.0577391 .
## factor(day)10 0.308901 0.7573976
## factor(day)11 1.746342 0.0807550 .
## factor(day)12 2.025835 0.0427846 *
## factor(day)13 1.914266 0.0555894 .
## factor(day)14 0.014585 0.9883635
## factor(day)15 0.700331 0.4837227
## factor(day)16 1.687440 0.0915222 .
## factor(day)17 1.525623 0.1271074
## factor(day)18 1.775609 0.0758008 .
## factor(day)19 0.893712 0.3714785
## factor(day)20 -0.172269 0.8632263
## factor(day)21 0.525274 0.5993939
## factor(day)22 0.741963 0.4581114
## factor(day)23 -0.192195 0.8475903
## factor(day)24 0.326134 0.7443239
## factor(day)25 0.948219 0.3430204
## factor(day)26 1.158587 0.2466275
## factor(day)27 0.511809 0.6087861
## factor(day)28 1.593501 0.1110514
## factor(day)29 0.568665 0.5695851
## factor(day)30 0.838930 0.4015110
## factor(day)31 0.983986 0.3251249
## factor(fan_size_pair)Small vs Big:is_same_category 0.677010 0.4984014
## factor(fan_size_pair)Big vs Small:is_same_category 0.223187 0.8233901
## factor(fan_size_pair)Big vs Big:is_same_category 0.220143 0.8257604
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.796728 Adj. R2: -3.125e-5
savesave(plot_predictions_with_ci(model1, data, "log_other_already_follow_other_fans_count"), "log_other_already_follow_other_fans_count")
model <- feols(log_other_already_follow_other_fans_count ~ factor(fan_size_pair), data = data, vcov = ~author_id)
summary(model)
## OLS estimation, Dep. Var.: log_other_already_follow_other_fans_count
## Observations: 187,126
## Standard-errors: Clustered (author_id)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.162432 0.002245 963.341095 < 2.2e-16 ***
## factor(fan_size_pair)Small vs Big -0.005061 0.005290 -0.956717 0.33871
## factor(fan_size_pair)Big vs Small 0.001921 0.005298 0.362613 0.71689
## factor(fan_size_pair)Big vs Big 0.007176 0.010479 0.684786 0.49348
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.796839 Adj. R2: -6.659e-6
savesave(plot_predictions_fans(model, data, "log_other_already_follow_other_fans_count"), "log_other_already_follow_other_fans_count_fan_size_pair")
model <- feols(log_other_already_follow_other_fans_count ~ is_same_category, data = data,vcov = ~author_id)
summary(model)
## OLS estimation, Dep. Var.: log_other_already_follow_other_fans_count
## Observations: 187,126
## Standard-errors: Clustered (author_id)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.162463 0.002729 792.538921 < 2.2e-16 ***
## is_same_category -0.000503 0.003704 -0.135823 0.89196
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.796843 Adj. R2: -5.245e-6
savesave(plot_predictions_cate(model, data, "log_other_already_follow_other_fans_count"), "log_other_already_follow_other_fans_count_is_same_category")
# plot_coefficients(data, "log_other_already_follow_other_fans_count")
savesave(plot_coefficients(data, "log_other_already_follow_other_fans_count"), "log_other_already_follow_other_fans_count_evolution")
heatmap_plot <- plot_heatmap(
data = data,
y_var = "log_other_already_follow_other_fans_count",
crs = crs,
limits = c(0, 0.2),
gradient_values = scales::rescale(c(0, 0.05, 0.1, 0.15, 0.2))
)
## Warning: There were 49 warnings in `summarize()`.
## The first warning was:
## ℹ In argument: `Y = ifelse(...)`.
## ℹ In group 1: `fans_new_range = "0-1k"` and `other_fans_new_range = "0-1k"`.
## Caused by warning in `mean.default()`:
## ! argument is not numeric or logical: returning NA
## ℹ Run `dplyr::last_dplyr_warnings()` to see the 48 remaining warnings.
savesave(heatmap_plot, "log_other_already_follow_other_fans_count_heatmap")
# Display the plot
print(heatmap_plot)
modelsummary_fun2(modp = list("Opponent Followers Attracted by Focal (log)" = model1,
"Opponent Followers Attracted by Focal (log)" = model1_with_ctrls,
"Focal Followers Attracted by Opponent (log)" = model2,
"Focal Followers Attracted by Opponent (log)" = model2_with_ctrls),
export = TRUE, new_cate_name = "Random_PK_Focal_Opponent_Followers", cate_name = "Focal and Opponent Followers")
model3 <- feols(log_net_follow_fans ~ factor(fan_size_pair)*is_same_category, data = data,vcov = ~ author_id)
model3_with_ctrls <- feols(log_net_follow_fans ~ factor(fan_size_pair)*is_same_category + factor(gender) + factor(age_range) +
factor(fre_country_region) + factor(fre_city_level) + factor(year) + factor(month) + factor(day),
data = data, vcov = ~ author_id)
summary(model1)
## OLS estimation, Dep. Var.: log_follow_author_fans_count
## Observations: 187,126
## Standard-errors: Clustered (author_id)
## Estimate Std. Error
## (Intercept) 5.909985 0.004093
## factor(fan_size_pair)Small vs Big 0.000669 0.009685
## factor(fan_size_pair)Big vs Small -0.009861 0.009781
## factor(fan_size_pair)Big vs Big 0.010622 0.019086
## is_same_category -0.001365 0.005563
## factor(fan_size_pair)Small vs Big:is_same_category 0.012254 0.013091
## factor(fan_size_pair)Big vs Small:is_same_category 0.031788 0.013227
## factor(fan_size_pair)Big vs Big:is_same_category 0.003250 0.025954
## t value Pr(>|t|)
## (Intercept) 1443.853705 < 2.2e-16 ***
## factor(fan_size_pair)Small vs Big 0.069085 0.94492
## factor(fan_size_pair)Big vs Small -1.008169 0.31338
## factor(fan_size_pair)Big vs Big 0.556540 0.57784
## is_same_category -0.245353 0.80618
## factor(fan_size_pair)Small vs Big:is_same_category 0.936077 0.34924
## factor(fan_size_pair)Big vs Small:is_same_category 2.403295 0.01625 *
## factor(fan_size_pair)Big vs Big:is_same_category 0.125239 0.90033
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.983732 Adj. R2: 1.692e-5
summary(model1_with_ctrls)
## OLS estimation, Dep. Var.: log_follow_author_fans_count
## Observations: 187,126
## Standard-errors: Clustered (author_id)
## Estimate Std. Error
## (Intercept) 5.944426 0.016519
## factor(fan_size_pair)Small vs Big 0.000713 0.009684
## factor(fan_size_pair)Big vs Small -0.009869 0.009781
## factor(fan_size_pair)Big vs Big 0.010787 0.019102
## is_same_category -0.001576 0.005562
## factor(gender)M 0.000278 0.004543
## factor(age_range)24-30 -0.006599 0.007218
## factor(age_range)31-40 -0.011723 0.007209
## factor(age_range)41-50 -0.003825 0.007182
## factor(age_range)50+ -0.003489 0.007161
## factor(fre_country_region)南方 -0.000577 0.004544
## factor(fre_city_level)三线城市 0.002085 0.007148
## factor(fre_city_level)二线城市 0.010355 0.007077
## factor(fre_city_level)四线及以下 -0.005573 0.007201
## factor(fre_city_level)新一线城市 -0.008550 0.007181
## factor(year)2023 -0.007819 0.005254
## factor(year)2024 -0.004071 0.006134
## factor(month)2 -0.004085 0.010723
## factor(month)3 -0.015259 0.010439
## factor(month)4 0.002432 0.010438
## factor(month)5 -0.010855 0.010423
## factor(month)6 -0.013031 0.010595
## factor(month)7 -0.011942 0.010387
## factor(month)8 -0.006952 0.010434
## factor(month)9 -0.010252 0.011879
## factor(month)10 -0.006466 0.011830
## factor(month)11 -0.002895 0.011983
## factor(month)12 -0.014740 0.011882
## factor(day)2 -0.017654 0.017539
## factor(day)3 -0.021666 0.017651
## factor(day)4 -0.011222 0.017665
## factor(day)5 -0.011155 0.017387
## factor(day)6 -0.018613 0.017736
## factor(day)7 -0.023071 0.017597
## factor(day)8 -0.028555 0.017756
## factor(day)9 -0.015045 0.017477
## factor(day)10 -0.015199 0.017730
## factor(day)11 -0.012984 0.017466
## factor(day)12 -0.007983 0.017533
## factor(day)13 -0.032047 0.017879
## factor(day)14 0.008836 0.017316
## factor(day)15 -0.004307 0.017504
## factor(day)16 -0.032786 0.017650
## factor(day)17 -0.051795 0.017950
## factor(day)18 -0.018201 0.017471
## factor(day)19 -0.024419 0.017668
## factor(day)20 -0.033598 0.017689
## factor(day)21 -0.016371 0.017554
## factor(day)22 -0.011560 0.017552
## factor(day)23 -0.035916 0.017809
## factor(day)24 -0.018570 0.017790
## factor(day)25 0.011506 0.017211
## factor(day)26 -0.015704 0.017688
## factor(day)27 0.000394 0.017274
## factor(day)28 -0.019172 0.017584
## factor(day)29 0.019892 0.017560
## factor(day)30 -0.038619 0.018449
## factor(day)31 -0.040824 0.020885
## factor(fan_size_pair)Small vs Big:is_same_category 0.012201 0.013089
## factor(fan_size_pair)Big vs Small:is_same_category 0.031971 0.013228
## factor(fan_size_pair)Big vs Big:is_same_category 0.003029 0.025968
## t value Pr(>|t|)
## (Intercept) 359.843394 < 2.2e-16 ***
## factor(fan_size_pair)Small vs Big 0.073587 0.941339
## factor(fan_size_pair)Big vs Small -1.009067 0.312945
## factor(fan_size_pair)Big vs Big 0.564713 0.572270
## is_same_category -0.283395 0.776874
## factor(gender)M 0.061167 0.951226
## factor(age_range)24-30 -0.914303 0.360560
## factor(age_range)31-40 -1.626222 0.103906
## factor(age_range)41-50 -0.532537 0.594355
## factor(age_range)50+ -0.487229 0.626097
## factor(fre_country_region)南方 -0.127024 0.898921
## factor(fre_city_level)三线城市 0.291665 0.770544
## factor(fre_city_level)二线城市 1.463221 0.143410
## factor(fre_city_level)四线及以下 -0.773910 0.438986
## factor(fre_city_level)新一线城市 -1.190674 0.233785
## factor(year)2023 -1.488149 0.136715
## factor(year)2024 -0.663681 0.506896
## factor(month)2 -0.380933 0.703254
## factor(month)3 -1.461729 0.143819
## factor(month)4 0.233003 0.815760
## factor(month)5 -1.041448 0.297670
## factor(month)6 -1.229966 0.218713
## factor(month)7 -1.149686 0.250276
## factor(month)8 -0.666303 0.505219
## factor(month)9 -0.863079 0.388096
## factor(month)10 -0.546612 0.584646
## factor(month)11 -0.241550 0.809130
## factor(month)12 -1.240539 0.214779
## factor(day)2 -1.006540 0.314159
## factor(day)3 -1.227483 0.219644
## factor(day)4 -0.635289 0.525241
## factor(day)5 -0.641544 0.521171
## factor(day)6 -1.049432 0.293982
## factor(day)7 -1.311073 0.189837
## factor(day)8 -1.608208 0.107793
## factor(day)9 -0.860850 0.389323
## factor(day)10 -0.857230 0.391320
## factor(day)11 -0.743391 0.457247
## factor(day)12 -0.455313 0.648885
## factor(day)13 -1.792448 0.073065 .
## factor(day)14 0.510302 0.609841
## factor(day)15 -0.246081 0.805620
## factor(day)16 -1.857615 0.063227 .
## factor(day)17 -2.885571 0.003908 **
## factor(day)18 -1.041772 0.297520
## factor(day)19 -1.382093 0.166946
## factor(day)20 -1.899312 0.057527 .
## factor(day)21 -0.932621 0.351018
## factor(day)22 -0.658592 0.510159
## factor(day)23 -2.016700 0.043730 *
## factor(day)24 -1.043883 0.296542
## factor(day)25 0.668549 0.503785
## factor(day)26 -0.887818 0.374641
## factor(day)27 0.022784 0.981822
## factor(day)28 -1.090331 0.275570
## factor(day)29 1.132804 0.257300
## factor(day)30 -2.093284 0.036327 *
## factor(day)31 -1.954717 0.050620 .
## factor(fan_size_pair)Small vs Big:is_same_category 0.932208 0.351232
## factor(fan_size_pair)Big vs Small:is_same_category 2.416946 0.015653 *
## factor(fan_size_pair)Big vs Big:is_same_category 0.116646 0.907141
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.983561 Adj. R2: 8.111e-5
savesave(plot_predictions_with_ci(model1, data, "log_net_follow_fans"), "log_net_follow_fans")
model <- feols(log_net_follow_fans ~ factor(fan_size_pair), data = data, vcov = ~author_id)
summary(model)
## OLS estimation, Dep. Var.: log_net_follow_fans
## Observations: 187,126
## Standard-errors: Clustered (author_id)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.097438 0.002115 2883.38827 < 2.2e-16 ***
## factor(fan_size_pair)Small vs Big 0.006493 0.004953 1.31086 0.18991
## factor(fan_size_pair)Big vs Small 0.005056 0.005016 1.00804 0.31344
## factor(fan_size_pair)Big vs Big 0.010465 0.009859 1.06141 0.28851
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.7497 Adj. R2: 6.323e-7
savesave(plot_predictions_fans(model, data, "log_net_follow_fans"), "log_net_follow_fans_fan_size_pair")
model <- feols(log_net_follow_fans ~ is_same_category, data = data,vcov = ~author_id)
summary(model)
## OLS estimation, Dep. Var.: log_net_follow_fans
## Observations: 187,126
## Standard-errors: Clustered (author_id)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.097481 0.002572 2370.80257 < 2.2e-16 ***
## is_same_category 0.003699 0.003493 1.05899 0.28961
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.749704 Adj. R2: 7.013e-7
savesave(plot_predictions_cate(model, data, "log_net_follow_fans"), "log_net_follow_fans_is_same_category")
# plot_coefficients(data, "log_net_follow_fans")
savesave(plot_coefficients(data, "log_net_follow_fans"), "log_net_follow_fans_evolution")
heatmap_plot <- plot_heatmap(
data = data,
y_var = "log_net_follow_fans",
crs = crs,
limits = c(0, 0.2),
gradient_values = scales::rescale(c(0, 0.05, 0.1, 0.15, 0.2))
)
## Warning: There were 49 warnings in `summarize()`.
## The first warning was:
## ℹ In argument: `Y = ifelse(...)`.
## ℹ In group 1: `fans_new_range = "0-1k"` and `other_fans_new_range = "0-1k"`.
## Caused by warning in `mean.default()`:
## ! argument is not numeric or logical: returning NA
## ℹ Run `dplyr::last_dplyr_warnings()` to see the 48 remaining warnings.
savesave(heatmap_plot, "log_net_follow_fans_heatmap")
# Display the plot
print(heatmap_plot)
modelsummary_fun2(modp = list("Gain" = model1,
"Gain" = model1_with_ctrls,
"Loss" = model2,
"Loss" = model2_with_ctrls,
"Net Gain" = model3,
"Net Gain" = model3_with_ctrls),
export = TRUE, new_cate_name = "Random_PK_Followers", cate_name = "Followers Dynamics (log)")