日志生成开始时间: 2025-09-09 16:57:59 


> # 加载必要的包
> library(dplyr)

> library(writexl)

> library(tidyr)

> library(stargazer)

> library(AER)

> #----------- 变量含义--------------
> # 变量名	变量定义
> # Score	主体学生的学业表现代理变量，即ln（10+主体学生学期标准分数）
> # GP_Score	主体学生的朋友的成绩平均值，即ln（10+朋友学生学期标准分数）
> # Rank	学生高考排名，即学生分数排名/考生总人数
> # Birth	学生户口所在地，城镇为1，否则取值0
> # Gender	学生性别，男性为1，女性为0
> # East	东部地区生源学生，取值为1，西部地区为0
> # Middle	中部地区生源学生，取值为1，西部地区为0
> # Northeast	东北地区生源学生，取值为1，西部地区为0
> # Edu	父母受教育程度，父母中有本科及以上学历者为1，否则为0
> # GP_Rank	朋友学生高考排名均值
> # GP_Birth	朋友学生户口所在地均值
> # GP_Gender	朋友学生性别均值
> # GP_East	朋友学生东部地区生源地均值
> # GP_Middle	朋友学生中部地区生源地均值
> # GP_Northeast	朋友学生东北地区生源地均值
> # GP_Edu	朋友学生父母受教育程度均值
> # School	学院虚拟变量
> # Grade	年级虚拟变量
> # Semester	学期虚拟变量
> # G2P_Score	主体学生的朋友的朋友（peers of peer）的成绩平均值
> # G2P_Rank	朋友的朋友学生高考排名均值
> # G2P_Birth	朋友的朋友学生户口所在地均值
> # G2P_Gender	朋友的朋友学生性别均值
> # G2P_East	朋友的朋友学生东部地区生源地均值
> # G2P_Middle	朋友的朋友学生中部地区生源地均值
> # G2P_Northeast	朋友的朋友学生东北地区生源地均值
> # G2P_Edu	朋友的朋友学生父母受教育程度均值
> # Stime	主体学生的学习时长代理变量
> # Present	主体学生的演讲代理变量
> # S_major	主体学生对所在专业的情感变量
> # S_school	主体学生对所在学校的情感变量
> 
> #------------自定义函数--------------
> # 定义一个函数，将指定列转换为因子
> # R中因子变量在回归模型中会被自动处理为虚拟变量
> convert_to_factors <- function(df) {
+   # 指定需要转换为因子的列名
+   factor_columns <- c("School", "Grade", "Semester")
+   # 遍历每个指定列名，并将其转换为因子
+   df[factor_columns] <- lapply(df[factor_columns], as.factor)
+   # 返回转换后的数据框
+   return(df)
+ }

> ################*表2 描述性统计*#################
> # 写入日志信息
> cat("################*表2 描述性统计*#################\n")
################*表2 描述性统计*#################

> # 导入数据
> workdata <- read.csv("C:/2024-00222+使用数据/table2.csv",header = T,as.is = T,stringsAsFactors = TRUE)

> # 计算描述性统计信息
> summary_stats <- workdata %>%
+   select(Score, GP_Score, Rank, Birth, Gender, East, Middle, Northeast, Edu,
+          GP_Rank, GP_Birth, GP_Gender, GP_East, GP_Middle, GP_Northeast, GP_Edu) %>%
+   summarise(
+     across(everything(), list(
+       样本量 = ~sum(!is.na(.)),
+       均值 = ~mean(., na.rm = TRUE),
+       标准差 = ~sd(., na.rm = TRUE),
+       P25 = ~quantile(., 0.25, na.rm = TRUE),
+       P50 = ~median(., na.rm = TRUE),
+       P75 = ~quantile(., 0.75, na.rm = TRUE)
+     ), .names = "{.col}_{.fn}")
+   )

> # 使用 pivot_longer，将宽格式的数据转换为长格式，以便每个变量的统计信息分行显示，将列名进行处理以避免分隔符冲突
> summary_stats_long <- summary_stats %>%
+   pivot_longer(
+     everything(),
+     names_to = c("变量名", ".value"),
+     names_pattern = "(.*)_(样本量|均值|标准差|P25|P50|P75)"
+   )

> # 将分析结果写入日志
> print(summary_stats_long)
# A tibble: 16 × 7
   变量名       样本量   均值 标准差      P25     P50    P75
   <chr>         <int>  <dbl>  <dbl>    <dbl>   <dbl>  <dbl>
 1 Score          6160 0.156  0.625  -0.180   0.254   0.590 
 2 GP_Score       6160 0.249  0.326   0.165   0.301   0.395 
 3 Rank           6160 0.0137 0.0231  0.00395 0.00774 0.0159
 4 Birth          6160 0.806  0.396   1       1       1     
 5 Gender         6160 0.319  0.466   0       0       1     
 6 East           6160 0.370  0.483   0       0       1     
 7 Middle         6160 0.232  0.422   0       0       0     
 8 Northeast      6160 0.0760 0.265   0       0       0     
 9 Edu            6160 0.451  0.498   0       0       1     
10 GP_Rank        6160 0.0132 0.0131  0.00838 0.0116  0.0150
11 GP_Birth       6160 0.776  0.218   0.689   0.783   1     
12 GP_Gender      6160 0.365  0.293   0.125   0.336   0.5   
13 GP_East        6160 0.353  0.245   0.25    0.341   0.444 
14 GP_Middle      6160 0.246  0.221   0.1     0.238   0.312 
15 GP_Northeast   6160 0.0690 0.136   0       0.0357  0.0833
16 GP_Edu         6160 0.416  0.266   0.283   0.379   0.5   

> # 导出汇总统计信息到 Excel 文件
> write_xlsx(summary_stats_long, path = "C:/2024-00222+日志文件/table2.xlsx")

> ################*表3 学业表现的同群效应*#################
> # 写入日志信息
> cat("################*表3 学业表现的同群效应*#################\n")
################*表3 学业表现的同群效应*#################

> # 导入数据
> workdata <- read.csv("C:/2024-00222+使用数据/table3.csv",header = T,as.is = T,stringsAsFactors = TRUE)

> # 使用函数转换指定的列为因子
> workdata <- convert_to_factors(workdata)

> # 单变量回归
> out.lm0 <- lm(Score ~ GP_Score, data = workdata)

> summary(out.lm0) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score, data = workdata)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.43136 -0.03120  0.01092  0.04260  0.15921 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  1.41500    0.05623   25.16   <2e-16 ***
GP_Score     0.38727    0.02417   16.02   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06255 on 6158 degrees of freedom
Multiple R-squared:  0.04003,	Adjusted R-squared:  0.03988 
F-statistic: 256.8 on 1 and 6158 DF,  p-value: < 2.2e-16


> # 主体学生特征控制变量和固定效应变量
> out.lmX <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester, data = workdata)

> summary(out.lmX) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester, data = workdata)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.41502 -0.03000  0.00885  0.04064  0.16569 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.627e+00  5.628e-02  28.901  < 2e-16 ***
GP_Score        2.981e-01  2.400e-02  12.423  < 2e-16 ***
Rank           -3.527e-01  3.453e-02 -10.214  < 2e-16 ***
Birth           5.704e-03  2.098e-03   2.719  0.00656 ** 
Gender         -2.875e-02  1.709e-03 -16.817  < 2e-16 ***
East            1.593e-02  1.885e-03   8.449  < 2e-16 ***
Middle          1.246e-02  2.143e-03   5.814 6.41e-09 ***
Northeast       7.580e-03  3.168e-03   2.393  0.01676 *  
Edu             2.609e-04  1.683e-03   0.155  0.87682    
School2        -1.798e-02  6.115e-03  -2.940  0.00330 ** 
School3        -4.783e-03  5.132e-03  -0.932  0.35131    
School4        -2.714e-02  6.424e-03  -4.225 2.42e-05 ***
School5        -3.282e-03  3.920e-03  -0.837  0.40251    
School6         2.586e-03  4.255e-03   0.608  0.54341    
School7        -2.208e-03  3.897e-03  -0.567  0.57099    
School8         2.469e-03  3.909e-03   0.632  0.52765    
School9        -1.251e-02  3.839e-03  -3.259  0.00113 ** 
School10       -5.329e-03  3.475e-03  -1.534  0.12519    
School11        5.493e-04  3.931e-03   0.140  0.88888    
School12       -6.066e-03  4.838e-03  -1.254  0.20996    
School13        2.396e-03  3.831e-03   0.625  0.53179    
School14       -7.027e-04  4.330e-03  -0.162  0.87110    
School15       -6.970e-03  4.032e-03  -1.729  0.08392 .  
School16       -8.841e-07  7.329e-03   0.000  0.99990    
School17        1.313e-03  4.640e-03   0.283  0.77717    
School18       -8.657e-03  4.125e-03  -2.099  0.03589 *  
School19       -2.228e-02  5.400e-03  -4.126 3.73e-05 ***
Grade2         -1.744e-03  1.854e-03  -0.941  0.34686    
Grade3         -1.461e-03  2.564e-03  -0.570  0.56892    
Semester151602  2.110e-04  4.937e-03   0.043  0.96592    
Semester161701 -4.898e-04  4.253e-03  -0.115  0.90831    
Semester161702 -2.756e-04  4.143e-03  -0.067  0.94697    
Semester171801  1.589e-03  4.098e-03   0.388  0.69825    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06022 on 6127 degrees of freedom
Multiple R-squared:  0.1145,	Adjusted R-squared:  0.1099 
F-statistic: 24.77 on 32 and 6127 DF,  p-value: < 2.2e-16


> # 朋友特征变量和固定效应变量
> out.lmXGX <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                   GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata)

> summary(out.lmXGX) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.41675 -0.03008  0.00890  0.04040  0.16520 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.613e+00  5.883e-02  27.426  < 2e-16 ***
GP_Score        3.041e-01  2.497e-02  12.178  < 2e-16 ***
Rank           -3.530e-01  3.456e-02 -10.215  < 2e-16 ***
Birth           5.773e-03  2.099e-03   2.750 0.005976 ** 
Gender         -2.837e-02  1.977e-03 -14.354  < 2e-16 ***
East            1.605e-02  1.890e-03   8.491  < 2e-16 ***
Middle          1.252e-02  2.146e-03   5.835 5.64e-09 ***
Northeast       7.690e-03  3.171e-03   2.425 0.015322 *  
Edu             3.151e-04  1.687e-03   0.187 0.851816    
School2        -1.818e-02  6.135e-03  -2.964 0.003048 ** 
School3        -4.337e-03  5.149e-03  -0.842 0.399696    
School4        -2.830e-02  6.449e-03  -4.389 1.16e-05 ***
School5        -3.928e-03  3.937e-03  -0.998 0.318518    
School6         1.648e-03  4.287e-03   0.384 0.700639    
School7        -2.568e-03  3.925e-03  -0.654 0.513052    
School8         1.717e-03  3.925e-03   0.438 0.661745    
School9        -1.271e-02  3.843e-03  -3.308 0.000945 ***
School10       -5.360e-03  3.483e-03  -1.539 0.123894    
School11        5.844e-05  3.948e-03   0.015 0.988192    
School12       -6.356e-03  4.863e-03  -1.307 0.191252    
School13        1.744e-03  3.876e-03   0.450 0.652777    
School14       -8.818e-04  4.353e-03  -0.203 0.839465    
School15       -7.410e-03  4.046e-03  -1.831 0.067111 .  
School16       -6.190e-04  7.342e-03  -0.084 0.932813    
School17        9.570e-04  4.652e-03   0.206 0.837007    
School18       -9.121e-03  4.149e-03  -2.198 0.027981 *  
School19       -2.189e-02  5.425e-03  -4.035 5.53e-05 ***
Grade2         -1.528e-03  1.857e-03  -0.823 0.410677    
Grade3         -1.377e-03  2.578e-03  -0.534 0.593429    
Semester151602  1.279e-04  4.948e-03   0.026 0.979380    
Semester161701 -2.970e-04  4.283e-03  -0.069 0.944705    
Semester161702  2.042e-04  4.202e-03   0.049 0.961239    
Semester171801  1.841e-03  4.148e-03   0.444 0.657139    
GP_Rank         6.275e-02  6.186e-02   1.014 0.310426    
GP_Birth        3.961e-03  3.975e-03   0.996 0.319112    
GP_Gender      -1.030e-03  3.254e-03  -0.317 0.751523    
GP_East        -6.106e-03  3.737e-03  -1.634 0.102294    
GP_Middle      -2.830e-03  4.092e-03  -0.692 0.489229    
GP_Northeast   -9.093e-03  6.179e-03  -1.472 0.141179    
GP_Edu         -2.419e-03  3.323e-03  -0.728 0.466654    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06022 on 6120 degrees of freedom
Multiple R-squared:  0.1155,	Adjusted R-squared:  0.1099 
F-statistic: 20.49 on 39 and 6120 DF,  p-value: < 2.2e-16


> # 表格输出
> stargazer(out.lm0, out.lmX, out.lmXGX,
+           type = "text", #输出显示为文本
+           omit = c("School", "Grade", "Semester", "GP_Rank", "GP_Birth", "GP_Gender", "GP_East",
+                    "GP_Middle", "GP_Northeast", "GP_Edu"), #隐藏不展示的变量
+           omit.stat = c("f", "ser", "adj.rsq"), #隐藏不展示的信息
+           dep.var.labels = "社交网络主体学生学业表现：Score", #因变量标签
+           title = "表3 学业表现的同群效应", #表格标题
+           add.lines = list(c("控制朋友特征变量", "NO", "NO", "YES"),
+                            c("固定效应", "NO", "YES", "YES")), #表格展示控制变量信息
+           digits = 3, #数据保留小数点后3位
+           out = "C:/2024-00222+日志文件/table3.html")

表3 学业表现的同群效应
==========================================
                  Dependent variable:     
             -----------------------------
                  社交网络主体学生学业表现：Score      
                (1)       (2)       (3)   
------------------------------------------
GP_Score     0.387***  0.298***  0.304*** 
              (0.024)   (0.024)   (0.025) 
                                          
Rank                   -0.353*** -0.353***
                        (0.035)   (0.035) 
                                          
Birth                  0.006***  0.006*** 
                        (0.002)   (0.002) 
                                          
Gender                 -0.029*** -0.028***
                        (0.002)   (0.002) 
                                          
East                   0.016***  0.016*** 
                        (0.002)   (0.002) 
                                          
Middle                 0.012***  0.013*** 
                        (0.002)   (0.002) 
                                          
Northeast               0.008**   0.008** 
                        (0.003)   (0.003) 
                                          
Edu                     0.0003    0.0003  
                        (0.002)   (0.002) 
                                          
Constant     1.415***  1.627***  1.613*** 
              (0.056)   (0.056)   (0.059) 
                                          
------------------------------------------
控制朋友特征变量        NO        NO        YES   
固定效应            NO        YES       YES   
Observations   6,160     6,160     6,160  
R2             0.040     0.115     0.115  
==========================================
Note:          *p<0.1; **p<0.05; ***p<0.01

> ################*表4 工具变量回归结果*#################
> # 写入日志信息
> cat("################*表4 工具变量回归结果*#################\n")
################*表4 工具变量回归结果*#################

> # 导入数据
> workdata <- read.csv("C:/2024-00222+使用数据/table4.csv",header = T,as.is = T,stringsAsFactors = TRUE)

> # 使用函数转换指定的列为因子
> workdata <- convert_to_factors(workdata)

> # 工具变量二阶段回归
> # 表格第一列IV:G^2X第一阶段回归
> ivreg1 <- ivreg(GP_Score ~ G2P_Rank+G2P_Birth+G2P_Gender+G2P_East+G2P_Middle+G2P_Northeast+G2P_Edu, data = workdata)

> GP_Score1 <- predict(ivreg1)

> # 表格第一列IV:G^2X第二阶段回归
> ivreg12 <- ivreg(Score ~ GP_Score1+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                    GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata)

> summary(ivreg12) # 回归原始结果输出

Call:
ivreg(formula = Score ~ GP_Score1 + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata)

Residuals:
      Min        1Q    Median        3Q       Max 
-0.427269 -0.030635  0.009241  0.040773  0.153533 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     0.8103882  0.2160892   3.750 0.000178 ***
GP_Score1       0.6492385  0.0925256   7.017 2.51e-12 ***
Rank           -0.3523079  0.0348441 -10.111  < 2e-16 ***
Birth           0.0057166  0.0021164   2.701 0.006929 ** 
Gender         -0.0291121  0.0019910 -14.622  < 2e-16 ***
East            0.0162194  0.0019054   8.512  < 2e-16 ***
Middle          0.0123167  0.0021635   5.693 1.31e-08 ***
Northeast       0.0074637  0.0031960   2.335 0.019560 *  
Edu             0.0002269  0.0017002   0.133 0.893825    
School2        -0.0256563  0.0061413  -4.178 2.99e-05 ***
School3        -0.0062025  0.0051882  -1.196 0.231934    
School4        -0.0328929  0.0064840  -5.073 4.03e-07 ***
School5        -0.0056521  0.0039733  -1.423 0.154925    
School6         0.0006784  0.0043214   0.157 0.875264    
School7        -0.0032250  0.0039566  -0.815 0.415047    
School8         0.0019842  0.0039562   0.502 0.616008    
School9        -0.0140234  0.0038722  -3.622 0.000295 ***
School10       -0.0074183  0.0035094  -2.114 0.034567 *  
School11        0.0001028  0.0039800   0.026 0.979395    
School12       -0.0089763  0.0048993  -1.832 0.066978 .  
School13        0.0003345  0.0039084   0.086 0.931790    
School14       -0.0018326  0.0043872  -0.418 0.676168    
School15       -0.0084359  0.0040776  -2.069 0.038603 *  
School16       -0.0011840  0.0074004  -0.160 0.872891    
School17        0.0012492  0.0046896   0.266 0.789957    
School18       -0.0109400  0.0041785  -2.618 0.008863 ** 
School19       -0.0251230  0.0054663  -4.596 4.39e-06 ***
Grade2         -0.0022454  0.0018719  -1.200 0.230363    
Grade3         -0.0024901  0.0025983  -0.958 0.337925    
Semester151602  0.0013173  0.0049866   0.264 0.791663    
Semester161701  0.0034157  0.0043325   0.788 0.430509    
Semester161702  0.0049478  0.0042438   1.166 0.243706    
Semester171801  0.0068643  0.0042123   1.630 0.103241    
GP_Rank        -0.0479566  0.0616614  -0.778 0.436752    
GP_Birth        0.0023006  0.0040035   0.575 0.565546    
GP_Gender      -0.0049071  0.0032699  -1.501 0.133492    
GP_East        -0.0037938  0.0037592  -1.009 0.312912    
GP_Middle      -0.0007876  0.0041202  -0.191 0.848411    
GP_Northeast   -0.0058593  0.0062256  -0.941 0.346662    
GP_Edu         -0.0013742  0.0033594  -0.409 0.682500    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.0607 on 6120 degrees of freedom
Multiple R-Squared: 0.1013,	Adjusted R-squared: 0.09556 
Wald test: 17.69 on 39 and 6120 DF,  p-value: < 2.2e-16 


> # 表格第二列IV:G^2Y第一阶段回归
> ivreg2 <- ivreg(GP_Score ~ G2P_Score, data = workdata)

> GP_Score2 <- predict(ivreg2)

> # 表格第二列IV:G^2Y第二阶段回归
> ivreg22 <- ivreg(Score ~ GP_Score2+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                    GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata)

> summary(ivreg22) # 回归原始结果输出

Call:
ivreg(formula = Score ~ GP_Score2 + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata)

Residuals:
      Min        1Q    Median        3Q       Max 
-0.426967 -0.030316  0.009081  0.041061  0.149509 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.5898110  0.1891899   8.403  < 2e-16 ***
GP_Score2       0.3156396  0.0810672   3.894 9.98e-05 ***
Rank           -0.3567423  0.0349342 -10.212  < 2e-16 ***
Birth           0.0054304  0.0021217   2.559 0.010509 *  
Gender         -0.0291641  0.0019967 -14.606  < 2e-16 ***
East            0.0162532  0.0019107   8.506  < 2e-16 ***
Middle          0.0125857  0.0021691   5.802 6.87e-09 ***
Northeast       0.0068805  0.0032053   2.147 0.031864 *  
Edu             0.0002087  0.0017049   0.122 0.902569    
School2        -0.0242666  0.0062101  -3.908 9.42e-05 ***
School3        -0.0060622  0.0052026  -1.165 0.243968    
School4        -0.0329649  0.0065096  -5.064 4.23e-07 ***
School5        -0.0043514  0.0039796  -1.093 0.274244    
School6         0.0011659  0.0043336   0.269 0.787913    
School7        -0.0026712  0.0039687  -0.673 0.500928    
School8         0.0017133  0.0039677   0.432 0.665890    
School9        -0.0133525  0.0038869  -3.435 0.000596 ***
School10       -0.0067793  0.0035185  -1.927 0.054056 .  
School11        0.0003183  0.0039913   0.080 0.936437    
School12       -0.0083189  0.0049125  -1.693 0.090428 .  
School13        0.0014791  0.0039193   0.377 0.705901    
School14       -0.0023319  0.0044000  -0.530 0.596136    
School15       -0.0081279  0.0040899  -1.987 0.046935 *  
School16       -0.0017037  0.0074205  -0.230 0.818415    
School17        0.0008717  0.0047021   0.185 0.852942    
School18       -0.0113456  0.0041898  -2.708 0.006789 ** 
School19       -0.0239452  0.0054809  -4.369 1.27e-05 ***
Grade2         -0.0021847  0.0018772  -1.164 0.244548    
Grade3         -0.0024583  0.0026060  -0.943 0.345538    
Semester151602  0.0016133  0.0050005   0.323 0.746995    
Semester161701  0.0010606  0.0043287   0.245 0.806451    
Semester161702  0.0031934  0.0042452   0.752 0.451933    
Semester171801  0.0032415  0.0041910   0.773 0.439289    
GP_Rank        -0.0450205  0.0618424  -0.728 0.466649    
GP_Birth        0.0027332  0.0040220   0.680 0.496813    
GP_Gender      -0.0082335  0.0032293  -2.550 0.010809 *  
GP_East        -0.0025662  0.0037658  -0.681 0.495608    
GP_Middle       0.0001564  0.0041286   0.038 0.969788    
GP_Northeast   -0.0064501  0.0062422  -1.033 0.301498    
GP_Edu         -0.0027983  0.0033602  -0.833 0.405006    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06087 on 6120 degrees of freedom
Multiple R-Squared: 0.09629,	Adjusted R-squared: 0.09053 
Wald test: 16.72 on 39 and 6120 DF,  p-value: < 2.2e-16 


> # 表格第三列IV:G^2X+G^2Y第一阶段回归
> ivreg3 <- ivreg(GP_Score ~ G2P_Score+G2P_Rank+G2P_Birth+G2P_Gender+G2P_East+G2P_Middle+G2P_Northeast+G2P_Edu, data = workdata)

> GP_Score3 <- predict(ivreg3)

> # 表格第三列IV:G^2X+G^2Y第二阶段回归
> ivreg32 <- ivreg(Score ~ GP_Score3+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                    GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata)

> summary(ivreg32) # 回归原始结果输出

Call:
ivreg(formula = Score ~ GP_Score3 + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata)

Residuals:
      Min        1Q    Median        3Q       Max 
-0.427849 -0.030601  0.009126  0.040762  0.152710 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.2732963  0.1689160   7.538 5.46e-14 ***
GP_Score3       0.4506517  0.0722605   6.236 4.77e-10 ***
Rank           -0.3544768  0.0348692 -10.166  < 2e-16 ***
Birth           0.0055966  0.0021179   2.643 0.008250 ** 
Gender         -0.0290666  0.0019929 -14.585  < 2e-16 ***
East            0.0162547  0.0019070   8.524  < 2e-16 ***
Middle          0.0123954  0.0021652   5.725 1.08e-08 ***
Northeast       0.0070183  0.0031985   2.194 0.028253 *  
Edu             0.0002319  0.0017016   0.136 0.891596    
School2        -0.0230803  0.0061823  -3.733 0.000191 ***
School3        -0.0060344  0.0051925  -1.162 0.245227    
School4        -0.0320856  0.0064968  -4.939 8.07e-07 ***
School5        -0.0049584  0.0039733  -1.248 0.212107    
School6         0.0010856  0.0043249   0.251 0.801806    
School7        -0.0026630  0.0039604  -0.672 0.501352    
School8         0.0017519  0.0039597   0.442 0.658194    
School9        -0.0132341  0.0038776  -3.413 0.000647 ***
School10       -0.0069774  0.0035116  -1.987 0.046970 *  
School11        0.0003653  0.0039835   0.092 0.926942    
School12       -0.0084497  0.0049029  -1.723 0.084865 .  
School13        0.0012328  0.0039104   0.315 0.752569    
School14       -0.0016369  0.0043934  -0.373 0.709473    
School15       -0.0080773  0.0040815  -1.979 0.047861 *  
School16       -0.0013029  0.0074066  -0.176 0.860368    
School17        0.0012057  0.0046936   0.257 0.797277    
School18       -0.0108711  0.0041828  -2.599 0.009372 ** 
School19       -0.0242145  0.0054696  -4.427 9.72e-06 ***
Grade2         -0.0022808  0.0018736  -1.217 0.223525    
Grade3         -0.0026350  0.0026011  -1.013 0.311073    
Semester151602  0.0010693  0.0049921   0.214 0.830399    
Semester161701  0.0021824  0.0043256   0.505 0.613910    
Semester161702  0.0041824  0.0042418   0.986 0.324174    
Semester171801  0.0048472  0.0041915   1.156 0.247544    
GP_Rank        -0.0435387  0.0617200  -0.705 0.480574    
GP_Birth        0.0030784  0.0040118   0.767 0.442916    
GP_Gender      -0.0060966  0.0032527  -1.874 0.060931 .  
GP_East        -0.0030264  0.0037591  -0.805 0.420805    
GP_Middle      -0.0005430  0.0041231  -0.132 0.895230    
GP_Northeast   -0.0063146  0.0062302  -1.014 0.310838    
GP_Edu         -0.0020219  0.0033575  -0.602 0.547053    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06076 on 6120 degrees of freedom
Multiple R-Squared: 0.09978,	Adjusted R-squared: 0.09404 
Wald test: 17.39 on 39 and 6120 DF,  p-value: < 2.2e-16 


> # 表格输出
> stargazer(ivreg12, ivreg22, ivreg32,
+           type = "text", #输出显示为文本
+           omit = c("Rank", "Birth", "Gender", "East", "Middle", "Northeast", "Edu",
+                    "School", "Grade", "Semester", "GP_Rank", "GP_Birth", "GP_Gender", "GP_East",
+                    "GP_Middle", "GP_Northeast", "GP_Edu"), #隐藏不展示的变量
+           omit.stat = c("f", "ser", "adj.rsq"), #隐藏不展示的信息
+           dep.var.labels = "社交网络主体学生学业表现：Score", #因变量标签
+           column.labels = c("IV:G2X","IV:G2Y","IV:G2X+G2Y"), #列标签
+           title = "表4 工具变量回归结果", #表格标题
+           add.lines = list(c("控制主体特征变量", "YES", "YES", "YES"),c("控制朋友特征变量", "YES", "YES", "YES"),
+                            c("固定效应", "YES", "YES", "YES")), #表格展示控制变量信息
+           digits = 3, #数据保留小数点后3位
+           out = "C:/2024-00222+日志文件/table4.html")

表4 工具变量回归结果
==========================================
                  Dependent variable:     
             -----------------------------
                  社交网络主体学生学业表现：Score      
              IV:G2X    IV:G2Y  IV:G2X+G2Y
                (1)      (2)       (3)    
------------------------------------------
GP_Score1    0.649***                     
              (0.093)                     
                                          
GP_Score2              0.316***           
                       (0.081)            
                                          
GP_Score3                        0.451*** 
                                 (0.072)  
                                          
Constant     0.810***  1.590***  1.273*** 
              (0.216)  (0.189)   (0.169)  
                                          
------------------------------------------
控制主体特征变量        YES      YES       YES    
控制朋友特征变量        YES      YES       YES    
固定效应            YES      YES       YES    
Observations   6,160    6,160     6,160   
R2             0.101    0.096     0.100   
==========================================
Note:          *p<0.1; **p<0.05; ***p<0.01

> ################*表5 考虑个体特征异质性后的同群效应影响*#################
> # 写入日志信息
> cat("################*表5 考虑个体特征异质性后的同群效应影响*#################\n")
################*表5 考虑个体特征异质性后的同群效应影响*#################

> # 导入数据
> workdata <- read.csv("C:/2024-00222+使用数据/table5.csv",header = T,as.is = T,stringsAsFactors = TRUE)

> # 使用函数转换指定的列为因子
> workdata <- convert_to_factors(workdata)

> # 按照高考排名分为较低认知和较高认知两组
> workdata_nceelow<-subset(workdata,Rank<median(Rank))

> workdata_nceehigh<-subset(workdata,Rank>=median(Rank))

> out.nceelow <- lm(Score ~ GP_Score+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                     GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_nceelow)

> summary(out.nceelow) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Birth + Gender + East + Middle + 
    Northeast + Edu + School + Grade + Semester + GP_Birth + 
    GP_Gender + GP_East + GP_Middle + GP_Northeast + GP_Edu, 
    data = workdata_nceelow)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.34951 -0.02799  0.00908  0.03974  0.16234 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.559e+00  8.216e-02  18.970  < 2e-16 ***
GP_Score        3.340e-01  3.498e-02   9.548  < 2e-16 ***
Birth           6.250e-04  2.832e-03   0.221  0.82533    
Gender         -2.909e-02  2.797e-03 -10.398  < 2e-16 ***
East            7.759e-03  2.855e-03   2.718  0.00660 ** 
Middle          6.574e-03  2.851e-03   2.306  0.02116 *  
Northeast       3.876e-03  3.444e-03   1.125  0.26049    
Edu            -1.402e-03  2.349e-03  -0.597  0.55065    
School2        -1.571e-02  8.464e-03  -1.856  0.06354 .  
School3         1.112e-02  6.236e-03   1.782  0.07479 .  
School4        -2.365e-02  8.965e-03  -2.637  0.00840 ** 
School5        -1.218e-03  4.947e-03  -0.246  0.80551    
School6         2.623e-03  5.687e-03   0.461  0.64473    
School7         2.385e-04  5.727e-03   0.042  0.96678    
School8         6.366e-03  5.439e-03   1.170  0.24190    
School9        -1.522e-02  5.154e-03  -2.952  0.00318 ** 
School10       -2.756e-03  4.325e-03  -0.637  0.52411    
School11        5.482e-03  5.880e-03   0.932  0.35123    
School12        1.848e-03  6.635e-03   0.279  0.78060    
School13        1.334e-02  5.954e-03   2.240  0.02515 *  
School14       -1.002e-03  5.387e-03  -0.186  0.85240    
School15        5.100e-03  5.612e-03   0.909  0.36355    
School16        9.190e-03  1.002e-02   0.917  0.35904    
School17        3.074e-03  6.201e-03   0.496  0.62011    
School18       -8.560e-04  5.190e-03  -0.165  0.86900    
School19       -1.628e-02  7.300e-03  -2.230  0.02582 *  
Grade2          6.224e-05  2.568e-03   0.024  0.98066    
Grade3          4.508e-04  3.663e-03   0.123  0.90206    
Semester151602 -2.453e-04  7.236e-03  -0.034  0.97296    
Semester161701 -5.513e-03  6.225e-03  -0.886  0.37595    
Semester161702 -7.810e-03  6.111e-03  -1.278  0.20133    
Semester171801 -4.963e-03  6.033e-03  -0.823  0.41081    
GP_Birth        1.332e-03  5.534e-03   0.241  0.80973    
GP_Gender       1.857e-03  4.716e-03   0.394  0.69375    
GP_East        -6.826e-03  5.395e-03  -1.265  0.20592    
GP_Middle      -1.034e-02  5.648e-03  -1.830  0.06731 .  
GP_Northeast   -5.403e-03  9.002e-03  -0.600  0.54839    
GP_Edu         -2.256e-03  4.772e-03  -0.473  0.63651    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.05924 on 3042 degrees of freedom
Multiple R-squared:  0.1091,	Adjusted R-squared:  0.09822 
F-statistic: 10.06 on 37 and 3042 DF,  p-value: < 2.2e-16


> out.nceehigh <- lm(Score ~ GP_Score+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                      GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_nceehigh)

> summary(out.nceehigh) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Birth + Gender + East + Middle + 
    Northeast + Edu + School + Grade + Semester + GP_Birth + 
    GP_Gender + GP_East + GP_Middle + GP_Northeast + GP_Edu, 
    data = workdata_nceehigh)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.40977 -0.03159  0.00843  0.04090  0.16332 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.6464356  0.0828940  19.862  < 2e-16 ***
GP_Score        0.2807472  0.0352349   7.968 2.26e-15 ***
Birth           0.0133118  0.0031556   4.219 2.53e-05 ***
Gender         -0.0271600  0.0028240  -9.617  < 2e-16 ***
East            0.0256860  0.0026356   9.746  < 2e-16 ***
Middle          0.0245695  0.0032440   7.574 4.78e-14 ***
Northeast      -0.0289073  0.0157675  -1.833 0.066848 .  
Edu             0.0004550  0.0024952   0.182 0.855333    
School2        -0.0212226  0.0091404  -2.322 0.020307 *  
School3        -0.0324446  0.0090431  -3.588 0.000339 ***
School4        -0.0343430  0.0095319  -3.603 0.000320 ***
School5        -0.0082672  0.0065474  -1.263 0.206803    
School6        -0.0026605  0.0067206  -0.396 0.692233    
School7        -0.0079887  0.0059237  -1.349 0.177571    
School8        -0.0032719  0.0060666  -0.539 0.589704    
School9        -0.0107551  0.0060656  -1.773 0.076304 .  
School10       -0.0074841  0.0059131  -1.266 0.205723    
School11       -0.0064213  0.0058990  -1.089 0.276445    
School12       -0.0180166  0.0074068  -2.432 0.015055 *  
School13       -0.0099230  0.0056996  -1.741 0.081787 .  
School14       -0.0006812  0.0074280  -0.092 0.926940    
School15       -0.0193155  0.0062084  -3.111 0.001881 ** 
School16       -0.0151226  0.0109895  -1.376 0.168893    
School17        0.0009193  0.0073001   0.126 0.899797    
School18       -0.0203460  0.0069199  -2.940 0.003304 ** 
School19       -0.0285099  0.0082911  -3.439 0.000593 ***
Grade2         -0.0040220  0.0027241  -1.476 0.139919    
Grade3         -0.0035278  0.0036653  -0.962 0.335880    
Semester151602  0.0001308  0.0067926   0.019 0.984641    
Semester161701  0.0024781  0.0059285   0.418 0.675970    
Semester161702  0.0056401  0.0058184   0.969 0.332439    
Semester171801  0.0068384  0.0057456   1.190 0.234066    
GP_Birth        0.0042168  0.0057567   0.733 0.463915    
GP_Gender      -0.0017899  0.0045182  -0.396 0.692013    
GP_East        -0.0074881  0.0052249  -1.433 0.151917    
GP_Middle       0.0052387  0.0058956   0.889 0.374302    
GP_Northeast   -0.0096257  0.0084781  -1.135 0.256313    
GP_Edu         -0.0019327  0.0046826  -0.413 0.679822    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06117 on 3042 degrees of freedom
Multiple R-squared:  0.1245,	Adjusted R-squared:  0.1138 
F-statistic: 11.69 on 37 and 3042 DF,  p-value: < 2.2e-16


> # 按照生源地区分为中西部和其他地区两组
> workdata_RegionMW<-subset(workdata,East==0&Northeast==0)

> workdata_RegionElse<-subset(workdata,East==1|Northeast==1)

> out.RegionMW <- lm(Score ~ GP_Score+Rank+Birth+Gender+Edu+School+Grade+Semester+
+                      GP_Rank+GP_Birth+GP_Gender+GP_Edu, data = workdata_RegionMW)

> summary(out.RegionMW) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + Edu + 
    School + Grade + Semester + GP_Rank + GP_Birth + GP_Gender + 
    GP_Edu, data = workdata_RegionMW)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.41220 -0.02952  0.00805  0.04031  0.15797 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.711e+00  8.106e-02  21.107  < 2e-16 ***
GP_Score        2.649e-01  3.430e-02   7.724 1.48e-14 ***
Rank           -4.317e-01  3.752e-02 -11.507  < 2e-16 ***
Birth           6.373e-03  2.705e-03   2.356  0.01852 *  
Gender         -3.275e-02  2.650e-03 -12.359  < 2e-16 ***
Edu            -1.243e-04  2.261e-03  -0.055  0.95617    
School2        -2.791e-02  8.552e-03  -3.263  0.00111 ** 
School3        -8.740e-03  7.135e-03  -1.225  0.22068    
School4        -3.092e-02  7.511e-03  -4.117 3.94e-05 ***
School5        -9.487e-03  5.408e-03  -1.754  0.07948 .  
School6        -4.020e-03  5.596e-03  -0.718  0.47260    
School7        -1.514e-02  5.312e-03  -2.849  0.00441 ** 
School8        -4.757e-03  5.171e-03  -0.920  0.35774    
School9        -1.150e-02  5.328e-03  -2.158  0.03098 *  
School10       -5.671e-03  4.890e-03  -1.160  0.24626    
School11        9.172e-04  5.326e-03   0.172  0.86327    
School12       -3.434e-03  6.312e-03  -0.544  0.58641    
School13        7.260e-04  5.235e-03   0.139  0.88970    
School14        4.714e-03  5.730e-03   0.823  0.41067    
School15       -2.989e-03  5.553e-03  -0.538  0.59042    
School16       -4.179e-03  8.942e-03  -0.467  0.64030    
School17        2.529e-04  6.174e-03   0.041  0.96733    
School18       -1.359e-02  5.556e-03  -2.446  0.01451 *  
School19       -1.602e-02  8.748e-03  -1.831  0.06714 .  
Grade2         -5.750e-03  2.460e-03  -2.337  0.01948 *  
Grade3         -1.650e-03  3.447e-03  -0.479  0.63222    
Semester151602 -3.073e-03  6.492e-03  -0.473  0.63593    
Semester161701 -3.174e-03  5.613e-03  -0.565  0.57184    
Semester161702 -3.148e-03  5.521e-03  -0.570  0.56858    
Semester171801 -9.051e-04  5.440e-03  -0.166  0.86786    
GP_Rank         1.711e-02  9.379e-02   0.182  0.85530    
GP_Birth        7.657e-03  5.405e-03   1.417  0.15669    
GP_Gender       1.551e-03  4.418e-03   0.351  0.72565    
GP_Edu          1.007e-05  4.478e-03   0.002  0.99820    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.05942 on 3377 degrees of freedom
Multiple R-squared:  0.1312,	Adjusted R-squared:  0.1227 
F-statistic: 15.46 on 33 and 3377 DF,  p-value: < 2.2e-16


> out.RegionENE <- lm(Score ~ GP_Score+Rank+Birth+Gender+Edu+School+Grade+Semester+
+                       GP_Rank+GP_Birth+GP_Gender+GP_Edu, data = workdata_RegionElse)

> summary(out.RegionENE) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + Edu + 
    School + Grade + Semester + GP_Rank + GP_Birth + GP_Gender + 
    GP_Edu, data = workdata_RegionElse)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.35144 -0.03014  0.00914  0.04190  0.14062 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.5171413  0.0856927  17.704  < 2e-16 ***
GP_Score        0.3507439  0.0363376   9.652  < 2e-16 ***
Rank           -0.1346208  0.0823894  -1.634  0.10238    
Birth           0.0014225  0.0033532   0.424  0.67144    
Gender         -0.0229332  0.0029946  -7.658  2.6e-14 ***
Edu            -0.0011616  0.0025902  -0.448  0.65387    
School2        -0.0069712  0.0088172  -0.791  0.42922    
School3         0.0011168  0.0074224   0.150  0.88041    
School4        -0.0301082  0.0130389  -2.309  0.02101 *  
School5        -0.0014659  0.0057532  -0.255  0.79890    
School6         0.0051850  0.0067353   0.770  0.44147    
School7         0.0107388  0.0059726   1.798  0.07229 .  
School8         0.0092319  0.0061495   1.501  0.13341    
School9        -0.0167155  0.0056092  -2.980  0.00291 ** 
School10       -0.0073968  0.0049849  -1.484  0.13797    
School11       -0.0026687  0.0059393  -0.449  0.65324    
School12       -0.0071174  0.0076832  -0.926  0.35434    
School13        0.0025127  0.0058160   0.432  0.66575    
School14       -0.0121992  0.0067923  -1.796  0.07260 .  
School15       -0.0151358  0.0059674  -2.536  0.01125 *  
School16        0.0056056  0.0130695   0.429  0.66802    
School17       -0.0027847  0.0071405  -0.390  0.69658    
School18       -0.0059349  0.0062416  -0.951  0.34176    
School19       -0.0218900  0.0069915  -3.131  0.00176 ** 
Grade2          0.0031734  0.0028573   1.111  0.26683    
Grade3         -0.0021722  0.0039020  -0.557  0.57778    
Semester151602  0.0028404  0.0076105   0.373  0.70901    
Semester161701  0.0026993  0.0065913   0.410  0.68218    
Semester161702  0.0034158  0.0064465   0.530  0.59625    
Semester171801  0.0049125  0.0063730   0.771  0.44088    
GP_Rank         0.1027103  0.0810125   1.268  0.20497    
GP_Birth       -0.0004395  0.0058837  -0.075  0.94046    
GP_Gender      -0.0046843  0.0048381  -0.968  0.33302    
GP_Edu         -0.0088712  0.0047553  -1.866  0.06221 .  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06112 on 2715 degrees of freedom
Multiple R-squared:  0.09912,	Adjusted R-squared:  0.08817 
F-statistic: 9.052 on 33 and 2715 DF,  p-value: < 2.2e-16


> # 表格输出
> stargazer(out.nceelow, out.nceehigh, out.RegionMW, out.RegionENE,
+           type = "text", #输出显示为文本
+           omit = c("Rank", "Birth", "Gender", "East", "Middle", "Northeast", "Edu",
+                    "School", "Grade", "Semester", "GP_Rank", "GP_Birth", "GP_Gender", "GP_East",
+                    "GP_Middle", "GP_Northeast", "GP_Edu"), #隐藏不展示的变量
+           omit.stat = c("f", "ser", "adj.rsq"), #隐藏不展示的信息
+           dep.var.labels = "社交网络主体学生学业表现：Score", #因变量标签
+           column.labels = c("较低认知","较高认知","中西部","其他地区"), #列标签
+           title = "表5 考虑个体特征异质性后的同群效应影响", #表格标题
+           add.lines = list(c("控制主体特征变量", "YES", "YES", "YES", "YES"),c("控制朋友特征变量", "YES", "YES", "YES", "YES"),
+                            c("固定效应", "YES", "YES", "YES", "YES")), #表格展示控制变量信息
+           digits = 3, #数据保留小数点后3位
+           out = "C:/2024-00222+日志文件/table5.html")

表5 考虑个体特征异质性后的同群效应影响
================================================
                     Dependent variable:        
             -----------------------------------
                     社交网络主体学生学业表现：Score         
               较低认知     较高认知     中西部      其他地区  
               (1)      (2)      (3)      (4)   
------------------------------------------------
GP_Score     0.334*** 0.281*** 0.265*** 0.351***
             (0.035)  (0.035)  (0.034)  (0.036) 
                                                
Constant     1.559*** 1.646*** 1.711*** 1.517***
             (0.082)  (0.083)  (0.081)  (0.086) 
                                                
------------------------------------------------
控制主体特征变量       YES      YES      YES      YES   
控制朋友特征变量       YES      YES      YES      YES   
固定效应           YES      YES      YES      YES   
Observations  3,080    3,080    3,411    2,749  
R2            0.109    0.124    0.131    0.099  
================================================
Note:                *p<0.1; **p<0.05; ***p<0.01

> ################*表6 考虑社交关系特征异质性后的同群效应影响*#################
> # 写入日志信息
> cat("################*表6 考虑社交关系特征异质性后的同群效应影响*#################\n")
################*表6 考虑社交关系特征异质性后的同群效应影响*#################

> # 导入数据
> workdata <- read.csv("C:/2024-00222+使用数据/table6.csv",header = T,as.is = T,stringsAsFactors = TRUE)

> # 使用函数转换指定的列为因子
> workdata <- convert_to_factors(workdata)

> # 按照长期朋友标记分为长期朋友和短期朋友两组
> workdata_long <- subset(workdata, LongTerm==1)

> workdata_short <- subset(workdata, LongTerm==0)

> # 按照高强度标记分为高社交强度和低社交强度两组
> workdata_high <- subset(workdata, HighInte==1)

> workdata_low <- subset(workdata, HighInte==0)

> # 分组回归
> out.long <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                  GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_long)

> summary(out.long) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_long)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.34797 -0.02946  0.00854  0.03971  0.14911 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.859e+00  6.062e-02  30.660  < 2e-16 ***
GP_Score        2.004e-01  2.577e-02   7.775 9.46e-15 ***
Rank           -3.640e-01  4.096e-02  -8.887  < 2e-16 ***
Birth           7.454e-03  2.458e-03   3.032 0.002443 ** 
Gender         -2.781e-02  2.465e-03 -11.283  < 2e-16 ***
East            1.722e-02  2.266e-03   7.598 3.70e-14 ***
Middle          1.286e-02  2.543e-03   5.057 4.45e-07 ***
Northeast       1.284e-02  3.749e-03   3.426 0.000619 ***
Edu            -2.663e-03  2.007e-03  -1.327 0.184719    
School2        -3.642e-02  8.184e-03  -4.450 8.81e-06 ***
School3        -1.710e-03  6.157e-03  -0.278 0.781183    
School4        -3.584e-02  7.469e-03  -4.799 1.65e-06 ***
School5        -1.222e-03  4.700e-03  -0.260 0.794917    
School6         4.201e-03  5.101e-03   0.824 0.410262    
School7        -8.162e-04  4.631e-03  -0.176 0.860099    
School8         3.417e-03  4.601e-03   0.743 0.457710    
School9        -9.675e-03  4.444e-03  -2.177 0.029514 *  
School10       -4.866e-03  4.075e-03  -1.194 0.232516    
School11       -1.123e-03  4.543e-03  -0.247 0.804841    
School12       -3.129e-03  5.771e-03  -0.542 0.587753    
School13        1.688e-03  4.494e-03   0.375 0.707310    
School14       -3.255e-03  5.223e-03  -0.623 0.533118    
School15       -5.347e-03  4.810e-03  -1.112 0.266349    
School16       -3.283e-03  8.974e-03  -0.366 0.714474    
School17        9.839e-03  6.067e-03   1.622 0.104942    
School18       -9.551e-03  5.020e-03  -1.903 0.057167 .  
School19       -1.713e-02  6.529e-03  -2.624 0.008710 ** 
Grade2         -2.927e-03  2.053e-03  -1.426 0.154059    
Semester151602 -5.775e-04  5.023e-03  -0.115 0.908470    
Semester161701 -1.215e-03  4.370e-03  -0.278 0.781062    
Semester161702  5.692e-05  4.296e-03   0.013 0.989431    
Semester171801  1.196e-03  4.326e-03   0.276 0.782249    
GP_Rank         1.318e-02  6.748e-02   0.195 0.845093    
GP_Birth        4.501e-03  4.130e-03   1.090 0.275817    
GP_Gender      -1.716e-03  3.572e-03  -0.480 0.630915    
GP_East        -6.153e-03  3.855e-03  -1.596 0.110510    
GP_Middle      -1.044e-02  4.152e-03  -2.516 0.011917 *  
GP_Northeast   -2.346e-02  6.905e-03  -3.397 0.000687 ***
GP_Edu         -2.678e-04  3.420e-03  -0.078 0.937595    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.05918 on 4184 degrees of freedom
Multiple R-squared:  0.1212,	Adjusted R-squared:  0.1132 
F-statistic: 15.19 on 38 and 4184 DF,  p-value: < 2.2e-16


> out.short <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                   GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_short)

> summary(out.short) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_short)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.42059 -0.02984  0.00926  0.04011  0.15695 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.8195063  0.0628361  28.956  < 2e-16 ***
GP_Score        0.2154059  0.0266375   8.087 7.51e-16 ***
Rank           -0.3563508  0.0352553 -10.108  < 2e-16 ***
Birth           0.0072106  0.0021877   3.296 0.000987 ***
Gender         -0.0302672  0.0018943 -15.978  < 2e-16 ***
East            0.0156923  0.0019816   7.919 2.88e-15 ***
Middle          0.0111762  0.0022413   4.986 6.34e-07 ***
Northeast       0.0083080  0.0033827   2.456 0.014081 *  
Edu             0.0008309  0.0017699   0.469 0.638766    
School2        -0.0199642  0.0065552  -3.046 0.002334 ** 
School3        -0.0092756  0.0054610  -1.699 0.089468 .  
School4        -0.0282641  0.0067667  -4.177 3.00e-05 ***
School5        -0.0054086  0.0040727  -1.328 0.184234    
School6        -0.0007363  0.0044077  -0.167 0.867337    
School7        -0.0039555  0.0041660  -0.949 0.342416    
School8        -0.0013295  0.0040828  -0.326 0.744721    
School9        -0.0122743  0.0040692  -3.016 0.002570 ** 
School10       -0.0066921  0.0036430  -1.837 0.066264 .  
School11       -0.0009025  0.0041430  -0.218 0.827564    
School12       -0.0074134  0.0050220  -1.476 0.139955    
School13        0.0046938  0.0040668   1.154 0.248481    
School14        0.0025132  0.0046940   0.535 0.592397    
School15       -0.0060291  0.0042571  -1.416 0.156766    
School16       -0.0032499  0.0079244  -0.410 0.681734    
School17       -0.0020908  0.0048451  -0.432 0.666098    
School18       -0.0123700  0.0043944  -2.815 0.004896 ** 
School19       -0.0257534  0.0057468  -4.481 7.57e-06 ***
Grade2         -0.0014161  0.0019763  -0.717 0.473691    
Grade3         -0.0033143  0.0026512  -1.250 0.211308    
Semester151602  0.0025535  0.0053135   0.481 0.630839    
Semester161701  0.0043727  0.0047148   0.927 0.353737    
Semester161702  0.0036077  0.0045872   0.786 0.431624    
Semester171801  0.0044363  0.0045403   0.977 0.328574    
GP_Rank         0.0334045  0.0691930   0.483 0.629277    
GP_Birth        0.0016207  0.0040255   0.403 0.687251    
GP_Gender      -0.0015623  0.0031517  -0.496 0.620113    
GP_East        -0.0032478  0.0038604  -0.841 0.400208    
GP_Middle       0.0016374  0.0041562   0.394 0.693617    
GP_Northeast   -0.0032977  0.0064444  -0.512 0.608873    
GP_Edu         -0.0023506  0.0033831  -0.695 0.487209    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.05953 on 5417 degrees of freedom
Multiple R-squared:  0.1059,	Adjusted R-squared:  0.09943 
F-statistic: 16.45 on 39 and 5417 DF,  p-value: < 2.2e-16


> out.high <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                  GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_high)

> summary(out.high) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_high)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.41124 -0.03010  0.00907  0.03969  0.17809 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.6613013  0.0529380  31.382  < 2e-16 ***
GP_Score        0.2842601  0.0224659  12.653  < 2e-16 ***
Rank           -0.3530443  0.0354281  -9.965  < 2e-16 ***
Birth           0.0047177  0.0021544   2.190 0.028579 *  
Gender         -0.0268938  0.0021640 -12.428  < 2e-16 ***
East            0.0169442  0.0019529   8.676  < 2e-16 ***
Middle          0.0130681  0.0022165   5.896 3.95e-09 ***
Northeast       0.0074001  0.0032911   2.249 0.024582 *  
Edu             0.0001636  0.0017456   0.094 0.925356    
School2        -0.0179031  0.0066832  -2.679 0.007410 ** 
School3        -0.0035662  0.0052923  -0.674 0.500433    
School4        -0.0252114  0.0066352  -3.800 0.000146 ***
School5        -0.0031856  0.0040399  -0.789 0.430425    
School6        -0.0001668  0.0044314  -0.038 0.969967    
School7        -0.0020257  0.0041245  -0.491 0.623341    
School8         0.0015944  0.0040540   0.393 0.694115    
School9        -0.0105297  0.0039609  -2.658 0.007873 ** 
School10       -0.0054590  0.0036042  -1.515 0.129926    
School11        0.0003536  0.0040957   0.086 0.931197    
School12       -0.0034346  0.0050669  -0.678 0.497897    
School13        0.0023558  0.0040175   0.586 0.557638    
School14       -0.0005720  0.0045279  -0.126 0.899477    
School15       -0.0028300  0.0042041  -0.673 0.500868    
School16       -0.0057330  0.0077360  -0.741 0.458671    
School17        0.0019886  0.0047957   0.415 0.678412    
School18       -0.0098742  0.0043176  -2.287 0.022236 *  
School19       -0.0216119  0.0055400  -3.901 9.69e-05 ***
Grade2         -0.0018561  0.0019317  -0.961 0.336671    
Grade3         -0.0026050  0.0026612  -0.979 0.327684    
Semester151602  0.0006234  0.0051395   0.121 0.903458    
Semester161701  0.0005074  0.0044617   0.114 0.909464    
Semester161702  0.0022743  0.0043784   0.519 0.603475    
Semester171801  0.0024482  0.0043279   0.566 0.571637    
GP_Rank        -0.0087758  0.0615962  -0.142 0.886712    
GP_Birth        0.0041068  0.0036323   1.131 0.258261    
GP_Gender      -0.0029741  0.0031473  -0.945 0.344718    
GP_East        -0.0042839  0.0033188  -1.291 0.196828    
GP_Middle      -0.0091198  0.0036576  -2.493 0.012682 *  
GP_Northeast   -0.0034110  0.0057354  -0.595 0.552048    
GP_Edu         -0.0016109  0.0029105  -0.553 0.579965    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.05919 on 5528 degrees of freedom
Multiple R-squared:  0.1233,	Adjusted R-squared:  0.1171 
F-statistic: 19.94 on 39 and 5528 DF,  p-value: < 2.2e-16


> out.low <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                 GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_low)

> summary(out.low) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_low)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.34749 -0.02931  0.00912  0.03968  0.14128 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     2.1149276  0.0638991  33.098  < 2e-16 ***
GP_Score        0.0900254  0.0271928   3.311 0.000937 ***
Rank           -0.3552476  0.0351514 -10.106  < 2e-16 ***
Birth           0.0080657  0.0021676   3.721 0.000201 ***
Gender         -0.0291036  0.0018483 -15.746  < 2e-16 ***
East            0.0153623  0.0019914   7.714 1.44e-14 ***
Middle          0.0105337  0.0022380   4.707 2.58e-06 ***
Northeast       0.0117793  0.0033737   3.492 0.000484 ***
Edu            -0.0002435  0.0017745  -0.137 0.890877    
School2        -0.0232639  0.0066682  -3.489 0.000489 ***
School3        -0.0053455  0.0053392  -1.001 0.316785    
School4        -0.0309651  0.0066016  -4.691 2.79e-06 ***
School5        -0.0033557  0.0041179  -0.815 0.415162    
School6         0.0025840  0.0044006   0.587 0.557092    
School7        -0.0025582  0.0041826  -0.612 0.540809    
School8         0.0009675  0.0040427   0.239 0.810865    
School9        -0.0103475  0.0040258  -2.570 0.010188 *  
School10       -0.0067054  0.0036055  -1.860 0.062974 .  
School11        0.0003748  0.0041244   0.091 0.927600    
School12       -0.0101576  0.0049494  -2.052 0.040189 *  
School13        0.0042258  0.0040156   1.052 0.292697    
School14        0.0048121  0.0047348   1.016 0.309520    
School15       -0.0052907  0.0042640  -1.241 0.214738    
School16       -0.0020910  0.0080506  -0.260 0.795080    
School17       -0.0007724  0.0049813  -0.155 0.876781    
School18       -0.0086938  0.0044298  -1.963 0.049749 *  
School19       -0.0248874  0.0057536  -4.326 1.55e-05 ***
Grade2         -0.0014915  0.0019536  -0.763 0.445233    
Grade3         -0.0010058  0.0027826  -0.361 0.717777    
Semester151602 -0.0001792  0.0050101  -0.036 0.971464    
Semester161701  0.0009091  0.0044180   0.206 0.836970    
Semester161702 -0.0001544  0.0043094  -0.036 0.971424    
Semester171801  0.0028765  0.0042942   0.670 0.502985    
GP_Rank         0.0369404  0.0783346   0.472 0.637252    
GP_Birth       -0.0011979  0.0041269  -0.290 0.771628    
GP_Gender      -0.0012265  0.0031874  -0.385 0.700404    
GP_East        -0.0018757  0.0038847  -0.483 0.629233    
GP_Middle       0.0006217  0.0041766   0.149 0.881676    
GP_Northeast   -0.0072694  0.0063364  -1.147 0.251338    
GP_Edu         -0.0013679  0.0034527  -0.396 0.691984    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.05874 on 5257 degrees of freedom
Multiple R-squared:  0.0927,	Adjusted R-squared:  0.08596 
F-statistic: 13.77 on 39 and 5257 DF,  p-value: < 2.2e-16


> # 表格输出
> stargazer(out.long, out.short, out.high, out.low,
+           type = "text", #输出显示为文本
+           omit = c("Rank", "Birth", "Gender", "East", "Middle", "Northeast", "Edu",
+                    "School", "Grade", "Semester", "GP_Rank", "GP_Birth", "GP_Gender", "GP_East",
+                    "GP_Middle", "GP_Northeast", "GP_Edu"), #隐藏不展示的变量
+           omit.stat = c("f", "ser", "adj.rsq"), #隐藏不展示的信息
+           dep.var.labels = "社交网络主体学生学业表现：Score", #因变量标签
+           column.labels = c("长期朋友","短期朋友","高社交强度","低社交强度"), #列标签
+           title = "表6 考虑社交关系特征异质性后的同群效应影响", #表格标题
+           add.lines = list(c("控制主体特征变量", "YES", "YES", "YES", "YES"),c("控制朋友特征变量", "YES", "YES", "YES", "YES"),
+                            c("固定效应", "YES", "YES", "YES", "YES")), #表格展示控制变量信息
+           digits = 3, #数据保留小数点后3位
+           out = "C:/2024-00222+日志文件/table6.html")

表6 考虑社交关系特征异质性后的同群效应影响
================================================
                     Dependent variable:        
             -----------------------------------
                     社交网络主体学生学业表现：Score         
               长期朋友     短期朋友    高社交强度    低社交强度  
               (1)      (2)      (3)      (4)   
------------------------------------------------
GP_Score     0.200*** 0.215*** 0.284*** 0.090***
             (0.026)  (0.027)  (0.022)  (0.027) 
                                                
Constant     1.859*** 1.820*** 1.661*** 2.115***
             (0.061)  (0.063)  (0.053)  (0.064) 
                                                
------------------------------------------------
控制主体特征变量       YES      YES      YES      YES   
控制朋友特征变量       YES      YES      YES      YES   
固定效应           YES      YES      YES      YES   
Observations  4,223    5,457    5,568    5,297  
R2            0.121    0.106    0.123    0.093  
================================================
Note:                *p<0.1; **p<0.05; ***p<0.01

> ################*表7 时间窗口设定为10分钟的社交网络同群效应影响*#################
> # 写入日志信息
> cat("################*表7 时间窗口设定为10分钟的社交网络同群效应影响*#################\n")
################*表7 时间窗口设定为10分钟的社交网络同群效应影响*#################

> # 导入数据
> workdata <- read.csv("C:/2024-00222+使用数据/table7.csv",header = T,as.is = T,stringsAsFactors = TRUE)

> # 使用函数转换指定的列为因子
> workdata <- convert_to_factors(workdata)

> # 单变量回归
> out.lm0_10mins <- lm(Score ~ GP_Score, data = workdata)

> summary(out.lm0_10mins) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score, data = workdata)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.44558 -0.03072  0.00972  0.04215  0.17810 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  1.47538    0.05872   25.12   <2e-16 ***
GP_Score     0.36185    0.02521   14.35   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.0614 on 5596 degrees of freedom
Multiple R-squared:  0.03551,	Adjusted R-squared:  0.03533 
F-statistic:   206 on 1 and 5596 DF,  p-value: < 2.2e-16


> # 控制主体特征变量和固定效应变量
> out.lmX_10mins <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester, data = workdata)

> summary(out.lmX_10mins) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester, data = workdata)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.42776 -0.02970  0.00874  0.03951  0.17583 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.6629219  0.0586171  28.369  < 2e-16 ***
GP_Score        0.2825559  0.0250091  11.298  < 2e-16 ***
Rank           -0.3642356  0.0363543 -10.019  < 2e-16 ***
Birth           0.0055445  0.0021405   2.590 0.009614 ** 
Gender         -0.0285609  0.0017532 -16.291  < 2e-16 ***
East            0.0157139  0.0019442   8.082 7.72e-16 ***
Middle          0.0117659  0.0021971   5.355 8.90e-08 ***
Northeast       0.0080602  0.0033120   2.434 0.014980 *  
Edu             0.0008935  0.0017320   0.516 0.605948    
School2        -0.0236015  0.0066323  -3.559 0.000376 ***
School3        -0.0052446  0.0052173  -1.005 0.314824    
School4        -0.0247766  0.0065722  -3.770 0.000165 ***
School5        -0.0037994  0.0039937  -0.951 0.341478    
School6         0.0020268  0.0043369   0.467 0.640275    
School7        -0.0024435  0.0040549  -0.603 0.546793    
School8         0.0012710  0.0039636   0.321 0.748472    
School9        -0.0111767  0.0039185  -2.852 0.004356 ** 
School10       -0.0054371  0.0035544  -1.530 0.126150    
School11        0.0003920  0.0040243   0.097 0.922412    
School12       -0.0090108  0.0049440  -1.823 0.068421 .  
School13        0.0024062  0.0039111   0.615 0.538436    
School14       -0.0022922  0.0044076  -0.520 0.603043    
School15       -0.0031172  0.0041590  -0.750 0.453577    
School16       -0.0046642  0.0075862  -0.615 0.538698    
School17       -0.0001522  0.0047101  -0.032 0.974218    
School18       -0.0094747  0.0042877  -2.210 0.027164 *  
School19       -0.0245171  0.0055437  -4.423 9.94e-06 ***
Grade2         -0.0013163  0.0019178  -0.686 0.492533    
Grade3         -0.0032720  0.0026620  -1.229 0.219070    
Semester151602  0.0007028  0.0049468   0.142 0.887022    
Semester161701  0.0009485  0.0042607   0.223 0.823834    
Semester161702  0.0006883  0.0041477   0.166 0.868211    
Semester171801  0.0046335  0.0041186   1.125 0.260631    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.05903 on 5565 degrees of freedom
Multiple R-squared:  0.1135,	Adjusted R-squared:  0.1084 
F-statistic: 22.26 on 32 and 5565 DF,  p-value: < 2.2e-16


> # 控制主体特征变量、朋友特征变量和固定效应变量
> out.lmXGX_10mins <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                          GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata)

> summary(out.lmXGX_10mins) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.43053 -0.02959  0.00859  0.03981  0.17972 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.656e+00  6.097e-02  27.165  < 2e-16 ***
GP_Score        2.879e-01  2.594e-02  11.099  < 2e-16 ***
Rank           -3.638e-01  3.637e-02 -10.004  < 2e-16 ***
Birth           5.650e-03  2.142e-03   2.638 0.008366 ** 
Gender         -2.760e-02  1.976e-03 -13.970  < 2e-16 ***
East            1.575e-02  1.948e-03   8.086 7.53e-16 ***
Middle          1.183e-02  2.197e-03   5.385 7.56e-08 ***
Northeast       8.283e-03  3.314e-03   2.499 0.012475 *  
Edu             1.054e-03  1.735e-03   0.607 0.543601    
School2        -2.278e-02  6.641e-03  -3.431 0.000607 ***
School3        -4.657e-03  5.232e-03  -0.890 0.373460    
School4        -2.554e-02  6.591e-03  -3.874 0.000108 ***
School5        -4.437e-03  4.007e-03  -1.107 0.268186    
School6         1.326e-03  4.352e-03   0.305 0.760560    
School7        -2.416e-03  4.078e-03  -0.592 0.553662    
School8         7.856e-04  3.978e-03   0.197 0.843476    
School9        -1.147e-02  3.926e-03  -2.921 0.003504 ** 
School10       -5.671e-03  3.558e-03  -1.594 0.111006    
School11       -5.399e-05  4.046e-03  -0.013 0.989353    
School12       -9.044e-03  4.953e-03  -1.826 0.067884 .  
School13        1.872e-03  3.963e-03   0.472 0.636646    
School14       -2.513e-03  4.423e-03  -0.568 0.569914    
School15       -3.386e-03  4.169e-03  -0.812 0.416674    
School16       -5.765e-03  7.602e-03  -0.758 0.448299    
School17       -5.081e-04  4.718e-03  -0.108 0.914244    
School18       -1.011e-02  4.305e-03  -2.350 0.018829 *  
School19       -2.362e-02  5.569e-03  -4.241 2.26e-05 ***
Grade2         -1.163e-03  1.920e-03  -0.606 0.544623    
Grade3         -3.354e-03  2.679e-03  -1.252 0.210597    
Semester151602  6.752e-04  4.952e-03   0.136 0.891563    
Semester161701  1.644e-03  4.294e-03   0.383 0.701892    
Semester161702  2.042e-03  4.224e-03   0.483 0.628821    
Semester171801  5.220e-03  4.180e-03   1.249 0.211732    
GP_Rank         9.360e-02  7.147e-02   1.310 0.190351    
GP_Birth       -1.558e-03  4.078e-03  -0.382 0.702362    
GP_Gender      -3.225e-03  3.303e-03  -0.976 0.328958    
GP_East        -9.279e-03  3.825e-03  -2.426 0.015318 *  
GP_Middle      -9.342e-03  4.267e-03  -2.189 0.028615 *  
GP_Northeast   -7.365e-03  6.680e-03  -1.102 0.270323    
GP_Edu          1.200e-03  3.402e-03   0.353 0.724420    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.05901 on 5558 degrees of freedom
Multiple R-squared:  0.1152,	Adjusted R-squared:  0.109 
F-statistic: 18.56 on 39 and 5558 DF,  p-value: < 2.2e-16


> # 表格输出
> stargazer(out.lm0_10mins, out.lmX_10mins, out.lmXGX_10mins,
+           type = "text", #输出显示为文本
+           omit = c("Rank", "Birth", "Gender", "East", "Middle", "Northeast", "Edu",
+                    "School", "Grade", "Semester", "GP_Rank", "GP_Birth", "GP_Gender", "GP_East",
+                    "GP_Middle", "GP_Northeast", "GP_Edu"), #隐藏不展示的变量
+           omit.stat = c("f", "ser", "adj.rsq"), #隐藏不展示的信息
+           dep.var.labels = "10分钟窗口设定下的社交网络主体学生学业表现：Score", #因变量标签
+           title = "表7 时间窗口设定为10分钟的社交网络同群效应影响", #表格标题
+           add.lines = list(c("控制主体特征变量", "NO", "YES", "YES"),c("控制朋友特征变量", "NO", "NO", "YES"),
+                            c("固定效应", "NO", "YES", "YES")), #表格展示控制变量信息
+           digits = 3, #数据保留小数点后3位
+           out = "C:/2024-00222+日志文件/table7.html")

表7 时间窗口设定为10分钟的社交网络同群效应影响
===========================================
                  Dependent variable:      
             ------------------------------
              10分钟窗口设定下的社交网络主体学生学业表现：Score 
                (1)        (2)       (3)   
-------------------------------------------
GP_Score      0.362***  0.283***  0.288*** 
              (0.025)    (0.025)   (0.026) 
                                           
Constant      1.475***  1.663***  1.656*** 
              (0.059)    (0.059)   (0.061) 
                                           
-------------------------------------------
控制主体特征变量         NO        YES       YES   
控制朋友特征变量         NO        NO        YES   
固定效应             NO        YES       YES   
Observations   5,598      5,598     5,598  
R2             0.036      0.113     0.115  
===========================================
Note:           *p<0.1; **p<0.05; ***p<0.01

> ################*表8 同群效应的影响机制研究*#################
> # 写入日志信息
> cat("################*表8 同群效应的影响机制研究*#################\n")
################*表8 同群效应的影响机制研究*#################

> # 导入数据
> workdata <- read.csv("C:/2024-00222+使用数据/table8.csv",header = T,as.is = T,stringsAsFactors = TRUE)

> # 使用函数转换指定的列为因子
> workdata <- convert_to_factors(workdata)

> # 最后两个回归方程使用删除转专业学生数据
> workdata_noTransfer <- subset(workdata, TransferStudent==0)

> out.1 <- lm(Stime ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+               GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata)

> summary(out.1) # 回归原始结果输出

Call:
lm(formula = Stime ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.28139 -0.08882 -0.00270  0.08277  0.35434 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     2.0940017  0.1182592  17.707  < 2e-16 ***
GP_Score        0.2266337  0.0501953   4.515 6.45e-06 ***
Rank           -0.1436490  0.0694784  -2.068  0.03873 *  
Birth           0.0024493  0.0042200   0.580  0.56167    
Gender          0.0098202  0.0039733   2.472  0.01348 *  
East           -0.0046994  0.0037999  -1.237  0.21624    
Middle          0.0079047  0.0043136   1.832  0.06693 .  
Northeast       0.0102747  0.0063737   1.612  0.10700    
Edu             0.0031681  0.0033907   0.934  0.35016    
School2        -0.0228432  0.0123328  -1.852  0.06404 .  
School3        -0.0237643  0.0103507  -2.296  0.02171 *  
School4        -0.0106788  0.0129630  -0.824  0.41009    
School5        -0.0316946  0.0079145  -4.005 6.29e-05 ***
School6        -0.0220926  0.0086184  -2.563  0.01039 *  
School7         0.0185852  0.0078908   2.355  0.01854 *  
School8        -0.0322953  0.0078899  -4.093 4.31e-05 ***
School9        -0.0096624  0.0077253  -1.251  0.21107    
School10       -0.0320392  0.0070018  -4.576 4.84e-06 ***
School11       -0.0126350  0.0079371  -1.592  0.11146    
School12       -0.0792952  0.0097756  -8.112 5.99e-16 ***
School13       -0.0428087  0.0077924  -5.494 4.10e-08 ***
School14       -0.0038199  0.0087496  -0.437  0.66243    
School15       -0.0177789  0.0081337  -2.186  0.02887 *  
School16       -0.0468529  0.0147583  -3.175  0.00151 ** 
School17       -0.0010926  0.0093510  -0.117  0.90699    
School18       -0.0523332  0.0083412  -6.274 3.76e-10 ***
School19       -0.0401941  0.0109058  -3.686  0.00023 ***
Grade2          0.0071575  0.0037335   1.917  0.05527 .  
Grade3          0.0058695  0.0051831   1.132  0.25749    
Semester151602 -0.0025439  0.0099474  -0.256  0.79817    
Semester161701 -0.0005683  0.0086090  -0.066  0.94737    
Semester161702 -0.0018375  0.0084473  -0.218  0.82781    
Semester171801  0.0036341  0.0083378   0.436  0.66296    
GP_Rank        -0.0630112  0.1243548  -0.507  0.61238    
GP_Birth        0.0109259  0.0079908   1.367  0.17158    
GP_Gender       0.0020521  0.0065419   0.314  0.75377    
GP_East        -0.0108399  0.0075114  -1.443  0.14903    
GP_Middle      -0.0091791  0.0082265  -1.116  0.26456    
GP_Northeast    0.0144351  0.0124213   1.162  0.24523    
GP_Edu         -0.0142854  0.0066809  -2.138  0.03254 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.1211 on 6120 degrees of freedom
Multiple R-squared:  0.04167,	Adjusted R-squared:  0.03557 
F-statistic: 6.824 on 39 and 6120 DF,  p-value: < 2.2e-16


> out.2 <- lm(Score ~ Stime+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+               GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata)

> summary(out.2) # 回归原始结果输出

Call:
lm(formula = Score ~ Stime + Rank + Birth + Gender + East + Middle + 
    Northeast + Edu + School + Grade + Semester + GP_Rank + GP_Birth + 
    GP_Gender + GP_East + GP_Middle + GP_Northeast + GP_Edu, 
    data = workdata)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.43684 -0.03010  0.00852  0.04095  0.13436 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     2.135e+00  1.777e-02 120.143  < 2e-16 ***
Stime           7.292e-02  6.357e-03  11.470  < 2e-16 ***
Rank           -3.464e-01  3.462e-02 -10.005  < 2e-16 ***
Birth           5.215e-03  2.102e-03   2.481  0.01313 *  
Gender         -2.999e-02  1.978e-03 -15.156  < 2e-16 ***
East            1.652e-02  1.893e-03   8.729  < 2e-16 ***
Middle          1.207e-02  2.149e-03   5.615 2.06e-08 ***
Northeast       6.425e-03  3.175e-03   2.023  0.04308 *  
Edu            -6.102e-05  1.689e-03  -0.036  0.97118    
School2        -2.538e-02  6.098e-03  -4.163 3.19e-05 ***
School3        -4.282e-03  5.156e-03  -0.830  0.40637    
School4        -3.337e-02  6.438e-03  -5.183 2.26e-07 ***
School5        -1.957e-03  3.948e-03  -0.496  0.62005    
School6         2.594e-03  4.295e-03   0.604  0.54585    
School7        -4.389e-03  3.932e-03  -1.116  0.26439    
School8         4.298e-03  3.935e-03   1.092  0.27484    
School9        -1.326e-02  3.847e-03  -3.447  0.00057 ***
School10       -4.489e-03  3.492e-03  -1.286  0.19862    
School11        1.055e-03  3.954e-03   0.267  0.78961    
School12       -2.560e-03  4.893e-03  -0.523  0.60085    
School13        4.229e-03  3.891e-03   1.087  0.27717    
School14       -2.681e-03  4.355e-03  -0.616  0.53817    
School15       -7.135e-03  4.052e-03  -1.761  0.07832 .  
School16        1.476e-03  7.357e-03   0.201  0.84098    
School17        7.819e-04  4.658e-03   0.168  0.86669    
School18       -7.776e-03  4.164e-03  -1.868  0.06187 .  
School19       -2.123e-02  5.435e-03  -3.906 9.49e-05 ***
Grade2         -2.534e-03  1.860e-03  -1.362  0.17311    
Grade3         -2.604e-03  2.581e-03  -1.009  0.31304    
Semester151602  2.121e-03  4.953e-03   0.428  0.66842    
Semester161701  7.469e-04  4.287e-03   0.174  0.86170    
Semester161702  2.638e-03  4.203e-03   0.628  0.53025    
Semester171801  2.841e-03  4.152e-03   0.684  0.49385    
GP_Rank        -3.874e-02  6.126e-02  -0.632  0.52718    
GP_Birth        1.053e-03  3.977e-03   0.265  0.79115    
GP_Gender      -9.118e-03  3.185e-03  -2.863  0.00421 ** 
GP_East        -2.013e-03  3.731e-03  -0.540  0.58955    
GP_Middle       1.209e-03  4.088e-03   0.296  0.76735    
GP_Northeast   -7.712e-03  6.185e-03  -1.247  0.21247    
GP_Edu         -2.104e-03  3.329e-03  -0.632  0.52726    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.0603 on 6120 degrees of freedom
Multiple R-squared:  0.1131,	Adjusted R-squared:  0.1075 
F-statistic: 20.02 on 39 and 6120 DF,  p-value: < 2.2e-16


> out.3 <- lm(Present ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+               GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata)

> summary(out.3) # 回归原始结果输出

Call:
lm(formula = Present ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata)

Residuals:
      Min        1Q    Median        3Q       Max 
-0.221949 -0.057666 -0.009992  0.050574  0.299724 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     2.3372797  0.0875798  26.687  < 2e-16 ***
GP_Score        0.0826764  0.0371734   2.224  0.02618 *  
Rank           -0.0703801  0.0514539  -1.368  0.17142    
Birth           0.0099191  0.0031252   3.174  0.00151 ** 
Gender          0.0010116  0.0029425   0.344  0.73103    
East           -0.0044091  0.0028141  -1.567  0.11721    
Middle          0.0013222  0.0031946   0.414  0.67898    
Northeast      -0.0082466  0.0047202  -1.747  0.08067 .  
Edu             0.0064285  0.0025111   2.560  0.01049 *  
School2         0.0606781  0.0091334   6.644 3.33e-11 ***
School3         0.0164570  0.0076655   2.147  0.03184 *  
School4         0.0864317  0.0096001   9.003  < 2e-16 ***
School5        -0.0083200  0.0058613  -1.419  0.15581    
School6        -0.0096975  0.0063826  -1.519  0.12872    
School7         0.0087704  0.0058437   1.501  0.13345    
School8         0.0050063  0.0058431   0.857  0.39160    
School9        -0.0420364  0.0057212  -7.348 2.28e-13 ***
School10        0.0096100  0.0051853   1.853  0.06389 .  
School11       -0.0122846  0.0058780  -2.090  0.03667 *  
School12        0.0172046  0.0072396   2.376  0.01751 *  
School13        0.0306119  0.0057709   5.305 1.17e-07 ***
School14       -0.0295398  0.0064797  -4.559 5.24e-06 ***
School15        0.0055647  0.0060236   0.924  0.35562    
School16       -0.0240290  0.0109297  -2.199  0.02795 *  
School17        0.0533759  0.0069251   7.708 1.49e-14 ***
School18        0.0320531  0.0061773   5.189 2.18e-07 ***
School19        0.0328674  0.0080766   4.069 4.77e-05 ***
Grade2         -0.0169136  0.0027650  -6.117 1.01e-09 ***
Grade3         -0.0064459  0.0038385  -1.679  0.09314 .  
Semester151602 -0.0004051  0.0073668  -0.055  0.95615    
Semester161701 -0.0051680  0.0063756  -0.811  0.41763    
Semester161702 -0.0056530  0.0062559  -0.904  0.36623    
Semester171801 -0.0062554  0.0061747  -1.013  0.31107    
GP_Rank         0.0547670  0.0920940   0.595  0.55208    
GP_Birth        0.0011739  0.0059178   0.198  0.84277    
GP_Gender      -0.0081218  0.0048448  -1.676  0.09371 .  
GP_East        -0.0071732  0.0055627  -1.290  0.19727    
GP_Middle       0.0058746  0.0060924   0.964  0.33495    
GP_Northeast    0.0141918  0.0091989   1.543  0.12294    
GP_Edu         -0.0079673  0.0049477  -1.610  0.10739    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.08965 on 6120 degrees of freedom
Multiple R-squared:  0.09076,	Adjusted R-squared:  0.08496 
F-statistic: 15.66 on 39 and 6120 DF,  p-value: < 2.2e-16


> out.4 <- lm(Score ~ Present+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+               GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata)

> summary(out.4) # 回归原始结果输出

Call:
lm(formula = Score ~ Present + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.41736 -0.03049  0.00901  0.04111  0.15300 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     2.1295849  0.0226842  93.880  < 2e-16 ***
Present         0.0776198  0.0086295   8.995  < 2e-16 ***
Rank           -0.3515302  0.0347539 -10.115  < 2e-16 ***
Birth           0.0046101  0.0021121   2.183 0.029093 *  
Gender         -0.0293793  0.0019857 -14.795  < 2e-16 ***
East            0.0165290  0.0019009   8.695  < 2e-16 ***
Middle          0.0125458  0.0021575   5.815 6.37e-09 ***
Northeast       0.0077957  0.0031884   2.445 0.014511 *  
Edu            -0.0003341  0.0016967  -0.197 0.843905    
School2        -0.0320704  0.0061401  -5.223 1.82e-07 ***
School3        -0.0073508  0.0051767  -1.420 0.155669    
School4        -0.0410584  0.0065047  -6.312 2.95e-10 ***
School5        -0.0036344  0.0039591  -0.918 0.358655    
School6         0.0017128  0.0043110   0.397 0.691157    
School7        -0.0037309  0.0039471  -0.945 0.344587    
School8         0.0015623  0.0039464   0.396 0.692209    
School9        -0.0107477  0.0038796  -2.770 0.005617 ** 
School10       -0.0076228  0.0035005  -2.178 0.029474 *  
School11        0.0010901  0.0039712   0.274 0.783714    
School12       -0.0097474  0.0048884  -1.994 0.046196 *  
School13       -0.0012912  0.0039059  -0.331 0.740969    
School14       -0.0007396  0.0043801  -0.169 0.865919    
School15       -0.0088996  0.0040674  -2.188 0.028705 *  
School16       -0.0001214  0.0073836  -0.016 0.986881    
School17       -0.0034497  0.0046995  -0.734 0.462934    
School18       -0.0141668  0.0041751  -3.393 0.000695 ***
School19       -0.0267916  0.0054581  -4.909 9.41e-07 ***
Grade2         -0.0007161  0.0018727  -0.382 0.702170    
Grade3         -0.0017040  0.0025920  -0.657 0.510950    
Semester151602  0.0020308  0.0049728   0.408 0.682998    
Semester161701  0.0011419  0.0043052   0.265 0.790838    
Semester161702  0.0030238  0.0042204   0.716 0.473735    
Semester171801  0.0036359  0.0041690   0.872 0.383181    
GP_Rank        -0.0513129  0.0615037  -0.834 0.404142    
GP_Birth        0.0016845  0.0039924   0.422 0.673095    
GP_Gender      -0.0086166  0.0031990  -2.694 0.007089 ** 
GP_East        -0.0021305  0.0037462  -0.569 0.569580    
GP_Middle       0.0002025  0.0041044   0.049 0.960649    
GP_Northeast   -0.0076753  0.0062103  -1.236 0.216545    
GP_Edu         -0.0025532  0.0033416  -0.764 0.444860    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06055 on 6120 degrees of freedom
Multiple R-squared:  0.1059,	Adjusted R-squared:  0.1002 
F-statistic: 18.58 on 39 and 6120 DF,  p-value: < 2.2e-16


> out.5 <- lm(S_major ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+               GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_noTransfer)

> summary(out.5) # 回归原始结果输出

Call:
lm(formula = S_major ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_noTransfer)

Residuals:
     Min       1Q   Median       3Q      Max 
-1.46040 -0.75296 -0.06867  0.94951  1.61713 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)    -1.8100551  0.8398319  -2.155 0.031182 *  
GP_Score        1.1209243  0.3563726   3.145 0.001667 ** 
Rank            1.2007899  0.4899497   2.451 0.014281 *  
Birth           0.0021186  0.0299574   0.071 0.943624    
Gender          0.0567072  0.0284041   1.996 0.045932 *  
East            0.0534175  0.0271169   1.970 0.048897 *  
Middle          0.0688050  0.0309062   2.226 0.026035 *  
Northeast       0.0003733  0.0458077   0.008 0.993497    
Edu            -0.0377640  0.0243280  -1.552 0.120648    
School2         0.1541688  0.0867727   1.777 0.075670 .  
School3         0.2656491  0.0740572   3.587 0.000337 ***
School4        -0.0981265  0.0923061  -1.063 0.287800    
School5         0.2259493  0.0561273   4.026 5.75e-05 ***
School6        -0.1564910  0.0614228  -2.548 0.010867 *  
School7        -0.1691097  0.0564211  -2.997 0.002735 ** 
School8         0.0757939  0.0578030   1.311 0.189827    
School9         0.0076587  0.0550151   0.139 0.889289    
School10       -0.0774863  0.0500446  -1.548 0.121593    
School11       -0.0016597  0.0575668  -0.029 0.977001    
School12       -0.1796401  0.0705265  -2.547 0.010887 *  
School13       -0.1963770  0.0557336  -3.523 0.000429 ***
School14        0.0233827  0.0622424   0.376 0.707174    
School15       -0.1461854  0.0584104  -2.503 0.012351 *  
School16       -0.1259023  0.1082478  -1.163 0.244839    
School17       -0.2835037  0.0677114  -4.187 2.87e-05 ***
School18       -0.2175083  0.0596353  -3.647 0.000267 ***
School19       -0.0992633  0.0782267  -1.269 0.204520    
Grade2         -0.0058136  0.0267108  -0.218 0.827708    
Grade3          0.2455852  0.0373852   6.569 5.50e-11 ***
Semester151602  0.0592314  0.0721931   0.820 0.411989    
Semester161701  0.0242733  0.0622492   0.390 0.696596    
Semester161702 -0.0008569  0.0611648  -0.014 0.988823    
Semester171801 -0.0111759  0.0603253  -0.185 0.853032    
GP_Rank        -0.3597815  0.9987814  -0.360 0.718695    
GP_Birth        0.0924424  0.0572920   1.614 0.106683    
GP_Gender      -0.0019506  0.0467214  -0.042 0.966699    
GP_East        -0.0299487  0.0536409  -0.558 0.576648    
GP_Middle      -0.1415127  0.0587328  -2.409 0.016008 *  
GP_Northeast    0.0502511  0.0880373   0.571 0.568161    
GP_Edu         -0.1007770  0.0474373  -2.124 0.033676 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.8479 on 5870 degrees of freedom
Multiple R-squared:  0.0426,	Adjusted R-squared:  0.03624 
F-statistic: 6.697 on 39 and 5870 DF,  p-value: < 2.2e-16


> out.6 <- lm(Score ~ S_major+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+               GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_noTransfer)

> summary(out.6) # 回归原始结果输出

Call:
lm(formula = Score ~ S_major + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_noTransfer)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.41968 -0.02975  0.00936  0.04117  0.16188 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     2.3174777  0.0063498 364.969  < 2e-16 ***
S_major         0.0080300  0.0009347   8.591  < 2e-16 ***
Rank           -0.3605491  0.0351320 -10.263  < 2e-16 ***
Birth           0.0044204  0.0021468   2.059 0.039533 *  
Gender         -0.0303778  0.0020350 -14.928  < 2e-16 ***
East            0.0163553  0.0019442   8.413  < 2e-16 ***
Middle          0.0122048  0.0022160   5.507 3.79e-08 ***
Northeast       0.0054630  0.0032828   1.664 0.096141 .  
Edu            -0.0002157  0.0017440  -0.124 0.901573    
School2        -0.0281035  0.0061697  -4.555 5.34e-06 ***
School3        -0.0080805  0.0053115  -1.521 0.128234    
School4        -0.0355093  0.0065951  -5.384 7.56e-08 ***
School5        -0.0054787  0.0040281  -1.360 0.173847    
School6         0.0024624  0.0044044   0.559 0.576127    
School7        -0.0013118  0.0040467  -0.324 0.745829    
School8         0.0004480  0.0041435   0.108 0.913906    
School9        -0.0142734  0.0039414  -3.621 0.000296 ***
School10       -0.0064197  0.0035850  -1.791 0.073393 .  
School11       -0.0013920  0.0041259  -0.337 0.735852    
School12       -0.0084939  0.0050552  -1.680 0.092965 .  
School13        0.0024538  0.0039984   0.614 0.539441    
School14       -0.0026903  0.0044570  -0.604 0.546124    
School15       -0.0074449  0.0041879  -1.778 0.075505 .  
School16       -0.0032718  0.0077580  -0.422 0.673238    
School17        0.0007931  0.0048602   0.163 0.870376    
School18       -0.0118176  0.0042734  -2.765 0.005703 ** 
School19       -0.0227492  0.0056039  -4.060 4.98e-05 ***
Grade2         -0.0010606  0.0019141  -0.554 0.579517    
Grade3         -0.0062947  0.0026880  -2.342 0.019226 *  
Semester151602  0.0032411  0.0051720   0.627 0.530909    
Semester161701  0.0025092  0.0044610   0.562 0.573811    
Semester161702  0.0045758  0.0043793   1.045 0.296125    
Semester171801  0.0056949  0.0043223   1.318 0.187703    
GP_Rank        -0.1077802  0.0708184  -1.522 0.128082    
GP_Birth        0.0022299  0.0041027   0.544 0.586790    
GP_Gender      -0.0083089  0.0032722  -2.539 0.011135 *  
GP_East        -0.0027221  0.0038307  -0.711 0.477358    
GP_Middle       0.0011676  0.0042002   0.278 0.781022    
GP_Northeast   -0.0082641  0.0063069  -1.310 0.190138    
GP_Edu         -0.0019311  0.0034008  -0.568 0.570165    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06077 on 5870 degrees of freedom
Multiple R-squared:  0.106,	Adjusted R-squared:  0.1001 
F-statistic: 17.85 on 39 and 5870 DF,  p-value: < 2.2e-16


> # 表格输出
> stargazer(out.1, out.2, out.3, out.4, out.5, out.6,
+           type = "text", #输出显示为文本
+           omit = c("Rank", "Birth", "Gender", "East", "Middle", "Northeast", "Edu",
+                    "School", "Grade", "Semester", "GP_Rank", "GP_Birth", "GP_Gender", "GP_East",
+                    "GP_Middle", "GP_Northeast", "GP_Edu"), #隐藏不展示的变量
+           omit.stat = c("f", "ser", "adj.rsq"), #隐藏不展示的信息
+           title = "表8 同群效应的影响机制研究", #表格标题
+           add.lines = list(c("控制主体特征变量", "YES", "YES", "YES", "YES", "YES", "YES"),
+                            c("控制朋友特征变量", "YES", "YES", "YES", "YES", "YES", "YES"),
+                            c("固定效应", "YES", "YES", "YES", "YES", "YES", "YES")), #表格展示控制变量信息
+           digits = 3, #数据保留小数点后3位
+           out = "C:/2024-00222+日志文件/table8.html")

表8 同群效应的影响机制研究
==================================================================
                              Dependent variable:                 
             -----------------------------------------------------
              Stime    Score   Present   Score   S_major   Score  
               (1)      (2)      (3)      (4)      (5)      (6)   
------------------------------------------------------------------
GP_Score     0.227***          0.083**           1.121***         
             (0.050)           (0.037)           (0.356)          
                                                                  
Stime                 0.073***                                    
                      (0.006)                                     
                                                                  
Present                                 0.078***                  
                                        (0.009)                   
                                                                  
S_major                                                   0.008***
                                                          (0.001) 
                                                                  
Constant     2.094*** 2.135*** 2.337*** 2.130*** -1.810** 2.317***
             (0.118)  (0.018)  (0.088)  (0.023)  (0.840)  (0.006) 
                                                                  
------------------------------------------------------------------
控制主体特征变量       YES      YES      YES      YES      YES      YES   
控制朋友特征变量       YES      YES      YES      YES      YES      YES   
固定效应           YES      YES      YES      YES      YES      YES   
Observations  6,160    6,160    6,160    6,160    5,910    5,910  
R2            0.042    0.113    0.091    0.106    0.043    0.106  
==================================================================
Note:                                  *p<0.1; **p<0.05; ***p<0.01

> ################*表I1 不同阈值设定下的学业表现同群效应检验*#################
> # 写入日志信息
> cat("################*表I1 不同阈值设定下的学业表现同群效应检验*#################\n")
################*表I1 不同阈值设定下的学业表现同群效应检验*#################

> # 导入数据
> workdata <- read.csv("C:/2024-00222+使用数据/tableI1.csv",header = T,as.is = T,stringsAsFactors = TRUE)

> # 使用函数转换指定的列为因子
> workdata <- convert_to_factors(workdata)

> # 按照阈值分组
> workdata_t10 <- subset(workdata, Threshold==10)

> workdata_t20 <- subset(workdata, Threshold==20)

> workdata_t30 <- subset(workdata, Threshold==30)

> workdata_t40 <- subset(workdata, Threshold==40)

> workdata_t50 <- subset(workdata, Threshold==50)

> workdata_t28 <- subset(workdata, Threshold==28)

> # 控制主体特征变量、朋友特征变量和固定效应变量
> out.t10 <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                 GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_t10)

> summary(out.t10) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_t10)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.42564 -0.03224  0.00932  0.04270  0.17505 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.7585799  0.1425338  12.338  < 2e-16 ***
GP_Score        0.2342969  0.0609613   3.843 0.000122 ***
Rank           -0.3795720  0.0312471 -12.147  < 2e-16 ***
Birth           0.0052293  0.0019994   2.615 0.008928 ** 
Gender         -0.0309814  0.0016463 -18.818  < 2e-16 ***
East            0.0167239  0.0017715   9.441  < 2e-16 ***
Middle          0.0117376  0.0020320   5.776 7.93e-09 ***
Northeast       0.0033325  0.0029758   1.120 0.262809    
Edu            -0.0002561  0.0015848  -0.162 0.871638    
School2        -0.0214191  0.0056393  -3.798 0.000147 ***
School3        -0.0076202  0.0048540  -1.570 0.116484    
School4        -0.0263447  0.0063252  -4.165 3.15e-05 ***
School5        -0.0062679  0.0037710  -1.662 0.096524 .  
School6        -0.0006124  0.0039699  -0.154 0.877414    
School7        -0.0087085  0.0037220  -2.340 0.019324 *  
School8         0.0037581  0.0037450   1.004 0.315647    
School9        -0.0152547  0.0036489  -4.181 2.94e-05 ***
School10       -0.0074335  0.0033088  -2.247 0.024695 *  
School11        0.0015799  0.0037932   0.417 0.677048    
School12       -0.0110735  0.0046494  -2.382 0.017257 *  
School13        0.0016138  0.0036805   0.438 0.661056    
School14       -0.0027307  0.0040865  -0.668 0.504003    
School15       -0.0103956  0.0038236  -2.719 0.006566 ** 
School16       -0.0009420  0.0065630  -0.144 0.885871    
School17       -0.0070384  0.0041766  -1.685 0.091988 .  
School18       -0.0116557  0.0038292  -3.044 0.002344 ** 
School19       -0.0332405  0.0051115  -6.503 8.37e-11 ***
Grade2          0.0003168  0.0017194   0.184 0.853810    
Grade3         -0.0000233  0.0024200  -0.010 0.992319    
Semester151602  0.0008065  0.0046539   0.173 0.862432    
Semester161701  0.0045551  0.0041702   1.092 0.274734    
Semester161702  0.0058656  0.0040920   1.433 0.151771    
Semester171801  0.0081990  0.0041534   1.974 0.048413 *  
GP_Rank         0.4131187  0.1913528   2.159 0.030887 *  
GP_Birth        0.0280453  0.0097984   2.862 0.004218 ** 
GP_Gender      -0.0348229  0.0064662  -5.385 7.45e-08 ***
GP_East         0.0102977  0.0091337   1.127 0.259595    
GP_Middle       0.0050201  0.0099348   0.505 0.613362    
GP_Northeast    0.0147546  0.0151933   0.971 0.331516    
GP_Edu         -0.0222226  0.0074976  -2.964 0.003046 ** 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06286 on 7538 degrees of freedom
Multiple R-squared:  0.1018,	Adjusted R-squared:  0.09715 
F-statistic: 21.91 on 39 and 7538 DF,  p-value: < 2.2e-16


> out.t20 <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                 GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_t20)

> summary(out.t20) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_t20)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.43438 -0.03094  0.00898  0.04166  0.17061 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.477e+00  7.420e-02  19.905  < 2e-16 ***
GP_Score        3.609e-01  3.160e-02  11.422  < 2e-16 ***
Rank           -3.690e-01  3.295e-02 -11.199  < 2e-16 ***
Birth           5.285e-03  2.039e-03   2.592 0.009574 ** 
Gender         -2.950e-02  1.802e-03 -16.370  < 2e-16 ***
East            1.538e-02  1.823e-03   8.441  < 2e-16 ***
Middle          1.111e-02  2.081e-03   5.339 9.66e-08 ***
Northeast       4.813e-03  3.057e-03   1.575 0.115394    
Edu            -3.540e-04  1.625e-03  -0.218 0.827561    
School2        -1.879e-02  5.795e-03  -3.242 0.001193 ** 
School3        -4.756e-03  4.977e-03  -0.956 0.339261    
School4        -2.734e-02  6.295e-03  -4.342 1.43e-05 ***
School5        -6.602e-03  3.825e-03  -1.726 0.084418 .  
School6        -1.115e-03  4.067e-03  -0.274 0.783930    
School7        -4.854e-03  3.789e-03  -1.281 0.200222    
School8         4.530e-04  3.796e-03   0.119 0.905026    
School9        -1.425e-02  3.728e-03  -3.822 0.000133 ***
School10       -6.560e-03  3.369e-03  -1.948 0.051516 .  
School11        5.459e-04  3.843e-03   0.142 0.887060    
School12       -1.018e-02  4.727e-03  -2.153 0.031325 *  
School13        5.491e-04  3.743e-03   0.147 0.883370    
School14       -2.326e-03  4.208e-03  -0.553 0.580466    
School15       -1.027e-02  3.897e-03  -2.635 0.008430 ** 
School16        6.631e-04  6.869e-03   0.097 0.923108    
School17       -5.024e-03  4.393e-03  -1.144 0.252852    
School18       -1.104e-02  3.979e-03  -2.775 0.005541 ** 
School19       -2.436e-02  5.271e-03  -4.622 3.86e-06 ***
Grade2         -8.444e-04  1.777e-03  -0.475 0.634707    
Grade3          9.003e-05  2.478e-03   0.036 0.971017    
Semester151602  2.541e-03  4.764e-03   0.533 0.593781    
Semester161701  1.317e-03  4.120e-03   0.320 0.749169    
Semester161702  2.310e-03  4.051e-03   0.570 0.568498    
Semester171801  3.723e-03  4.004e-03   0.930 0.352409    
GP_Rank         1.443e-01  7.526e-02   1.917 0.055286 .  
GP_Birth        1.113e-02  5.080e-03   2.190 0.028542 *  
GP_Gender      -4.181e-03  3.811e-03  -1.097 0.272672    
GP_East        -4.773e-03  4.795e-03  -0.995 0.319628    
GP_Middle      -4.495e-03  5.335e-03  -0.843 0.399502    
GP_Northeast   -8.373e-03  8.340e-03  -1.004 0.315481    
GP_Edu         -6.498e-03  4.228e-03  -1.537 0.124364    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06134 on 6826 degrees of freedom
Multiple R-squared:  0.1099,	Adjusted R-squared:  0.1048 
F-statistic:  21.6 on 39 and 6826 DF,  p-value: < 2.2e-16


> out.t30 <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                 GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_t30)

> summary(out.t30) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_t30)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.41629 -0.03031  0.00902  0.04023  0.16349 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.6300465  0.0554335  29.405  < 2e-16 ***
GP_Score        0.2980068  0.0235671  12.645  < 2e-16 ***
Rank           -0.3463608  0.0345344 -10.029  < 2e-16 ***
Birth           0.0052541  0.0021204   2.478  0.01324 *  
Gender         -0.0272035  0.0020631 -13.185  < 2e-16 ***
East            0.0160885  0.0019158   8.398  < 2e-16 ***
Middle          0.0128416  0.0021780   5.896 3.94e-09 ***
Northeast       0.0073648  0.0032257   2.283  0.02246 *  
Edu             0.0004703  0.0017138   0.274  0.78376    
School2        -0.0170673  0.0064907  -2.630  0.00857 ** 
School3        -0.0042825  0.0052215  -0.820  0.41216    
School4        -0.0261077  0.0065815  -3.967 7.37e-05 ***
School5        -0.0044239  0.0039694  -1.114  0.26511    
School6         0.0006467  0.0043335   0.149  0.88138    
School7        -0.0032178  0.0040166  -0.801  0.42309    
School8         0.0009549  0.0039728   0.240  0.81007    
School9        -0.0116834  0.0038905  -3.003  0.00268 ** 
School10       -0.0061637  0.0035196  -1.751  0.07995 .  
School11       -0.0014757  0.0039938  -0.369  0.71177    
School12       -0.0037778  0.0049089  -0.770  0.44158    
School13        0.0014605  0.0039263   0.372  0.70993    
School14       -0.0014128  0.0044034  -0.321  0.74835    
School15       -0.0054545  0.0041129  -1.326  0.18483    
School16       -0.0050636  0.0075818  -0.668  0.50425    
School17        0.0002256  0.0047017   0.048  0.96174    
School18       -0.0106855  0.0042431  -2.518  0.01182 *  
School19       -0.0221531  0.0054861  -4.038 5.46e-05 ***
Grade2         -0.0017608  0.0018910  -0.931  0.35180    
Grade3         -0.0025265  0.0026226  -0.963  0.33541    
Semester151602  0.0001978  0.0049878   0.040  0.96837    
Semester161701  0.0005966  0.0043569   0.137  0.89109    
Semester161702  0.0013017  0.0042704   0.305  0.76052    
Semester171801  0.0030909  0.0042218   0.732  0.46411    
GP_Rank         0.0364944  0.0592885   0.616  0.53822    
GP_Birth        0.0025628  0.0037185   0.689  0.49073    
GP_Gender      -0.0020637  0.0031503  -0.655  0.51243    
GP_East        -0.0060295  0.0034762  -1.735  0.08288 .  
GP_Middle      -0.0057359  0.0037993  -1.510  0.13116    
GP_Northeast   -0.0055494  0.0059563  -0.932  0.35154    
GP_Edu         -0.0025237  0.0030772  -0.820  0.41218    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.05943 on 5785 degrees of freedom
Multiple R-squared:  0.1188,	Adjusted R-squared:  0.1129 
F-statistic: 20.01 on 39 and 5785 DF,  p-value: < 2.2e-16


> out.t40 <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                 GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_t40)

> summary(out.t40) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_t40)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.33122 -0.02962  0.00850  0.03851  0.16615 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.815e+00  4.760e-02  38.142  < 2e-16 ***
GP_Score        2.221e-01  2.024e-02  10.978  < 2e-16 ***
Rank           -3.743e-01  4.108e-02  -9.109  < 2e-16 ***
Birth           3.362e-03  2.269e-03   1.482 0.138489    
Gender         -2.635e-02  2.477e-03 -10.641  < 2e-16 ***
East            1.658e-02  2.076e-03   7.983 1.78e-15 ***
Middle          1.209e-02  2.348e-03   5.149 2.73e-07 ***
Northeast       1.182e-02  3.507e-03   3.369 0.000760 ***
Edu             7.604e-04  1.857e-03   0.410 0.682179    
School2        -2.421e-02  7.231e-03  -3.348 0.000820 ***
School3        -6.207e-03  5.473e-03  -1.134 0.256806    
School4        -2.578e-02  6.849e-03  -3.763 0.000170 ***
School5        -1.673e-03  4.311e-03  -0.388 0.698040    
School6        -1.662e-03  4.577e-03  -0.363 0.716581    
School7        -2.194e-03  4.377e-03  -0.501 0.616203    
School8         2.671e-03  4.259e-03   0.627 0.530625    
School9        -8.136e-03  4.187e-03  -1.943 0.052071 .  
School10       -6.927e-03  3.803e-03  -1.821 0.068604 .  
School11        8.440e-05  4.264e-03   0.020 0.984208    
School12       -4.443e-03  5.357e-03  -0.829 0.406934    
School13        7.110e-04  4.241e-03   0.168 0.866853    
School14       -3.687e-03  4.777e-03  -0.772 0.440257    
School15       -2.285e-03  4.476e-03  -0.510 0.609759    
School16       -1.240e-02  8.320e-03  -1.490 0.136243    
School17        1.911e-04  5.186e-03   0.037 0.970605    
School18       -1.154e-02  4.608e-03  -2.505 0.012296 *  
School19       -1.952e-02  5.862e-03  -3.329 0.000878 ***
Grade2         -2.219e-03  2.074e-03  -1.070 0.284623    
Grade3         -2.927e-03  2.811e-03  -1.041 0.297873    
Semester151602 -1.738e-03  5.540e-03  -0.314 0.753762    
Semester161701 -1.859e-03  4.823e-03  -0.385 0.699958    
Semester161702 -2.573e-04  4.696e-03  -0.055 0.956313    
Semester171801 -9.885e-05  4.659e-03  -0.021 0.983075    
GP_Rank         6.636e-02  6.096e-02   1.089 0.276383    
GP_Birth       -1.615e-03  3.261e-03  -0.495 0.620505    
GP_Gender       6.789e-04  3.116e-03   0.218 0.827536    
GP_East        -4.696e-03  2.972e-03  -1.580 0.114103    
GP_Middle      -9.800e-03  3.335e-03  -2.938 0.003314 ** 
GP_Northeast   -7.568e-03  5.205e-03  -1.454 0.146024    
GP_Edu         -3.310e-03  2.630e-03  -1.258 0.208284    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.05772 on 4667 degrees of freedom
Multiple R-squared:  0.119,	Adjusted R-squared:  0.1116 
F-statistic: 16.16 on 39 and 4667 DF,  p-value: < 2.2e-16


> out.t50 <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                 GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_t50)

> summary(out.t50) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_t50)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.32499 -0.02842  0.00801  0.03825  0.15694 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.8630854  0.0465778  39.999  < 2e-16 ***
GP_Score        0.1999972  0.0197808  10.111  < 2e-16 ***
Rank           -0.3568775  0.0456789  -7.813 7.27e-15 ***
Birth           0.0024016  0.0025034   0.959 0.337452    
Gender         -0.0281597  0.0031024  -9.077  < 2e-16 ***
East            0.0167214  0.0023078   7.246 5.23e-13 ***
Middle          0.0127952  0.0026155   4.892 1.04e-06 ***
Northeast       0.0103232  0.0039560   2.609 0.009105 ** 
Edu             0.0003579  0.0020700   0.173 0.862746    
School2        -0.0179149  0.0086193  -2.078 0.037736 *  
School3        -0.0028661  0.0061686  -0.465 0.642228    
School4        -0.0259643  0.0072373  -3.588 0.000338 ***
School5         0.0004939  0.0048253   0.102 0.918471    
School6         0.0005075  0.0050653   0.100 0.920202    
School7         0.0005035  0.0049356   0.102 0.918758    
School8         0.0058432  0.0047774   1.223 0.221366    
School9        -0.0046233  0.0046217  -1.000 0.317219    
School10       -0.0051475  0.0041928  -1.228 0.219633    
School11        0.0028135  0.0046899   0.600 0.548600    
School12       -0.0041488  0.0058953  -0.704 0.481637    
School13        0.0022007  0.0046349   0.475 0.634955    
School14       -0.0046775  0.0053432  -0.875 0.381411    
School15        0.0042808  0.0050223   0.852 0.394078    
School16       -0.0113620  0.0093562  -1.214 0.224679    
School17        0.0007326  0.0060684   0.121 0.903920    
School18       -0.0135984  0.0051582  -2.636 0.008418 ** 
School19       -0.0172194  0.0061982  -2.778 0.005495 ** 
Grade2         -0.0027239  0.0023395  -1.164 0.244380    
Grade3         -0.0026607  0.0031213  -0.852 0.394020    
Semester151602  0.0008280  0.0062713   0.132 0.894968    
Semester161701  0.0007015  0.0054898   0.128 0.898335    
Semester161702  0.0027640  0.0053227   0.519 0.603597    
Semester171801  0.0022872  0.0053106   0.431 0.666716    
GP_Rank         0.0779170  0.0638370   1.221 0.222331    
GP_Birth       -0.0015298  0.0031383  -0.487 0.625971    
GP_Gender       0.0033842  0.0035008   0.967 0.333764    
GP_East        -0.0012487  0.0028722  -0.435 0.663782    
GP_Middle      -0.0105275  0.0032822  -3.208 0.001351 ** 
GP_Northeast   -0.0031050  0.0051070  -0.608 0.543231    
GP_Edu         -0.0035414  0.0025616  -1.383 0.166896    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.05672 on 3640 degrees of freedom
Multiple R-squared:  0.1256,	Adjusted R-squared:  0.1162 
F-statistic: 13.41 on 39 and 3640 DF,  p-value: < 2.2e-16


> out.t28 <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                 GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_t28)

> summary(out.t28) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_t28)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.41675 -0.03008  0.00890  0.04040  0.16520 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.613e+00  5.883e-02  27.426  < 2e-16 ***
GP_Score        3.041e-01  2.497e-02  12.178  < 2e-16 ***
Rank           -3.530e-01  3.456e-02 -10.215  < 2e-16 ***
Birth           5.773e-03  2.099e-03   2.750 0.005976 ** 
Gender         -2.837e-02  1.977e-03 -14.354  < 2e-16 ***
East            1.605e-02  1.890e-03   8.491  < 2e-16 ***
Middle          1.252e-02  2.146e-03   5.835 5.64e-09 ***
Northeast       7.690e-03  3.171e-03   2.425 0.015322 *  
Edu             3.151e-04  1.687e-03   0.187 0.851816    
School2        -1.818e-02  6.135e-03  -2.964 0.003048 ** 
School3        -4.337e-03  5.149e-03  -0.842 0.399696    
School4        -2.830e-02  6.449e-03  -4.389 1.16e-05 ***
School5        -3.928e-03  3.937e-03  -0.998 0.318518    
School6         1.648e-03  4.287e-03   0.384 0.700639    
School7        -2.568e-03  3.925e-03  -0.654 0.513052    
School8         1.717e-03  3.925e-03   0.438 0.661745    
School9        -1.271e-02  3.843e-03  -3.308 0.000945 ***
School10       -5.360e-03  3.483e-03  -1.539 0.123894    
School11        5.844e-05  3.948e-03   0.015 0.988192    
School12       -6.356e-03  4.863e-03  -1.307 0.191252    
School13        1.744e-03  3.876e-03   0.450 0.652777    
School14       -8.818e-04  4.353e-03  -0.203 0.839465    
School15       -7.410e-03  4.046e-03  -1.831 0.067111 .  
School16       -6.190e-04  7.342e-03  -0.084 0.932813    
School17        9.570e-04  4.652e-03   0.206 0.837007    
School18       -9.121e-03  4.149e-03  -2.198 0.027981 *  
School19       -2.189e-02  5.425e-03  -4.035 5.53e-05 ***
Grade2         -1.528e-03  1.857e-03  -0.823 0.410677    
Grade3         -1.377e-03  2.578e-03  -0.534 0.593429    
Semester151602  1.279e-04  4.948e-03   0.026 0.979380    
Semester161701 -2.970e-04  4.283e-03  -0.069 0.944705    
Semester161702  2.042e-04  4.202e-03   0.049 0.961239    
Semester171801  1.841e-03  4.148e-03   0.444 0.657139    
GP_Rank         6.275e-02  6.186e-02   1.014 0.310426    
GP_Birth        3.961e-03  3.975e-03   0.996 0.319112    
GP_Gender      -1.030e-03  3.254e-03  -0.317 0.751523    
GP_East        -6.106e-03  3.737e-03  -1.634 0.102294    
GP_Middle      -2.830e-03  4.092e-03  -0.692 0.489229    
GP_Northeast   -9.093e-03  6.179e-03  -1.472 0.141179    
GP_Edu         -2.419e-03  3.323e-03  -0.728 0.466654    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06022 on 6120 degrees of freedom
Multiple R-squared:  0.1155,	Adjusted R-squared:  0.1099 
F-statistic: 20.49 on 39 and 6120 DF,  p-value: < 2.2e-16


> # 表格输出
> stargazer(out.t10, out.t20, out.t30, out.t40, out.t50, out.t28,
+           type = "text", #输出显示为文本
+           omit = c("Rank", "Birth", "Gender", "East", "Middle", "Northeast", "Edu",
+                    "School", "Grade", "Semester", "GP_Rank", "GP_Birth", "GP_Gender", "GP_East",
+                    "GP_Middle", "GP_Northeast", "GP_Edu"), #隐藏不展示的变量
+           omit.stat = c("f", "ser", "adj.rsq"), #隐藏不展示的信息
+           dep.var.labels = "社交网络主体学生学业表现：Score", #因变量标签
+           title = "表I1 不同阈值设定下的学业表现同群效应检验", #表格标题
+           add.lines = list(c("控制主体特征变量", "YES", "YES", "YES", "YES", "YES", "YES"),
+                            c("控制朋友特征变量", "YES", "YES", "YES", "YES", "YES", "YES"),
+                            c("固定效应", "YES", "YES", "YES", "YES", "YES", "YES")), #表格展示控制变量信息
+           digits = 3, #数据保留小数点后3位
+           out = "C:/2024-00222+日志文件/tableI1.html")

表I1 不同阈值设定下的学业表现同群效应检验
==================================================================
                              Dependent variable:                 
             -----------------------------------------------------
                              社交网络主体学生学业表现：Score                  
               (1)      (2)      (3)      (4)      (5)      (6)   
------------------------------------------------------------------
GP_Score     0.234*** 0.361*** 0.298*** 0.222*** 0.200*** 0.304***
             (0.061)  (0.032)  (0.024)  (0.020)  (0.020)  (0.025) 
                                                                  
Constant     1.759*** 1.477*** 1.630*** 1.815*** 1.863*** 1.613***
             (0.143)  (0.074)  (0.055)  (0.048)  (0.047)  (0.059) 
                                                                  
------------------------------------------------------------------
控制主体特征变量       YES      YES      YES      YES      YES      YES   
控制朋友特征变量       YES      YES      YES      YES      YES      YES   
固定效应           YES      YES      YES      YES      YES      YES   
Observations  7,578    6,866    5,825    4,707    3,680    6,160  
R2            0.102    0.110    0.119    0.119    0.126    0.115  
==================================================================
Note:                                  *p<0.1; **p<0.05; ***p<0.01

> ################*表I2 剔除饭前有课学生就餐的刷卡记录后重建社交网络的对比分析*#################
> # 写入日志信息
> cat("################*表I2 剔除饭前有课学生就餐的刷卡记录后重建社交网络的对比分析*#################\n")
################*表I2 剔除饭前有课学生就餐的刷卡记录后重建社交网络的对比分析*#################

> # 导入数据
> workdata <- read.csv("C:/2024-00222+使用数据/tableI2.csv",header = T,as.is = T,stringsAsFactors = TRUE)

> # 使用函数转换指定的列为因子
> workdata <- convert_to_factors(workdata)

> # 将数据按照是否剔除就餐记录分组
> workdata_deletedine <- subset(workdata, DeleteDine==1)

> workdata_all <- subset(workdata, DeleteDine==0)

> # 单变量回归
> out.1 <- lm(Score ~ GP_Score, data = workdata_deletedine)

> summary(out.1) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score, data = workdata_deletedine)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.34490 -0.03153  0.00936  0.04088  0.16811 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  1.59641    0.04571   34.92   <2e-16 ***
GP_Score     0.31086    0.01966   15.81   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.0595 on 4430 degrees of freedom
Multiple R-squared:  0.05342,	Adjusted R-squared:  0.0532 
F-statistic:   250 on 1 and 4430 DF,  p-value: < 2.2e-16


> # 控制主体特征变量和固定效应变量
> out.2 <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester, data = workdata_deletedine)

> summary(out.2) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester, data = workdata_deletedine)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.33137 -0.03055  0.00883  0.03862  0.16710 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.7580657  0.0463304  37.946  < 2e-16 ***
GP_Score        0.2420352  0.0196665  12.307  < 2e-16 ***
Rank           -0.3501479  0.0414617  -8.445  < 2e-16 ***
Birth           0.0031366  0.0023257   1.349 0.177507    
Gender         -0.0253720  0.0019339 -13.119  < 2e-16 ***
East            0.0172364  0.0021239   8.116 6.22e-16 ***
Middle          0.0125977  0.0023955   5.259 1.52e-07 ***
Northeast       0.0113566  0.0035615   3.189 0.001439 ** 
Edu             0.0002975  0.0018947   0.157 0.875232    
School2        -0.0272842  0.0074267  -3.674 0.000242 ***
School3        -0.0063403  0.0056631  -1.120 0.262950    
School4        -0.0271062  0.0068738  -3.943 8.16e-05 ***
School5         0.0008443  0.0043006   0.196 0.844361    
School6         0.0014267  0.0046620   0.306 0.759604    
School7        -0.0049923  0.0043832  -1.139 0.254777    
School8         0.0033514  0.0043441   0.771 0.440460    
School9        -0.0090467  0.0042165  -2.146 0.031962 *  
School10       -0.0054490  0.0038019  -1.433 0.151862    
School11        0.0003109  0.0043066   0.072 0.942447    
School12       -0.0043883  0.0054096  -0.811 0.417288    
School13        0.0019300  0.0042739   0.452 0.651593    
School14       -0.0010792  0.0047030  -0.229 0.818519    
School15        0.0005919  0.0045370   0.130 0.896209    
School16       -0.0033664  0.0080419  -0.419 0.675521    
School17        0.0022941  0.0054144   0.424 0.671809    
School18       -0.0094458  0.0046538  -2.030 0.042449 *  
School19       -0.0193482  0.0059205  -3.268 0.001091 ** 
Grade2         -0.0012079  0.0021176  -0.570 0.568439    
Grade3         -0.0019593  0.0028395  -0.690 0.490217    
Semester151602  0.0026168  0.0059245   0.442 0.658741    
Semester161701  0.0018031  0.0051742   0.348 0.727502    
Semester161702  0.0021104  0.0050288   0.420 0.674749    
Semester171801  0.0034996  0.0049941   0.701 0.483501    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.05737 on 4399 degrees of freedom
Multiple R-squared:  0.1262,	Adjusted R-squared:  0.1198 
F-statistic: 19.85 on 32 and 4399 DF,  p-value: < 2.2e-16


> # 控制主体特征变量、朋友特征变量和固定效应变量
> out.3 <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                              GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_deletedine)

> summary(out.3) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_deletedine)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.33229 -0.02987  0.00872  0.03843  0.16828 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.7409880  0.0476725  36.520  < 2e-16 ***
GP_Score        0.2516754  0.0202158  12.449  < 2e-16 ***
Rank           -0.3501636  0.0414632  -8.445  < 2e-16 ***
Birth           0.0032009  0.0023262   1.376 0.168894    
Gender         -0.0265701  0.0025753 -10.317  < 2e-16 ***
East            0.0175269  0.0021274   8.239 2.27e-16 ***
Middle          0.0129377  0.0023973   5.397 7.14e-08 ***
Northeast       0.0117556  0.0035631   3.299 0.000977 ***
Edu             0.0004375  0.0018998   0.230 0.817875    
School2        -0.0265611  0.0074320  -3.574 0.000356 ***
School3        -0.0057246  0.0056722  -1.009 0.312914    
School4        -0.0289899  0.0069067  -4.197 2.75e-05 ***
School5        -0.0004191  0.0043187  -0.097 0.922699    
School6        -0.0005665  0.0047079  -0.120 0.904220    
School7        -0.0048394  0.0044134  -1.097 0.272915    
School8         0.0026146  0.0043664   0.599 0.549339    
School9        -0.0094522  0.0042227  -2.238 0.025243 *  
School10       -0.0059515  0.0038109  -1.562 0.118430    
School11       -0.0003846  0.0043400  -0.089 0.929382    
School12       -0.0043160  0.0054315  -0.795 0.426880    
School13        0.0013596  0.0043493   0.313 0.754598    
School14       -0.0019223  0.0047268  -0.407 0.684271    
School15       -0.0006503  0.0045610  -0.143 0.886633    
School16       -0.0045162  0.0080688  -0.560 0.575708    
School17        0.0014544  0.0054227   0.268 0.788557    
School18       -0.0104612  0.0046817  -2.234 0.025502 *  
School19       -0.0180224  0.0059536  -3.027 0.002483 ** 
Grade2         -0.0011654  0.0021194  -0.550 0.582441    
Grade3         -0.0018260  0.0028466  -0.641 0.521254    
Semester151602  0.0019570  0.0059303   0.330 0.741415    
Semester161701  0.0012546  0.0051829   0.242 0.808740    
Semester161702  0.0017134  0.0050496   0.339 0.734389    
Semester171801  0.0027867  0.0050155   0.556 0.578495    
GP_Rank         0.0463343  0.0603351   0.768 0.442558    
GP_Birth       -0.0002725  0.0032039  -0.085 0.932216    
GP_Gender       0.0023012  0.0031312   0.735 0.462416    
GP_East        -0.0049979  0.0028996  -1.724 0.084843 .  
GP_Middle      -0.0096073  0.0032727  -2.936 0.003346 ** 
GP_Northeast   -0.0089080  0.0049888  -1.786 0.074231 .  
GP_Edu         -0.0015008  0.0025771  -0.582 0.560364    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.05734 on 4392 degrees of freedom
Multiple R-squared:  0.1285,	Adjusted R-squared:  0.1208 
F-statistic: 16.61 on 39 and 4392 DF,  p-value: < 2.2e-16


> # 单变量回归
> out.4 <- lm(Score ~ GP_Score, data = workdata_all)

> summary(out.4) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score, data = workdata_all)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.43136 -0.03120  0.01092  0.04260  0.15921 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  1.41500    0.05623   25.16   <2e-16 ***
GP_Score     0.38727    0.02417   16.02   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06255 on 6158 degrees of freedom
Multiple R-squared:  0.04003,	Adjusted R-squared:  0.03988 
F-statistic: 256.8 on 1 and 6158 DF,  p-value: < 2.2e-16


> # 控制主体特征变量和固定效应变量
> out.5 <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester, data = workdata_all)

> summary(out.5) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester, data = workdata_all)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.41502 -0.03000  0.00885  0.04064  0.16569 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.627e+00  5.628e-02  28.901  < 2e-16 ***
GP_Score        2.981e-01  2.400e-02  12.423  < 2e-16 ***
Rank           -3.527e-01  3.453e-02 -10.214  < 2e-16 ***
Birth           5.704e-03  2.098e-03   2.719  0.00656 ** 
Gender         -2.875e-02  1.709e-03 -16.817  < 2e-16 ***
East            1.593e-02  1.885e-03   8.449  < 2e-16 ***
Middle          1.246e-02  2.143e-03   5.814 6.41e-09 ***
Northeast       7.580e-03  3.168e-03   2.393  0.01676 *  
Edu             2.609e-04  1.683e-03   0.155  0.87682    
School2        -1.798e-02  6.115e-03  -2.940  0.00330 ** 
School3        -4.783e-03  5.132e-03  -0.932  0.35131    
School4        -2.714e-02  6.424e-03  -4.225 2.42e-05 ***
School5        -3.282e-03  3.920e-03  -0.837  0.40251    
School6         2.586e-03  4.255e-03   0.608  0.54341    
School7        -2.208e-03  3.897e-03  -0.567  0.57099    
School8         2.469e-03  3.909e-03   0.632  0.52765    
School9        -1.251e-02  3.839e-03  -3.259  0.00113 ** 
School10       -5.329e-03  3.475e-03  -1.534  0.12519    
School11        5.493e-04  3.931e-03   0.140  0.88888    
School12       -6.066e-03  4.838e-03  -1.254  0.20996    
School13        2.396e-03  3.831e-03   0.625  0.53179    
School14       -7.027e-04  4.330e-03  -0.162  0.87110    
School15       -6.970e-03  4.032e-03  -1.729  0.08392 .  
School16       -8.841e-07  7.329e-03   0.000  0.99990    
School17        1.313e-03  4.640e-03   0.283  0.77717    
School18       -8.657e-03  4.125e-03  -2.099  0.03589 *  
School19       -2.228e-02  5.400e-03  -4.126 3.73e-05 ***
Grade2         -1.744e-03  1.854e-03  -0.941  0.34686    
Grade3         -1.461e-03  2.564e-03  -0.570  0.56892    
Semester151602  2.110e-04  4.937e-03   0.043  0.96592    
Semester161701 -4.898e-04  4.253e-03  -0.115  0.90831    
Semester161702 -2.756e-04  4.143e-03  -0.067  0.94697    
Semester171801  1.589e-03  4.098e-03   0.388  0.69825    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06022 on 6127 degrees of freedom
Multiple R-squared:  0.1145,	Adjusted R-squared:  0.1099 
F-statistic: 24.77 on 32 and 6127 DF,  p-value: < 2.2e-16


> # 控制主体特征变量、朋友特征变量和固定效应变量
> out.6 <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                       GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_all)

> summary(out.6) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_all)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.41675 -0.03008  0.00890  0.04040  0.16520 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.613e+00  5.883e-02  27.426  < 2e-16 ***
GP_Score        3.041e-01  2.497e-02  12.178  < 2e-16 ***
Rank           -3.530e-01  3.456e-02 -10.215  < 2e-16 ***
Birth           5.773e-03  2.099e-03   2.750 0.005976 ** 
Gender         -2.837e-02  1.977e-03 -14.354  < 2e-16 ***
East            1.605e-02  1.890e-03   8.491  < 2e-16 ***
Middle          1.252e-02  2.146e-03   5.835 5.64e-09 ***
Northeast       7.690e-03  3.171e-03   2.425 0.015322 *  
Edu             3.151e-04  1.687e-03   0.187 0.851816    
School2        -1.818e-02  6.135e-03  -2.964 0.003048 ** 
School3        -4.337e-03  5.149e-03  -0.842 0.399696    
School4        -2.830e-02  6.449e-03  -4.389 1.16e-05 ***
School5        -3.928e-03  3.937e-03  -0.998 0.318518    
School6         1.648e-03  4.287e-03   0.384 0.700639    
School7        -2.568e-03  3.925e-03  -0.654 0.513052    
School8         1.717e-03  3.925e-03   0.438 0.661745    
School9        -1.271e-02  3.843e-03  -3.308 0.000945 ***
School10       -5.360e-03  3.483e-03  -1.539 0.123894    
School11        5.844e-05  3.948e-03   0.015 0.988192    
School12       -6.356e-03  4.863e-03  -1.307 0.191252    
School13        1.744e-03  3.876e-03   0.450 0.652777    
School14       -8.818e-04  4.353e-03  -0.203 0.839465    
School15       -7.410e-03  4.046e-03  -1.831 0.067111 .  
School16       -6.190e-04  7.342e-03  -0.084 0.932813    
School17        9.570e-04  4.652e-03   0.206 0.837007    
School18       -9.121e-03  4.149e-03  -2.198 0.027981 *  
School19       -2.189e-02  5.425e-03  -4.035 5.53e-05 ***
Grade2         -1.528e-03  1.857e-03  -0.823 0.410677    
Grade3         -1.377e-03  2.578e-03  -0.534 0.593429    
Semester151602  1.279e-04  4.948e-03   0.026 0.979380    
Semester161701 -2.970e-04  4.283e-03  -0.069 0.944705    
Semester161702  2.042e-04  4.202e-03   0.049 0.961239    
Semester171801  1.841e-03  4.148e-03   0.444 0.657139    
GP_Rank         6.275e-02  6.186e-02   1.014 0.310426    
GP_Birth        3.961e-03  3.975e-03   0.996 0.319112    
GP_Gender      -1.030e-03  3.254e-03  -0.317 0.751523    
GP_East        -6.106e-03  3.737e-03  -1.634 0.102294    
GP_Middle      -2.830e-03  4.092e-03  -0.692 0.489229    
GP_Northeast   -9.093e-03  6.179e-03  -1.472 0.141179    
GP_Edu         -2.419e-03  3.323e-03  -0.728 0.466654    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06022 on 6120 degrees of freedom
Multiple R-squared:  0.1155,	Adjusted R-squared:  0.1099 
F-statistic: 20.49 on 39 and 6120 DF,  p-value: < 2.2e-16


> # 表格输出
> stargazer(out.1, out.2, out.3, out.4, out.5, out.6,
+           type = "text", #输出显示为文本
+           omit = c("Rank", "Birth", "Gender", "East", "Middle", "Northeast", "Edu",
+                    "School", "Grade", "Semester", "GP_Rank", "GP_Birth", "GP_Gender", "GP_East",
+                    "GP_Middle", "GP_Northeast", "GP_Edu"), #隐藏不展示的变量
+           omit.stat = c("f", "ser", "adj.rsq"), #隐藏不展示的信息
+           dep.var.labels = "剔除后学生社交网络学业表现：Score | 全样本学生社交网络学业表现：Score", #因变量标签
+           title = "表I2 剔除饭前有课学生就餐的刷卡记录后重建社交网络的对比分析", #表格标题
+           add.lines = list(c("控制主体特征变量", "NO", "YES", "YES", "NO", "YES", "YES"),
+                            c("控制朋友特征变量", "NO", "NO", "YES", "NO", "NO", "YES"),
+                            c("固定效应", "NO", "YES", "YES", "NO", "YES", "YES")), #表格展示控制变量信息
+           digits = 3, #数据保留小数点后3位
+           out = "C:/2024-00222+日志文件/tableI2.html")

表I2 剔除饭前有课学生就餐的刷卡记录后重建社交网络的对比分析
==================================================================
                              Dependent variable:                 
             -----------------------------------------------------
                   剔除后学生社交网络学业表现：Score | 全样本学生社交网络学业表现：Score      
               (1)      (2)      (3)      (4)      (5)      (6)   
------------------------------------------------------------------
GP_Score     0.311*** 0.242*** 0.252*** 0.387*** 0.298*** 0.304***
             (0.020)  (0.020)  (0.020)  (0.024)  (0.024)  (0.025) 
                                                                  
Constant     1.596*** 1.758*** 1.741*** 1.415*** 1.627*** 1.613***
             (0.046)  (0.046)  (0.048)  (0.056)  (0.056)  (0.059) 
                                                                  
------------------------------------------------------------------
控制主体特征变量        NO      YES      YES       NO      YES      YES   
控制朋友特征变量        NO       NO      YES       NO       NO      YES   
固定效应            NO      YES      YES       NO      YES      YES   
Observations  4,432    4,432    4,432    6,160    6,160    6,160  
R2            0.053    0.126    0.129    0.040    0.115    0.115  
==================================================================
Note:                                  *p<0.1; **p<0.05; ***p<0.01

> ################*表I3 周末与工作日就餐学生社交网络对比分析*#################
> # 写入日志信息
> cat("################*表I3 周末与工作日就餐学生社交网络对比分析*#################\n")
################*表I3 周末与工作日就餐学生社交网络对比分析*#################

> # 导入数据
> workdata <- read.csv("C:/2024-00222+使用数据/tableI3.csv",header = T,as.is = T,stringsAsFactors = TRUE)

> # 使用函数转换指定的列为因子
> workdata <- convert_to_factors(workdata)

> # 将数据按照是否是周末记录分组
> workdata_weekend <- subset(workdata, Weekend==1)

> workdata_weekday <- subset(workdata, Weekend==0)

> # 单变量回归
> out.1 <- lm(Score ~ GP_Score, data = workdata_weekend)

> summary(out.1) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score, data = workdata_weekend)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.45306 -0.03224  0.01157  0.04442  0.15272 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  1.60625    0.06488   24.76   <2e-16 ***
GP_Score     0.30473    0.02789   10.93   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06467 on 6488 degrees of freedom
Multiple R-squared:  0.01807,	Adjusted R-squared:  0.01792 
F-statistic: 119.4 on 1 and 6488 DF,  p-value: < 2.2e-16


> # 控制主体特征变量和固定效应变量
> out.2 <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester, data = workdata_weekend)

> summary(out.2) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester, data = workdata_weekend)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.42930 -0.03068  0.00905  0.04222  0.14816 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.7606220  0.0633501  27.792  < 2e-16 ***
GP_Score        0.2420330  0.0270537   8.946  < 2e-16 ***
Rank           -0.3575209  0.0356882 -10.018  < 2e-16 ***
Birth           0.0059310  0.0020845   2.845  0.00445 ** 
Gender         -0.0333587  0.0016766 -19.897  < 2e-16 ***
East            0.0160637  0.0018889   8.504  < 2e-16 ***
Middle          0.0109734  0.0021232   5.168 2.43e-07 ***
Northeast       0.0037867  0.0031932   1.186  0.23572    
Edu            -0.0021072  0.0016819  -1.253  0.21029    
School2        -0.0198682  0.0061577  -3.227  0.00126 ** 
School3        -0.0069351  0.0050869  -1.363  0.17283    
School4        -0.0280007  0.0064049  -4.372 1.25e-05 ***
School5        -0.0068269  0.0039225  -1.740  0.08183 .  
School6        -0.0022605  0.0041320  -0.547  0.58436    
School7        -0.0064168  0.0039553  -1.622  0.10479    
School8         0.0015704  0.0039061   0.402  0.68767    
School9        -0.0157982  0.0038179  -4.138 3.55e-05 ***
School10       -0.0076322  0.0034614  -2.205  0.02749 *  
School11        0.0007774  0.0039566   0.196  0.84424    
School12       -0.0079912  0.0049394  -1.618  0.10575    
School13        0.0013266  0.0038256   0.347  0.72878    
School14       -0.0044024  0.0043815  -1.005  0.31505    
School15       -0.0109103  0.0039808  -2.741  0.00615 ** 
School16       -0.0017568  0.0069721  -0.252  0.80106    
School17       -0.0055176  0.0045505  -1.213  0.22536    
School18       -0.0115241  0.0041008  -2.810  0.00497 ** 
School19       -0.0246169  0.0055486  -4.437 9.29e-06 ***
Grade2          0.0006208  0.0018217   0.341  0.73328    
Grade3         -0.0005347  0.0025706  -0.208  0.83524    
Semester151602  0.0020782  0.0050879   0.408  0.68294    
Semester161701 -0.0015270  0.0043183  -0.354  0.72363    
Semester161702  0.0007099  0.0042368   0.168  0.86693    
Semester171801  0.0019640  0.0041780   0.470  0.63832    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06191 on 6457 degrees of freedom
Multiple R-squared:  0.1045,	Adjusted R-squared:  0.1001 
F-statistic: 23.54 on 32 and 6457 DF,  p-value: < 2.2e-16


> # 控制主体特征变量、朋友特征变量和固定效应变量
> out.3 <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+               GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_weekend)

> summary(out.3) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_weekend)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.43045 -0.03164  0.00900  0.04205  0.16004 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.756e+00  6.571e-02  26.727  < 2e-16 ***
GP_Score        2.493e-01  2.791e-02   8.933  < 2e-16 ***
Rank           -3.572e-01  3.565e-02 -10.021  < 2e-16 ***
Birth           6.402e-03  2.083e-03   3.073  0.00213 ** 
Gender         -3.331e-02  1.730e-03 -19.252  < 2e-16 ***
East            1.643e-02  1.889e-03   8.697  < 2e-16 ***
Middle          1.110e-02  2.121e-03   5.232 1.73e-07 ***
Northeast       4.053e-03  3.190e-03   1.270  0.20398    
Edu            -1.892e-03  1.680e-03  -1.126  0.26023    
School2        -1.961e-02  6.149e-03  -3.190  0.00143 ** 
School3        -6.870e-03  5.080e-03  -1.352  0.17629    
School4        -2.822e-02  6.400e-03  -4.410 1.05e-05 ***
School5        -7.312e-03  3.918e-03  -1.866  0.06203 .  
School6        -2.493e-03  4.127e-03  -0.604  0.54571    
School7        -5.755e-03  3.960e-03  -1.453  0.14622    
School8         1.568e-03  3.902e-03   0.402  0.68778    
School9        -1.590e-02  3.814e-03  -4.170 3.09e-05 ***
School10       -7.993e-03  3.458e-03  -2.312  0.02084 *  
School11       -3.196e-05  3.955e-03  -0.008  0.99355    
School12       -8.286e-03  4.935e-03  -1.679  0.09318 .  
School13        1.003e-03  3.824e-03   0.262  0.79302    
School14       -5.165e-03  4.378e-03  -1.180  0.23808    
School15       -1.095e-02  3.974e-03  -2.755  0.00589 ** 
School16       -2.189e-03  6.960e-03  -0.315  0.75313    
School17       -6.475e-03  4.547e-03  -1.424  0.15444    
School18       -1.215e-02  4.105e-03  -2.960  0.00309 ** 
School19       -2.532e-02  5.548e-03  -4.564 5.10e-06 ***
Grade2          5.126e-04  1.819e-03   0.282  0.77807    
Grade3         -1.756e-04  2.576e-03  -0.068  0.94566    
Semester151602  1.591e-03  5.117e-03   0.311  0.75582    
Semester161701 -2.280e-03  4.393e-03  -0.519  0.60368    
Semester161702 -5.089e-04  4.332e-03  -0.117  0.90648    
Semester171801  5.681e-04  4.293e-03   0.132  0.89472    
GP_Rank         5.517e-02  7.080e-02   0.779  0.43587    
GP_Birth       -4.914e-03  4.578e-03  -1.073  0.28321    
GP_Gender       2.080e-03  3.588e-03   0.580  0.56222    
GP_East        -7.579e-03  4.188e-03  -1.810  0.07039 .  
GP_Middle      -3.600e-03  4.658e-03  -0.773  0.43970    
GP_Northeast    9.407e-04  7.366e-03   0.128  0.89839    
GP_Edu         -1.490e-02  3.753e-03  -3.972 7.21e-05 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.0618 on 6450 degrees of freedom
Multiple R-squared:  0.1088,	Adjusted R-squared:  0.1034 
F-statistic: 20.19 on 39 and 6450 DF,  p-value: < 2.2e-16


> # 单变量回归
> out.4 <- lm(Score ~ GP_Score, data = workdata_weekday)

> summary(out.4) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score, data = workdata_weekday)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.45400 -0.03213  0.01123  0.04379  0.17687 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  1.26987    0.07114   17.85   <2e-16 ***
GP_Score     0.44896    0.03057   14.69   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06384 on 6776 degrees of freedom
Multiple R-squared:  0.03085,	Adjusted R-squared:  0.03071 
F-statistic: 215.7 on 1 and 6776 DF,  p-value: < 2.2e-16


> # 控制主体特征变量和固定效应变量
> out.5 <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester, data = workdata_weekday)

> summary(out.5) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester, data = workdata_weekday)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.42958 -0.03095  0.00910  0.04162  0.15469 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.5338860  0.0703165  21.814  < 2e-16 ***
GP_Score        0.3388515  0.0300812  11.265  < 2e-16 ***
Rank           -0.3647100  0.0330145 -11.047  < 2e-16 ***
Birth           0.0052790  0.0020501   2.575 0.010043 *  
Gender         -0.0304289  0.0016492 -18.451  < 2e-16 ***
East            0.0158185  0.0018329   8.630  < 2e-16 ***
Middle          0.0119943  0.0020923   5.733 1.03e-08 ***
Northeast       0.0046218  0.0030653   1.508 0.131657    
Edu            -0.0003622  0.0016316  -0.222 0.824341    
School2        -0.0198489  0.0058146  -3.414 0.000645 ***
School3        -0.0055509  0.0049498  -1.121 0.262140    
School4        -0.0252931  0.0063207  -4.002 6.36e-05 ***
School5        -0.0054998  0.0038189  -1.440 0.149866    
School6         0.0001866  0.0040802   0.046 0.963525    
School7        -0.0049759  0.0037619  -1.323 0.185975    
School8         0.0016986  0.0038327   0.443 0.657642    
School9        -0.0121354  0.0037488  -3.237 0.001213 ** 
School10       -0.0070237  0.0033785  -2.079 0.037660 *  
School11        0.0017961  0.0038509   0.466 0.640927    
School12       -0.0098778  0.0047190  -2.093 0.036369 *  
School13        0.0012507  0.0037529   0.333 0.738954    
School14       -0.0011470  0.0042118  -0.272 0.785381    
School15       -0.0084045  0.0039186  -2.145 0.032006 *  
School16       -0.0014938  0.0069017  -0.216 0.828648    
School17       -0.0038531  0.0044460  -0.867 0.386163    
School18       -0.0099080  0.0040063  -2.473 0.013419 *  
School19       -0.0249462  0.0052267  -4.773 1.85e-06 ***
Grade2         -0.0008617  0.0017819  -0.484 0.628683    
Grade3          0.0010475  0.0024499   0.428 0.668974    
Semester151602  0.0012756  0.0050213   0.254 0.799478    
Semester161701 -0.0019460  0.0042536  -0.457 0.647334    
Semester161702 -0.0004746  0.0041816  -0.114 0.909634    
Semester171801 -0.0006568  0.0041064  -0.160 0.872920    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06137 on 6745 degrees of freedom
Multiple R-squared:  0.1083,	Adjusted R-squared:  0.104 
F-statistic: 25.59 on 32 and 6745 DF,  p-value: < 2.2e-16


> # 控制主体特征变量、朋友特征变量和固定效应变量
> out.6 <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+               GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_weekday)

> summary(out.6) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_weekday)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.42876 -0.03086  0.00897  0.04141  0.14989 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.533e+00  7.403e-02  20.703  < 2e-16 ***
GP_Score        3.382e-01  3.150e-02  10.735  < 2e-16 ***
Rank           -3.673e-01  3.305e-02 -11.113  < 2e-16 ***
Birth           5.317e-03  2.053e-03   2.590 0.009615 ** 
Gender         -2.967e-02  1.796e-03 -16.520  < 2e-16 ***
East            1.584e-02  1.837e-03   8.623  < 2e-16 ***
Middle          1.183e-02  2.095e-03   5.645 1.72e-08 ***
Northeast       4.550e-03  3.069e-03   1.482 0.138289    
Edu            -3.167e-04  1.634e-03  -0.194 0.846337    
School2        -2.047e-02  5.830e-03  -3.511 0.000449 ***
School3        -4.914e-03  4.967e-03  -0.989 0.322596    
School4        -2.632e-02  6.335e-03  -4.155 3.29e-05 ***
School5        -6.221e-03  3.830e-03  -1.624 0.104344    
School6        -8.980e-04  4.108e-03  -0.219 0.826976    
School7        -5.685e-03  3.802e-03  -1.495 0.134947    
School8         9.338e-04  3.845e-03   0.243 0.808100    
School9        -1.240e-02  3.752e-03  -3.305 0.000954 ***
School10       -7.232e-03  3.388e-03  -2.135 0.032818 *  
School11        1.163e-03  3.864e-03   0.301 0.763417    
School12       -1.053e-02  4.730e-03  -2.227 0.026000 *  
School13        6.929e-05  3.790e-03   0.018 0.985416    
School14       -1.465e-03  4.231e-03  -0.346 0.729142    
School15       -8.990e-03  3.925e-03  -2.290 0.022031 *  
School16       -1.881e-03  6.913e-03  -0.272 0.785600    
School17       -4.421e-03  4.455e-03  -0.992 0.321141    
School18       -1.055e-02  4.027e-03  -2.620 0.008808 ** 
School19       -2.577e-02  5.252e-03  -4.908 9.43e-07 ***
Grade2         -6.724e-04  1.784e-03  -0.377 0.706222    
Grade3          9.287e-04  2.457e-03   0.378 0.705493    
Semester151602  8.354e-04  5.039e-03   0.166 0.868326    
Semester161701 -1.541e-03  4.304e-03  -0.358 0.720270    
Semester161702  2.519e-04  4.265e-03   0.059 0.952908    
Semester171801  6.707e-05  4.183e-03   0.016 0.987209    
GP_Rank         1.388e-01  7.958e-02   1.744 0.081138 .  
GP_Birth        7.479e-03  5.081e-03   1.472 0.141128    
GP_Gender      -3.544e-03  3.794e-03  -0.934 0.350308    
GP_East        -7.880e-05  4.728e-03  -0.017 0.986704    
GP_Middle      -2.498e-04  5.195e-03  -0.048 0.961657    
GP_Northeast   -7.511e-03  8.034e-03  -0.935 0.349873    
GP_Edu         -7.596e-03  4.132e-03  -1.838 0.066041 .  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06136 on 6738 degrees of freedom
Multiple R-squared:  0.1095,	Adjusted R-squared:  0.1044 
F-statistic: 21.25 on 39 and 6738 DF,  p-value: < 2.2e-16


> # 表格输出
> stargazer(out.1, out.2, out.3, out.4, out.5, out.6,
+           type = "text", #输出显示为文本
+           omit = c("Rank", "Birth", "Gender", "East", "Middle", "Northeast", "Edu",
+                    "School", "Grade", "Semester", "GP_Rank", "GP_Birth", "GP_Gender", "GP_East",
+                    "GP_Middle", "GP_Northeast", "GP_Edu"), #隐藏不展示的变量
+           omit.stat = c("f", "ser", "adj.rsq"), #隐藏不展示的信息
+           dep.var.labels = "周末就餐社交网络学业表现：Score	| 工作日就餐社交网络学业表现：Score", #因变量标签
+           title = "表I3 周末与工作日就餐学生社交网络对比分析", #表格标题
+           add.lines = list(c("控制主体特征变量", "NO", "YES", "YES", "NO", "YES", "YES"),
+                            c("控制朋友特征变量", "NO", "NO", "YES", "NO", "NO", "YES"),
+                            c("固定效应", "NO", "YES", "YES", "NO", "YES", "YES")), #表格展示控制变量信息
+           digits = 3, #数据保留小数点后3位
+           out = "C:/2024-00222+日志文件/tableI3.html")

表I3 周末与工作日就餐学生社交网络对比分析
==================================================================
                              Dependent variable:                 
             -----------------------------------------------------
                   周末就餐社交网络学业表现：Score	| 工作日就餐社交网络学业表现：Score       
               (1)      (2)      (3)      (4)      (5)      (6)   
------------------------------------------------------------------
GP_Score     0.305*** 0.242*** 0.249*** 0.449*** 0.339*** 0.338***
             (0.028)  (0.027)  (0.028)  (0.031)  (0.030)  (0.032) 
                                                                  
Constant     1.606*** 1.761*** 1.756*** 1.270*** 1.534*** 1.533***
             (0.065)  (0.063)  (0.066)  (0.071)  (0.070)  (0.074) 
                                                                  
------------------------------------------------------------------
控制主体特征变量        NO      YES      YES       NO      YES      YES   
控制朋友特征变量        NO       NO      YES       NO       NO      YES   
固定效应            NO      YES      YES       NO      YES      YES   
Observations  6,490    6,490    6,490    6,778    6,778    6,778  
R2            0.018    0.104    0.109    0.031    0.108    0.110  
==================================================================
Note:                                  *p<0.1; **p<0.05; ***p<0.01

> ################*表II1 同群效应的情感投入机制的深入分析*#################
> # 写入日志信息
> cat("################*表II1 同群效应的情感投入机制的深入分析*#################\n")
################*表II1 同群效应的情感投入机制的深入分析*#################

> # 导入数据
> workdata <- read.csv("C:/2024-00222+使用数据/tableII1.csv",header = T,as.is = T,stringsAsFactors = TRUE)

> # 使用函数转换指定的列为因子
> workdata <- convert_to_factors(workdata)

> # 数据分成较低较低成绩群体和较高成绩群体
> workdata_lowScore <- subset(workdata, LowScore==1)

> workdata_highScore <- subset(workdata, LowScore==0)

> # 全样本（1和2）、较低较低成绩群体（3和4）、较高成绩群体（5和6）分组回归
> # PanelA 情感投入的渠道--专业满意
> out.A1 <- lm(S_major~GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata)

> summary(out.A1) # 回归原始结果输出

Call:
lm(formula = S_major ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata)

Residuals:
     Min       1Q   Median       3Q      Max 
-1.45330 -0.76879 -0.04823  0.96272  1.62890 

Coefficients:
                Estimate Std. Error t value Pr(>|t|)    
(Intercept)    -1.982876   0.834824  -2.375 0.017570 *  
GP_Score        1.198964   0.354343   3.384 0.000720 ***
Rank            1.058859   0.490467   2.159 0.030898 *  
Birth           0.019791   0.029790   0.664 0.506497    
Gender          0.045004   0.028048   1.605 0.108648    
East            0.054441   0.026824   2.030 0.042447 *  
Middle          0.051942   0.030451   1.706 0.088104 .  
Northeast       0.018168   0.044994   0.404 0.686383    
Edu            -0.033617   0.023936  -1.404 0.160237    
School2         0.156497   0.087061   1.798 0.072295 .  
School3         0.264072   0.073069   3.614 0.000304 ***
School4        -0.071860   0.091510  -0.785 0.432325    
School5         0.224482   0.055871   4.018 5.94e-05 ***
School6        -0.164521   0.060840  -2.704 0.006866 ** 
School7        -0.146577   0.055703  -2.631 0.008525 ** 
School8         0.111633   0.055697   2.004 0.045083 *  
School9         0.005073   0.054535   0.093 0.925885    
School10       -0.082561   0.049427  -1.670 0.094901 .  
School11        0.006619   0.056030   0.118 0.905972    
School12       -0.147365   0.069009  -2.135 0.032763 *  
School13       -0.184817   0.055009  -3.360 0.000785 ***
School14        0.022378   0.061766   0.362 0.717135    
School15       -0.127299   0.057418  -2.217 0.026656 *  
School16       -0.141982   0.104183  -1.363 0.172994    
School17       -0.237005   0.066011  -3.590 0.000333 ***
School18       -0.192335   0.058883  -3.266 0.001095 ** 
School19       -0.091916   0.076987  -1.194 0.232558    
Grade2         -0.029261   0.026356  -1.110 0.266950    
Grade3          0.237695   0.036589   6.496 8.87e-11 ***
Semester151602  0.063227   0.070221   0.900 0.367944    
Semester161701  0.012513   0.060774   0.206 0.836884    
Semester161702 -0.012292   0.059632  -0.206 0.836690    
Semester171801 -0.027238   0.058859  -0.463 0.643541    
GP_Rank         0.700432   0.877854   0.798 0.424965    
GP_Birth        0.100995   0.056409   1.790 0.073440 .  
GP_Gender       0.002984   0.046181   0.065 0.948484    
GP_East        -0.045895   0.053025  -0.866 0.386773    
GP_Middle      -0.143065   0.058073  -2.464 0.013785 *  
GP_Northeast    0.051424   0.087685   0.586 0.557592    
GP_Edu         -0.105389   0.047162  -2.235 0.025480 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.8546 on 6120 degrees of freedom
Multiple R-squared:  0.03956,	Adjusted R-squared:  0.03344 
F-statistic: 6.464 on 39 and 6120 DF,  p-value: < 2.2e-16


> out.A2 <- lm(Score~S_major+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata)

> summary(out.A2) # 回归原始结果输出

Call:
lm(formula = Score ~ S_major + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.41980 -0.02971  0.00927  0.04075  0.16002 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     2.319e+00  6.164e-03 376.156  < 2e-16 ***
S_major         8.816e-03  9.038e-04   9.755  < 2e-16 ***
Rank           -3.663e-01  3.472e-02 -10.549  < 2e-16 ***
Birth           5.211e-03  2.108e-03   2.472 0.013463 *  
Gender         -2.968e-02  1.984e-03 -14.964  < 2e-16 ***
East            1.570e-02  1.899e-03   8.270  < 2e-16 ***
Middle          1.219e-02  2.156e-03   5.655 1.63e-08 ***
Northeast       7.003e-03  3.184e-03   2.199 0.027882 *  
Edu             4.633e-04  1.694e-03   0.273 0.784486    
School2        -2.861e-02  6.114e-03  -4.680 2.93e-06 ***
School3        -8.377e-03  5.174e-03  -1.619 0.105490    
School4        -3.363e-02  6.457e-03  -5.209 1.96e-07 ***
School5        -6.254e-03  3.959e-03  -1.580 0.114209    
School6         2.420e-03  4.308e-03   0.562 0.574285    
School7        -1.751e-03  3.944e-03  -0.444 0.657068    
School8         9.635e-04  3.943e-03   0.244 0.806967    
School9        -1.404e-02  3.858e-03  -3.639 0.000276 ***
School10       -6.128e-03  3.497e-03  -1.753 0.079731 .  
School11        7.711e-05  3.965e-03   0.019 0.984486    
School12       -7.084e-03  4.883e-03  -1.451 0.146868    
School13        2.723e-03  3.896e-03   0.699 0.484589    
School14       -3.200e-03  4.367e-03  -0.733 0.463804    
School15       -7.331e-03  4.064e-03  -1.804 0.071327 .  
School16       -7.158e-04  7.373e-03  -0.097 0.922671    
School17        2.786e-03  4.676e-03   0.596 0.551309    
School18       -9.948e-03  4.166e-03  -2.388 0.016969 *  
School19       -2.340e-02  5.446e-03  -4.297 1.76e-05 ***
Grade2         -1.764e-03  1.865e-03  -0.946 0.344249    
Grade3         -4.288e-03  2.597e-03  -1.651 0.098749 .  
Semester151602  1.416e-03  4.967e-03   0.285 0.775630    
Semester161701  6.159e-04  4.300e-03   0.143 0.886103    
Semester161702  2.660e-03  4.215e-03   0.631 0.528027    
Semester171801  3.372e-03  4.164e-03   0.810 0.418060    
GP_Rank        -5.170e-02  6.143e-02  -0.842 0.400021    
GP_Birth        9.157e-04  3.989e-03   0.230 0.818426    
GP_Gender      -9.159e-03  3.194e-03  -2.867 0.004154 ** 
GP_East        -2.330e-03  3.742e-03  -0.623 0.533431    
GP_Middle       1.871e-03  4.101e-03   0.456 0.648221    
GP_Northeast   -7.062e-03  6.202e-03  -1.139 0.254880    
GP_Edu         -2.232e-03  3.338e-03  -0.669 0.503792    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06048 on 6120 degrees of freedom
Multiple R-squared:  0.1079,	Adjusted R-squared:  0.1022 
F-statistic: 18.98 on 39 and 6120 DF,  p-value: < 2.2e-16


> out.A3 <- lm(S_major~GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_lowScore)

> summary(out.A3) # 回归原始结果输出

Call:
lm(formula = S_major ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_lowScore)

Residuals:
    Min      1Q  Median      3Q     Max 
-1.3575 -0.7046 -0.3844  0.9237  1.6214 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)    -0.9407400  1.0146228  -0.927  0.35391    
GP_Score        0.7832069  0.4285478   1.828  0.06771 .  
Rank            1.6417646  0.5257708   3.123  0.00181 ** 
Birth          -0.0390305  0.0421037  -0.927  0.35400    
Gender          0.0601857  0.0380706   1.581  0.11401    
East            0.0728013  0.0366885   1.984  0.04731 *  
Middle          0.0544328  0.0421507   1.291  0.19667    
Northeast       0.0009259  0.0639862   0.014  0.98846    
Edu            -0.0137585  0.0334951  -0.411  0.68128    
School2         0.2565345  0.1059176   2.422  0.01549 *  
School3         0.2820263  0.1043231   2.703  0.00690 ** 
School4        -0.2293466  0.1173968  -1.954  0.05084 .  
School5         0.1919373  0.0799411   2.401  0.01641 *  
School6         0.0084169  0.0870328   0.097  0.92296    
School7         0.0379360  0.0795699   0.477  0.63357    
School8         0.1700909  0.0792897   2.145  0.03202 *  
School9        -0.0287716  0.0739812  -0.389  0.69737    
School10        0.0203245  0.0696255   0.292  0.77037    
School11       -0.0103330  0.0804233  -0.128  0.89778    
School12       -0.1031241  0.0933741  -1.104  0.26950    
School13       -0.1261640  0.0782484  -1.612  0.10699    
School14        0.0067972  0.0871833   0.078  0.93786    
School15       -0.2073370  0.0797504  -2.600  0.00937 ** 
School16        0.1015657  0.1474930   0.689  0.49112    
School17       -0.2716088  0.0936822  -2.899  0.00377 ** 
School18       -0.1157398  0.0801196  -1.445  0.14868    
School19       -0.1207771  0.1004425  -1.202  0.22928    
Grade2         -0.0101302  0.0368738  -0.275  0.78355    
Grade3          0.2549742  0.0500158   5.098 3.65e-07 ***
Semester151602  0.0339010  0.0988548   0.343  0.73167    
Semester161701 -0.1120776  0.0857939  -1.306  0.19153    
Semester161702 -0.1199578  0.0842859  -1.423  0.15477    
Semester171801 -0.1305689  0.0831890  -1.570  0.11663    
GP_Rank        -1.4242755  1.2502340  -1.139  0.25471    
GP_Birth        0.0371425  0.0715160   0.519  0.60355    
GP_Gender       0.0391586  0.0597332   0.656  0.51216    
GP_East        -0.0632940  0.0666086  -0.950  0.34207    
GP_Middle      -0.2227190  0.0750893  -2.966  0.00304 ** 
GP_Northeast   -0.0474877  0.1106111  -0.429  0.66772    
GP_Edu         -0.1000611  0.0601789  -1.663  0.09647 .  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.8345 on 3040 degrees of freedom
Multiple R-squared:  0.04694,	Adjusted R-squared:  0.03472 
F-statistic:  3.84 on 39 and 3040 DF,  p-value: 1.893e-14


> out.A4 <- lm(Score~S_major+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_lowScore)

> summary(out.A4) # 回归原始结果输出

Call:
lm(formula = Score ~ S_major + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_lowScore)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.38670 -0.02240  0.01375  0.03610  0.10964 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     2.282e+00  7.686e-03 296.877  < 2e-16 ***
S_major         3.863e-03  1.156e-03   3.341 0.000846 ***
Rank           -1.781e-01  3.359e-02  -5.301 1.24e-07 ***
Birth           6.368e-03  2.685e-03   2.372 0.017760 *  
Gender         -1.987e-02  2.429e-03  -8.181 4.09e-16 ***
East            2.915e-03  2.341e-03   1.245 0.213237    
Middle          3.159e-03  2.690e-03   1.175 0.240212    
Northeast      -7.918e-03  4.081e-03  -1.940 0.052420 .  
Edu             6.252e-04  2.136e-03   0.293 0.769783    
School2        -1.377e-02  6.706e-03  -2.053 0.040147 *  
School3        -1.513e-02  6.660e-03  -2.272 0.023168 *  
School4        -4.123e-02  7.476e-03  -5.516 3.76e-08 ***
School5        -6.918e-03  5.104e-03  -1.355 0.175405    
School6        -1.302e-03  5.552e-03  -0.235 0.814561    
School7        -9.464e-03  5.075e-03  -1.865 0.062312 .  
School8        -2.119e-03  5.062e-03  -0.419 0.675454    
School9        -1.276e-02  4.718e-03  -2.705 0.006861 ** 
School10       -3.718e-03  4.438e-03  -0.838 0.402166    
School11       -5.199e-03  5.130e-03  -1.013 0.310970    
School12       -3.209e-03  5.954e-03  -0.539 0.589982    
School13       -2.003e-03  4.990e-03  -0.401 0.688207    
School14        7.578e-04  5.553e-03   0.136 0.891465    
School15       -1.394e-02  5.093e-03  -2.737 0.006229 ** 
School16       -1.235e-02  9.406e-03  -1.313 0.189227    
School17        1.622e-04  5.983e-03   0.027 0.978376    
School18       -5.023e-03  5.103e-03  -0.984 0.325046    
School19       -1.094e-02  6.407e-03  -1.707 0.087881 .  
Grade2         -3.205e-03  2.351e-03  -1.363 0.172990    
Grade3          1.691e-04  3.202e-03   0.053 0.957874    
Semester151602  2.362e-03  6.305e-03   0.375 0.707917    
Semester161701 -7.357e-04  5.474e-03  -0.134 0.893099    
Semester161702  2.196e-05  5.376e-03   0.004 0.996741    
Semester171801  8.184e-04  5.309e-03   0.154 0.877486    
GP_Rank        -5.120e-02  7.910e-02  -0.647 0.517542    
GP_Birth        3.242e-03  4.554e-03   0.712 0.476534    
GP_Gender      -1.325e-02  3.713e-03  -3.567 0.000366 ***
GP_East        -4.082e-03  4.239e-03  -0.963 0.335693    
GP_Middle       3.708e-03  4.790e-03   0.774 0.438980    
GP_Northeast   -8.131e-03  7.054e-03  -1.153 0.249150    
GP_Edu         -9.789e-04  3.838e-03  -0.255 0.798714    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.05324 on 3040 degrees of freedom
Multiple R-squared:  0.08555,	Adjusted R-squared:  0.07382 
F-statistic: 7.293 on 39 and 3040 DF,  p-value: < 2.2e-16


> out.A5 <- lm(S_major~GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_highScore)

> summary(out.A5) # 回归原始结果输出

Call:
lm(formula = S_major ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_highScore)

Residuals:
     Min       1Q   Median       3Q      Max 
-1.53474 -0.80339 -0.01588  0.89665  1.49546 

Coefficients:
                Estimate Std. Error t value Pr(>|t|)    
(Intercept)    -1.594147   1.464409  -1.089 0.276419    
GP_Score        0.991564   0.625409   1.585 0.112965    
Rank            0.412547   1.353539   0.305 0.760546    
Birth           0.093961   0.041848   2.245 0.024823 *  
Gender          0.098378   0.041871   2.350 0.018860 *  
East            0.004780   0.040229   0.119 0.905434    
Middle          0.021670   0.044017   0.492 0.622536    
Northeast       0.020646   0.063276   0.326 0.744233    
Edu            -0.055728   0.034180  -1.630 0.103118    
School2         0.116925   0.154536   0.757 0.449337    
School3         0.239934   0.100983   2.376 0.017564 *  
School4         0.222049   0.144024   1.542 0.123237    
School5         0.252274   0.077166   3.269 0.001090 ** 
School6        -0.305301   0.084123  -3.629 0.000289 ***
School7        -0.315253   0.077579  -4.064 4.95e-05 ***
School8         0.065613   0.077461   0.847 0.397036    
School9         0.117941   0.080578   1.464 0.143384    
School10       -0.164856   0.069289  -2.379 0.017409 *  
School11        0.009821   0.077730   0.126 0.899464    
School12       -0.152782   0.100956  -1.513 0.130295    
School13       -0.224021   0.076729  -2.920 0.003530 ** 
School14        0.061051   0.086665   0.704 0.481208    
School15       -0.022741   0.081757  -0.278 0.780910    
School16       -0.357867   0.145437  -2.461 0.013924 *  
School17       -0.193634   0.092041  -2.104 0.035479 *  
School18       -0.235319   0.085725  -2.745 0.006086 ** 
School19        0.049406   0.118810   0.416 0.677557    
Grade2         -0.035897   0.037383  -0.960 0.337008    
Grade3          0.236623   0.052994   4.465 8.29e-06 ***
Semester151602  0.079563   0.098326   0.809 0.418481    
Semester161701  0.125791   0.085020   1.480 0.139099    
Semester161702  0.069321   0.083389   0.831 0.405867    
Semester171801  0.054718   0.082225   0.665 0.505803    
GP_Rank         2.202497   1.221109   1.804 0.071380 .  
GP_Birth        0.155977   0.089873   1.736 0.082749 .  
GP_Gender      -0.064000   0.071684  -0.893 0.372032    
GP_East        -0.031565   0.085347  -0.370 0.711526    
GP_Middle      -0.032335   0.090002  -0.359 0.719422    
GP_Northeast    0.211749   0.140135   1.511 0.130884    
GP_Edu         -0.078237   0.074524  -1.050 0.293887    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.8586 on 3040 degrees of freedom
Multiple R-squared:  0.05905,	Adjusted R-squared:  0.04698 
F-statistic: 4.892 on 39 and 3040 DF,  p-value: < 2.2e-16


> out.A6 <- lm(Score~S_major+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_highScore)

> summary(out.A6) # 回归原始结果输出

Call:
lm(formula = Score ~ S_major + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_highScore)

Residuals:
      Min        1Q    Median        3Q       Max 
-0.045241 -0.018669 -0.003246  0.016678  0.078888 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     2.357e+00  3.448e-03 683.548  < 2e-16 ***
S_major         1.785e-03  4.984e-04   3.582 0.000347 ***
Rank           -1.784e-01  3.719e-02  -4.798 1.68e-06 ***
Birth           6.163e-03  1.151e-03   5.354 9.25e-08 ***
Gender         -6.343e-03  1.151e-03  -5.512 3.85e-08 ***
East            6.574e-03  1.106e-03   5.946 3.06e-09 ***
Middle          4.968e-03  1.210e-03   4.105 4.14e-05 ***
Northeast       6.792e-03  1.739e-03   3.905 9.61e-05 ***
Edu            -2.727e-04  9.399e-04  -0.290 0.771716    
School2         4.955e-03  4.232e-03   1.171 0.241690    
School3         4.046e-04  2.776e-03   0.146 0.884143    
School4         1.697e-03  3.943e-03   0.430 0.666885    
School5        -3.227e-03  2.125e-03  -1.519 0.128909    
School6        -7.647e-04  2.317e-03  -0.330 0.741384    
School7         4.537e-04  2.138e-03   0.212 0.831993    
School8         4.173e-03  2.130e-03   1.960 0.050122 .  
School9         2.009e-03  2.215e-03   0.907 0.364415    
School10       -1.279e-03  1.906e-03  -0.671 0.502272    
School11       -9.229e-04  2.137e-03  -0.432 0.665798    
School12        2.124e-03  2.775e-03   0.766 0.443987    
School13        3.911e-03  2.112e-03   1.852 0.064102 .  
School14       -2.860e-03  2.382e-03  -1.201 0.230001    
School15        3.885e-03  2.246e-03   1.730 0.083804 .  
School16        2.571e-03  4.002e-03   0.642 0.520657    
School17        5.269e-03  2.531e-03   2.082 0.037452 *  
School18        3.504e-03  2.359e-03   1.486 0.137473    
School19       -4.877e-04  3.263e-03  -0.149 0.881204    
Grade2          1.989e-03  1.028e-03   1.936 0.052984 .  
Grade3          1.216e-03  1.461e-03   0.832 0.405362    
Semester151602  6.576e-05  2.700e-03   0.024 0.980571    
Semester161701  5.664e-04  2.336e-03   0.242 0.808429    
Semester161702 -2.036e-03  2.287e-03  -0.890 0.373484    
Semester171801 -3.743e-04  2.258e-03  -0.166 0.868340    
GP_Rank        -3.162e-02  3.302e-02  -0.958 0.338269    
GP_Birth       -2.441e-03  2.471e-03  -0.988 0.323320    
GP_Gender       3.583e-03  1.934e-03   1.852 0.064081 .  
GP_East        -1.833e-03  2.336e-03  -0.784 0.432850    
GP_Middle      -2.918e-03  2.460e-03  -1.186 0.235732    
GP_Northeast    2.704e-03  3.847e-03   0.703 0.482209    
GP_Edu          3.534e-04  2.049e-03   0.172 0.863082    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.0236 on 3040 degrees of freedom
Multiple R-squared:  0.05202,	Adjusted R-squared:  0.03985 
F-statistic: 4.277 on 39 and 3040 DF,  p-value: < 2.2e-16


> # 表格PanelA输出
> stargazer(out.A1, out.A2, out.A3, out.A4, out.A5, out.A6,
+           type = "text", #输出显示为文本
+           omit = c("Rank", "Birth", "Gender", "East", "Middle", "Northeast", "Edu",
+                    "School", "Grade", "Semester", "GP_Rank", "GP_Birth", "GP_Gender", "GP_East",
+                    "GP_Middle", "GP_Northeast", "GP_Edu"), #隐藏不展示的变量
+           omit.stat = c("f", "ser", "adj.rsq"), #隐藏不展示的信息
+           title = "表II1 同群效应的情感投入机制的深入分析", #表格标题
+           add.lines = list(c("控制主体特征变量", "YES", "YES", "YES", "YES", "YES", "YES"),
+                            c("控制朋友特征变量", "YES", "YES", "YES", "YES", "YES", "YES"),
+                            c("固定效应", "YES", "YES", "YES", "YES", "YES", "YES")), #表格展示控制变量信息
+           digits = 3, #数据保留小数点后3位
+           out = "C:/2024-00222+日志文件/tableII1-PanelA.html")

表II1 同群效应的情感投入机制的深入分析
================================================================
                             Dependent variable:                
             ---------------------------------------------------
             S_major   Score   S_major  Score   S_major  Score  
               (1)      (2)      (3)     (4)      (5)     (6)   
----------------------------------------------------------------
GP_Score     1.199***          0.783*            0.992          
             (0.354)           (0.429)          (0.625)         
                                                                
S_major               0.009***         0.004***         0.002***
                      (0.001)          (0.001)          (0.0005)
                                                                
Constant     -1.983** 2.319*** -0.941  2.282*** -1.594  2.357***
             (0.835)  (0.006)  (1.015) (0.008)  (1.464) (0.003) 
                                                                
----------------------------------------------------------------
控制主体特征变量       YES      YES      YES     YES      YES     YES   
控制朋友特征变量       YES      YES      YES     YES      YES     YES   
固定效应           YES      YES      YES     YES      YES     YES   
Observations  6,160    6,160    3,080   3,080    3,080   3,080  
R2            0.040    0.108    0.047   0.086    0.059   0.052  
================================================================
Note:                                *p<0.1; **p<0.05; ***p<0.01

> # PanelB 情感投入的渠道--学校满意
> out.B1 <- lm(S_school~GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata)

> summary(out.B1) # 回归原始结果输出

Call:
lm(formula = S_school ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata)

Residuals:
     Min       1Q   Median       3Q      Max 
-1.49824 -0.77279 -0.06315  0.96245  1.49313 

Coefficients:
                Estimate Std. Error t value Pr(>|t|)    
(Intercept)    -1.502879   0.844841  -1.779  0.07531 .  
GP_Score        1.000634   0.358594   2.790  0.00528 ** 
Rank            0.345287   0.496352   0.696  0.48667    
Birth          -0.002372   0.030148  -0.079  0.93729    
Gender          0.112497   0.028385   3.963 7.48e-05 ***
East            0.009101   0.027146   0.335  0.73744    
Middle         -0.013991   0.030817  -0.454  0.64983    
Northeast      -0.029838   0.045534  -0.655  0.51231    
Edu             0.008018   0.024223   0.331  0.74064    
School2         0.053072   0.088105   0.602  0.54695    
School3         0.174668   0.073945   2.362  0.01820 *  
School4         0.174484   0.092608   1.884  0.05960 .  
School5         0.338845   0.056541   5.993 2.18e-09 ***
School6        -0.121581   0.061570  -1.975  0.04835 *  
School7         0.039403   0.056371   0.699  0.48459    
School8         0.137035   0.056365   2.431  0.01508 *  
School9        -0.063083   0.055189  -1.143  0.25307    
School10       -0.018589   0.050020  -0.372  0.71018    
School11       -0.046539   0.056703  -0.821  0.41182    
School12       -0.135495   0.069837  -1.940  0.05240 .  
School13       -0.102851   0.055669  -1.848  0.06472 .  
School14       -0.058937   0.062507  -0.943  0.34577    
School15       -0.042161   0.058107  -0.726  0.46812    
School16        0.112143   0.105433   1.064  0.28753    
School17       -0.080851   0.066803  -1.210  0.22622    
School18       -0.157570   0.059589  -2.644  0.00821 ** 
School19        0.147753   0.077911   1.896  0.05795 .  
Grade2         -0.047353   0.026672  -1.775  0.07589 .  
Grade3          0.258318   0.037028   6.976 3.35e-12 ***
Semester151602  0.049600   0.071064   0.698  0.48523    
Semester161701 -0.027439   0.061503  -0.446  0.65551    
Semester161702 -0.044118   0.060347  -0.731  0.46476    
Semester171801 -0.058006   0.059565  -0.974  0.33018    
GP_Rank         0.916379   0.888387   1.032  0.30234    
GP_Birth        0.022838   0.057086   0.400  0.68912    
GP_Gender       0.002877   0.046735   0.062  0.95091    
GP_East         0.077055   0.053661   1.436  0.15107    
GP_Middle      -0.089174   0.058770  -1.517  0.12923    
GP_Northeast    0.170222   0.088738   1.918  0.05512 .  
GP_Edu         -0.133128   0.047728  -2.789  0.00530 ** 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.8649 on 6120 degrees of freedom
Multiple R-squared:  0.04167,	Adjusted R-squared:  0.03556 
F-statistic: 6.823 on 39 and 6120 DF,  p-value: < 2.2e-16


> out.B2 <- lm(Score~S_school+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata)

> summary(out.B2) # 回归原始结果输出

Call:
lm(formula = Score ~ S_school + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.42357 -0.03014  0.00916  0.04144  0.15211 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     2.3237652  0.0062081 374.312  < 2e-16 ***
S_school        0.0027041  0.0008996   3.006 0.002659 ** 
Rank           -0.3579761  0.0349529 -10.242  < 2e-16 ***
Birth           0.0053816  0.0021227   2.535 0.011263 *  
Gender         -0.0296166  0.0019997 -14.810  < 2e-16 ***
East            0.0161638  0.0019116   8.456  < 2e-16 ***
Middle          0.0126879  0.0021701   5.847 5.27e-09 ***
Northeast       0.0072297  0.0032063   2.255 0.024179 *  
Edu             0.0001413  0.0017058   0.083 0.933973    
School2        -0.0276185  0.0061554  -4.487 7.36e-06 ***
School3        -0.0065674  0.0052074  -1.261 0.207297    
School4        -0.0348968  0.0065027  -5.366 8.32e-08 ***
School5        -0.0052009  0.0039931  -1.302 0.192806    
School6         0.0012802  0.0043368   0.295 0.767846    
School7        -0.0031627  0.0039696  -0.797 0.425645    
School8         0.0015832  0.0039711   0.399 0.690140    
School9        -0.0138562  0.0038853  -3.566 0.000365 ***
School10       -0.0068455  0.0035202  -1.945 0.051862 .  
School11        0.0002634  0.0039932   0.066 0.947417    
School12       -0.0080712  0.0049165  -1.642 0.100711    
School13        0.0013548  0.0039210   0.346 0.729716    
School14       -0.0028999  0.0043984  -0.659 0.509718    
School15       -0.0083669  0.0040911  -2.045 0.040885 *  
School16       -0.0023068  0.0074244  -0.311 0.756030    
School17        0.0009086  0.0047048   0.193 0.846866    
School18       -0.0112847  0.0041934  -2.691 0.007141 ** 
School19       -0.0246693  0.0054843  -4.498 6.98e-06 ***
Grade2         -0.0019072  0.0018783  -1.015 0.309973    
Grade3         -0.0029132  0.0026167  -1.113 0.265618    
Semester151602  0.0018886  0.0050021   0.378 0.705766    
Semester161701  0.0008279  0.0043302   0.191 0.848385    
Semester161702  0.0027340  0.0042450   0.644 0.519572    
Semester171801  0.0033235  0.0041934   0.793 0.428065    
GP_Rank        -0.0509091  0.0618649  -0.823 0.410593    
GP_Birth        0.0016866  0.0040158   0.420 0.674503    
GP_Gender      -0.0093573  0.0032165  -2.909 0.003637 ** 
GP_East        -0.0028530  0.0037685  -0.757 0.449047    
GP_Middle       0.0009431  0.0041286   0.228 0.819311    
GP_Northeast   -0.0070026  0.0062473  -1.121 0.262377    
GP_Edu         -0.0028210  0.0033626  -0.839 0.401540    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.0609 on 6120 degrees of freedom
Multiple R-squared:  0.09539,	Adjusted R-squared:  0.08963 
F-statistic: 16.55 on 39 and 6120 DF,  p-value: < 2.2e-16


> out.B3 <- lm(S_school~GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_lowScore)

> summary(out.B3) # 回归原始结果输出

Call:
lm(formula = S_school ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_lowScore)

Residuals:
    Min      1Q  Median      3Q     Max 
-1.4138 -0.7645 -0.1262  0.9623  1.5885 

Coefficients:
                Estimate Std. Error t value Pr(>|t|)    
(Intercept)    -1.162280   1.050905  -1.106 0.268822    
GP_Score        0.871183   0.443872   1.963 0.049773 *  
Rank            0.239491   0.544572   0.440 0.660128    
Birth          -0.064352   0.043609  -1.476 0.140140    
Gender          0.134831   0.039432   3.419 0.000636 ***
East            0.005573   0.038000   0.147 0.883405    
Middle         -0.007558   0.043658  -0.173 0.862577    
Northeast      -0.055739   0.066274  -0.841 0.400391    
Edu             0.069151   0.034693   1.993 0.046327 *  
School2         0.075193   0.109705   0.685 0.493136    
School3         0.265061   0.108054   2.453 0.014221 *  
School4         0.053824   0.121595   0.443 0.658049    
School5         0.271304   0.082800   3.277 0.001062 ** 
School6         0.027989   0.090145   0.310 0.756212    
School7         0.175413   0.082415   2.128 0.033384 *  
School8         0.209396   0.082125   2.550 0.010830 *  
School9         0.012945   0.076627   0.169 0.865854    
School10        0.070930   0.072115   0.984 0.325407    
School11       -0.046459   0.083299  -0.558 0.577063    
School12       -0.089302   0.096713  -0.923 0.355887    
School13       -0.081428   0.081046  -1.005 0.315120    
School14       -0.006784   0.090301  -0.075 0.940121    
School15        0.011614   0.082602   0.141 0.888190    
School16        0.282920   0.152767   1.852 0.064127 .  
School17       -0.078149   0.097032  -0.805 0.420654    
School18       -0.067435   0.082985  -0.813 0.416497    
School19        0.148200   0.104034   1.425 0.154395    
Grade2          0.019753   0.038192   0.517 0.605049    
Grade3          0.316156   0.051804   6.103 1.17e-09 ***
Semester151602  0.004718   0.102390   0.046 0.963249    
Semester161701 -0.161665   0.088862  -1.819 0.068966 .  
Semester161702 -0.155707   0.087300  -1.784 0.074590 .  
Semester171801 -0.162104   0.086164  -1.881 0.060020 .  
GP_Rank         0.480866   1.294941   0.371 0.710408    
GP_Birth        0.021066   0.074073   0.284 0.776123    
GP_Gender       0.026547   0.061869   0.429 0.667895    
GP_East         0.092966   0.068990   1.348 0.177913    
GP_Middle      -0.120520   0.077774  -1.550 0.121339    
GP_Northeast    0.044767   0.114566   0.391 0.696005    
GP_Edu         -0.173194   0.062331  -2.779 0.005493 ** 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.8644 on 3040 degrees of freedom
Multiple R-squared:  0.04629,	Adjusted R-squared:  0.03405 
F-statistic: 3.783 on 39 and 3040 DF,  p-value: 4.178e-14


> out.B4 <- lm(Score~S_school+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_lowScore)

> summary(out.B4) # 回归原始结果输出

Call:
lm(formula = Score ~ S_school + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_lowScore)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.38807 -0.02278  0.01361  0.03653  0.10735 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     2.2840038  0.0076911 296.969  < 2e-16 ***
S_school        0.0015768  0.0011180   1.410 0.158530    
Rank           -0.1720873  0.0335901  -5.123 3.19e-07 ***
Birth           0.0063138  0.0026896   2.348 0.018962 *  
Gender         -0.0198563  0.0024367  -8.149 5.31e-16 ***
East            0.0031846  0.0023434   1.359 0.174269    
Middle          0.0033809  0.0026929   1.255 0.209395    
Northeast      -0.0078324  0.0040873  -1.916 0.055423 .  
Edu             0.0004601  0.0021407   0.215 0.829822    
School2        -0.0129476  0.0067106  -1.929 0.053772 .  
School3        -0.0144698  0.0066691  -2.170 0.030108 *  
School4        -0.0422374  0.0074816  -5.645 1.80e-08 ***
School5        -0.0066054  0.0051161  -1.291 0.196766    
School6        -0.0013160  0.0055602  -0.237 0.812923    
School7        -0.0095995  0.0050863  -1.887 0.059210 .  
School8        -0.0017896  0.0050708  -0.353 0.724171    
School9        -0.0129025  0.0047253  -2.730 0.006361 ** 
School10       -0.0037627  0.0044449  -0.847 0.397335    
School11       -0.0051654  0.0051382  -1.005 0.314841    
School12       -0.0034786  0.0059629  -0.583 0.559683    
School13       -0.0023728  0.0049966  -0.475 0.634903    
School14        0.0007767  0.0055618   0.140 0.888947    
School15       -0.0147637  0.0050946  -2.898 0.003783 ** 
School16       -0.0124205  0.0094245  -1.318 0.187638    
School17       -0.0007724  0.0059841  -0.129 0.897312    
School18       -0.0053829  0.0051091  -1.054 0.292157    
School19       -0.0116478  0.0064172  -1.815 0.069608 .  
Grade2         -0.0032790  0.0023550  -1.392 0.163923    
Grade3          0.0006488  0.0032124   0.202 0.839953    
Semester151602  0.0024934  0.0063143   0.395 0.692958    
Semester161701 -0.0009126  0.0054840  -0.166 0.867851    
Semester161702 -0.0001857  0.0053847  -0.034 0.972488    
Semester171801  0.0005725  0.0053175   0.108 0.914275    
GP_Rank        -0.0580821  0.0791954  -0.733 0.463370    
GP_Birth        0.0033364  0.0045609   0.732 0.464521    
GP_Gender      -0.0131885  0.0037188  -3.546 0.000396 ***
GP_East        -0.0044553  0.0042468  -1.049 0.294219    
GP_Middle       0.0030521  0.0047927   0.637 0.524279    
GP_Northeast   -0.0083746  0.0070647  -1.185 0.235949    
GP_Edu         -0.0011008  0.0038472  -0.286 0.774798    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.05332 on 3040 degrees of freedom
Multiple R-squared:  0.0828,	Adjusted R-squared:  0.07103 
F-statistic: 7.037 on 39 and 3040 DF,  p-value: < 2.2e-16


> out.B5 <- lm(S_school~GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_highScore)

> summary(out.B5) # 回归原始结果输出

Call:
lm(formula = S_school ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_highScore)

Residuals:
     Min       1Q   Median       3Q      Max 
-1.64892 -0.77030 -0.06271  0.92508  1.58309 

Coefficients:
                Estimate Std. Error t value Pr(>|t|)    
(Intercept)    -1.768938   1.471466  -1.202 0.229395    
GP_Score        1.096168   0.628423   1.744 0.081205 .  
Rank            2.413365   1.360062   1.774 0.076088 .  
Birth           0.054037   0.042050   1.285 0.198869    
Gender          0.102519   0.042073   2.437 0.014879 *  
East           -0.003750   0.040423  -0.093 0.926094    
Middle         -0.015503   0.044229  -0.351 0.725982    
Northeast       0.009085   0.063581   0.143 0.886384    
Edu            -0.049291   0.034345  -1.435 0.151343    
School2         0.086751   0.155281   0.559 0.576427    
School3         0.093005   0.101469   0.917 0.359435    
School4         0.400448   0.144718   2.767 0.005690 ** 
School5         0.387454   0.077538   4.997 6.15e-07 ***
School6        -0.257114   0.084528  -3.042 0.002372 ** 
School7        -0.113328   0.077953  -1.454 0.146105    
School8         0.056530   0.077834   0.726 0.467722    
School9        -0.138883   0.080966  -1.715 0.086390 .  
School10       -0.106395   0.069623  -1.528 0.126576    
School11       -0.079967   0.078104  -1.024 0.305989    
School12       -0.181219   0.101443  -1.786 0.074131 .  
School13       -0.133867   0.077099  -1.736 0.082611 .  
School14       -0.099933   0.087083  -1.148 0.251236    
School15       -0.095465   0.082151  -1.162 0.245302    
School16       -0.067511   0.146137  -0.462 0.644138    
School17       -0.092211   0.092484  -0.997 0.318825    
School18       -0.248311   0.086138  -2.883 0.003970 ** 
School19        0.195861   0.119382   1.641 0.100979    
Grade2         -0.110868   0.037563  -2.952 0.003186 ** 
Grade3          0.203583   0.053249   3.823 0.000134 ***
Semester151602  0.091704   0.098800   0.928 0.353387    
Semester161701  0.099686   0.085430   1.167 0.243351    
Semester161702  0.060150   0.083790   0.718 0.472894    
Semester171801  0.040009   0.082621   0.484 0.628244    
GP_Rank         1.285609   1.226994   1.048 0.294827    
GP_Birth       -0.003292   0.090306  -0.036 0.970921    
GP_Gender      -0.036324   0.072029  -0.504 0.614087    
GP_East         0.042775   0.085759   0.499 0.617965    
GP_Middle      -0.042847   0.090436  -0.474 0.635690    
GP_Northeast    0.357761   0.140811   2.541 0.011112 *  
GP_Edu         -0.063167   0.074883  -0.844 0.398994    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.8627 on 3040 degrees of freedom
Multiple R-squared:  0.0548,	Adjusted R-squared:  0.04267 
F-statistic: 4.519 on 39 and 3040 DF,  p-value: < 2.2e-16


> out.B6 <- lm(Score~S_school+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata_highScore)

> summary(out.B6) # 回归原始结果输出

Call:
lm(formula = Score ~ S_school + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata_highScore)

Residuals:
      Min        1Q    Median        3Q       Max 
-0.045816 -0.018727 -0.003121  0.016406  0.079018 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     2.357e+00  3.456e-03 682.151  < 2e-16 ***
S_school        1.186e-03  4.965e-04   2.389   0.0170 *  
Rank           -1.806e-01  3.725e-02  -4.848 1.31e-06 ***
Birth           6.267e-03  1.152e-03   5.441 5.72e-08 ***
Gender         -6.290e-03  1.152e-03  -5.459 5.16e-08 ***
East            6.587e-03  1.107e-03   5.951 2.97e-09 ***
Middle          5.025e-03  1.211e-03   4.148 3.45e-05 ***
Northeast       6.818e-03  1.741e-03   3.916 9.22e-05 ***
Edu            -3.134e-04  9.409e-04  -0.333   0.7391    
School2         5.051e-03  4.236e-03   1.192   0.2333    
School3         7.196e-04  2.777e-03   0.259   0.7956    
School4         1.608e-03  3.951e-03   0.407   0.6839    
School5        -3.237e-03  2.132e-03  -1.518   0.1291    
School6        -1.006e-03  2.318e-03  -0.434   0.6642    
School7         2.531e-05  2.136e-03   0.012   0.9905    
School8         4.223e-03  2.132e-03   1.981   0.0477 *  
School9         2.383e-03  2.218e-03   1.074   0.2828    
School10       -1.448e-03  1.907e-03  -0.759   0.4477    
School11       -8.102e-04  2.139e-03  -0.379   0.7049    
School12        2.064e-03  2.778e-03   0.743   0.4576    
School13        3.671e-03  2.112e-03   1.738   0.0823 .  
School14       -2.634e-03  2.385e-03  -1.104   0.2696    
School15        3.956e-03  2.250e-03   1.759   0.0787 .  
School16        2.012e-03  4.003e-03   0.503   0.6152    
School17        5.035e-03  2.533e-03   1.988   0.0469 *  
School18        3.377e-03  2.362e-03   1.430   0.1529    
School19       -6.355e-04  3.268e-03  -0.194   0.8458    
Grade2          2.056e-03  1.030e-03   1.996   0.0460 *  
Grade3          1.397e-03  1.462e-03   0.955   0.3395    
Semester151602  1.024e-04  2.704e-03   0.038   0.9698    
Semester161701  6.755e-04  2.338e-03   0.289   0.7727    
Semester161702 -1.979e-03  2.290e-03  -0.864   0.3875    
Semester171801 -3.209e-04  2.260e-03  -0.142   0.8871    
GP_Rank        -2.938e-02  3.305e-02  -0.889   0.3740    
GP_Birth       -2.160e-03  2.473e-03  -0.874   0.3824    
GP_Gender       3.501e-03  1.936e-03   1.808   0.0707 .  
GP_East        -1.934e-03  2.339e-03  -0.827   0.4085    
GP_Middle      -2.918e-03  2.463e-03  -1.184   0.2363    
GP_Northeast    2.664e-03  3.855e-03   0.691   0.4896    
GP_Edu          2.891e-04  2.051e-03   0.141   0.8879    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.02363 on 3040 degrees of freedom
Multiple R-squared:  0.0498,	Adjusted R-squared:  0.03761 
F-statistic: 4.085 on 39 and 3040 DF,  p-value: 5.797e-16


> # 表格PanelB输出
> stargazer(out.B1, out.B2, out.B3, out.B4, out.B5, out.B6,
+           type = "text", #输出显示为文本
+           omit = c("Rank", "Birth", "Gender", "East", "Middle", "Northeast", "Edu",
+                    "School", "Grade", "Semester", "GP_Rank", "GP_Birth", "GP_Gender", "GP_East",
+                    "GP_Middle", "GP_Northeast", "GP_Edu"), #隐藏不展示的变量
+           omit.stat = c("f", "ser", "adj.rsq"), #隐藏不展示的信息
+           title = "表II1 同群效应的情感投入机制的深入分析", #表格标题
+           add.lines = list(c("控制主体特征变量", "YES", "YES", "YES", "YES", "YES", "YES"),
+                            c("控制朋友特征变量", "YES", "YES", "YES", "YES", "YES", "YES"),
+                            c("固定效应", "YES", "YES", "YES", "YES", "YES", "YES")), #表格展示控制变量信息
+           digits = 3, #数据保留小数点后3位
+           out = "C:/2024-00222+日志文件/tableII1-PanelB.html")

表II1 同群效应的情感投入机制的深入分析
==================================================================
                              Dependent variable:                 
             -----------------------------------------------------
             S_school  Score   S_school  Score   S_school  Score  
               (1)      (2)      (3)      (4)      (5)      (6)   
------------------------------------------------------------------
GP_Score     1.001***          0.871**            1.096*          
             (0.359)           (0.444)           (0.628)          
                                                                  
S_school              0.003***           0.002            0.001** 
                      (0.001)           (0.001)           (0.0005)
                                                                  
Constant     -1.503*  2.324***  -1.162  2.284***  -1.769  2.357***
             (0.845)  (0.006)  (1.051)  (0.008)  (1.471)  (0.003) 
                                                                  
------------------------------------------------------------------
控制主体特征变量       YES      YES      YES      YES      YES      YES   
控制朋友特征变量       YES      YES      YES      YES      YES      YES   
固定效应           YES      YES      YES      YES      YES      YES   
Observations  6,160    6,160    3,080    3,080    3,080    3,080  
R2            0.042    0.095    0.046    0.083    0.055    0.050  
==================================================================
Note:                                  *p<0.1; **p<0.05; ***p<0.01

> ################*表A1 “共现”记录统计*#################
> # 写入日志信息
> cat("################*表A1 “共现”记录统计*#################\n")
################*表A1 “共现”记录统计*#################

> # 导入最初共现记录和最终保留共现记录
> workdata1 <- read.csv("C:/2024-00222+使用数据/tableA1-1.csv",header = T,as.is = T,stringsAsFactors = TRUE)

> workdata2 <- read.csv("C:/2024-00222+使用数据/tableA1-2.csv",header = T,as.is = T,stringsAsFactors = TRUE)

> # 按照学期分组
> Sem1 <- subset(workdata1,Semester==1)

> Sem2 <- subset(workdata1,Semester==2)

> Sem3 <- subset(workdata1,Semester==3)

> Sem4 <- subset(workdata1,Semester==4)

> Sem5 <- subset(workdata1,Semester==5)

> Sem1f <- subset(workdata2,Semester==1)

> Sem2f <- subset(workdata2,Semester==2)

> Sem3f <- subset(workdata2,Semester==3)

> Sem4f <- subset(workdata2,Semester==4)

> Sem5f <- subset(workdata2,Semester==5)

> # 创建一个函数来计算每个学期的数据
> calculate_semester_data <- function(Co_Occurrence_df,Co_Occurrence_final_df) {
+   # 计算“共现”数
+   cooccurrence_count <- nrow(Co_Occurrence_df)
+   # 计算倒序排列前5%对应的频数
+   value_threshold <- quantile(Co_Occurrence_df$Co_OccurrenceTimes, 0.95)
+   # 缺失值处理后“共现”数
+   cleaned_cooccurrence_count <- nrow(Co_Occurrence_final_df)
+   # 计算保留比例
+   retention_ratio <- cleaned_cooccurrence_count / cooccurrence_count * 100
+   
+   return(c(cooccurrence_count, value_threshold, cleaned_cooccurrence_count, retention_ratio))
+ }

> # 初始化学期名称
> semesters <- c("一", "二", "三", "四", "五")

> # 初始化结果列表
> results <- list()

> # 逐个学期计算
> sem_list1 <- list(Sem1, Sem2, Sem3, Sem4, Sem5)

> sem_list2 <- list(Sem1f, Sem2f, Sem3f, Sem4f, Sem5f)

> for (i in seq_along(sem_list1)) {
+   results[[i]] <- calculate_semester_data(sem_list1[[i]], sem_list2[[i]])
+ }

> # 计算总计行
> total_cooccurrence_count <- sum(sapply(sem_list1, nrow))

> total_cleaned_cooccurrence_count <- sum(sapply(results, `[[`, 3))

> total_retention_ratio <- total_cleaned_cooccurrence_count / total_cooccurrence_count * 100

> # 创建最终数据框
> tableA1 <- data.frame(
+   学期 = c(semesters, "总计"),
+   共现数 = c(sapply(results, `[[`, 1), total_cooccurrence_count),
+   倒序排列前百分之五对应的频数 = c(sapply(results, `[[`, 2), NA),
+   缺失值处理后共现数 = c(sapply(results, `[[`, 3), total_cleaned_cooccurrence_count),
+   保留比例 = c(sapply(results, `[[`, 4), total_retention_ratio)
+ )

> # 打印结果
> print(tableA1)
  学期   共现数 倒序排列前百分之五对应的频数 缺失值处理后共现数  保留比例
1   一   156351                           24               2056 1.3149900
2   二   264455                           28               4621 1.7473672
3   三  2750572                           19              14072 0.5116027
4   四  4444006                           23              54588 1.2283512
5   五  8148497                           19              36838 0.4520834
6 总计 15763881                           NA             112175 0.7115951

> write_xlsx(tableA1, path = "C:/2024-00222+日志文件/tableA1.xlsx")

> ################*表A2 前一学期形成的社交网络的同群效应*#################
> # 写入日志信息
> cat("################*表A2 前一学期形成的社交网络的同群效应*#################\n")
################*表A2 前一学期形成的社交网络的同群效应*#################

> # 导入数据
> workdata <- read.csv("C:/2024-00222+使用数据/tableA2.csv",header = T,as.is = T,stringsAsFactors = TRUE)

> # 使用函数转换指定的列为因子
> workdata <- convert_to_factors(workdata)

> # 单变量回归
> out.lm0_lastsem <- lm(Score ~ GP_Score, data = workdata)

> summary(out.lm0_lastsem) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score, data = workdata)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.32266 -0.02874  0.01134  0.04327  0.13253 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  1.63459    0.08544  19.132  < 2e-16 ***
GP_Score     0.29336    0.03668   7.998 1.75e-15 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06381 on 3244 degrees of freedom
Multiple R-squared:  0.01934,	Adjusted R-squared:  0.01903 
F-statistic: 63.96 on 1 and 3244 DF,  p-value: 1.748e-15


> # 控制主体特征变量和固定效应变量
> out.lmX_lastsem <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester, data = workdata)

> summary(out.lmX_lastsem) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester, data = workdata)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.33747 -0.02931  0.00973  0.04100  0.13924 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.9376785  0.0861149  22.501  < 2e-16 ***
GP_Score        0.1659446  0.0366663   4.526 6.23e-06 ***
Rank           -0.3325845  0.0459137  -7.244 5.44e-13 ***
Birth           0.0056677  0.0029472   1.923 0.054554 .  
Gender         -0.0317838  0.0024465 -12.992  < 2e-16 ***
East            0.0157052  0.0026624   5.899 4.04e-09 ***
Middle          0.0095030  0.0029957   3.172 0.001527 ** 
Northeast       0.0055612  0.0044172   1.259 0.208124    
Edu            -0.0007212  0.0023579  -0.306 0.759734    
School2        -0.0337777  0.0092710  -3.643 0.000273 ***
School3        -0.0022034  0.0071014  -0.310 0.756364    
School4        -0.0389467  0.0088014  -4.425 9.96e-06 ***
School5        -0.0014673  0.0055725  -0.263 0.792328    
School6         0.0023812  0.0059160   0.402 0.687350    
School7        -0.0040009  0.0055213  -0.725 0.468730    
School8         0.0090771  0.0053794   1.687 0.091627 .  
School9        -0.0128959  0.0052969  -2.435 0.014962 *  
School10       -0.0067506  0.0048255  -1.399 0.161925    
School11        0.0005775  0.0054603   0.106 0.915779    
School12       -0.0070134  0.0068571  -1.023 0.306481    
School13        0.0021613  0.0052605   0.411 0.681212    
School14       -0.0031580  0.0061093  -0.517 0.605246    
School15       -0.0067979  0.0057328  -1.186 0.235792    
School16        0.0086927  0.0105775   0.822 0.411246    
School17       -0.0014298  0.0069656  -0.205 0.837375    
School18       -0.0099888  0.0058548  -1.706 0.088089 .  
School19       -0.0248662  0.0074422  -3.341 0.000844 ***
Grade2         -0.0015988  0.0024669  -0.648 0.516969    
Semester161701 -0.0001069  0.0050230  -0.021 0.983025    
Semester161702 -0.0002307  0.0044386  -0.052 0.958551    
Semester171801  0.0007399  0.0043198   0.171 0.864009    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06122 on 3215 degrees of freedom
Multiple R-squared:  0.1052,	Adjusted R-squared:  0.0969 
F-statistic: 12.61 on 30 and 3215 DF,  p-value: < 2.2e-16


> # 控制主体特征变量、朋友特征变量和固定效应变量
> out.lmXGX_lastsem <- lm(Score ~ GP_Score+Rank+Birth+Gender+East+Middle+Northeast+Edu+School+Grade+Semester+
+                           GP_Rank+GP_Birth+GP_Gender+GP_East+GP_Middle+GP_Northeast+GP_Edu, data = workdata)

> summary(out.lmXGX_lastsem) # 回归原始结果输出

Call:
lm(formula = Score ~ GP_Score + Rank + Birth + Gender + East + 
    Middle + Northeast + Edu + School + Grade + Semester + GP_Rank + 
    GP_Birth + GP_Gender + GP_East + GP_Middle + GP_Northeast + 
    GP_Edu, data = workdata)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.33528 -0.02938  0.00978  0.04112  0.14545 

Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
(Intercept)     1.9306308  0.0912573  21.156  < 2e-16 ***
GP_Score        0.1711227  0.0387457   4.417 1.04e-05 ***
Rank           -0.3349942  0.0459912  -7.284 4.06e-13 ***
Birth           0.0056037  0.0029520   1.898 0.057750 .  
Gender         -0.0307735  0.0027107 -11.353  < 2e-16 ***
East            0.0156246  0.0026704   5.851 5.38e-09 ***
Middle          0.0096866  0.0030005   3.228 0.001258 ** 
Northeast       0.0057871  0.0044222   1.309 0.190751    
Edu            -0.0007015  0.0023686  -0.296 0.767109    
School2        -0.0338223  0.0093236  -3.628 0.000291 ***
School3        -0.0018511  0.0071415  -0.259 0.795500    
School4        -0.0403795  0.0088308  -4.573 5.00e-06 ***
School5        -0.0025863  0.0055955  -0.462 0.643963    
School6         0.0007774  0.0059859   0.130 0.896681    
School7        -0.0044481  0.0055499  -0.801 0.422910    
School8         0.0080623  0.0054051   1.492 0.135900    
School9        -0.0134668  0.0053056  -2.538 0.011189 *  
School10       -0.0071220  0.0048452  -1.470 0.141681    
School11        0.0003528  0.0054774   0.064 0.948652    
School12       -0.0072685  0.0068828  -1.056 0.291030    
School13        0.0018369  0.0053005   0.347 0.728945    
School14       -0.0037698  0.0061516  -0.613 0.540044    
School15       -0.0076861  0.0057458  -1.338 0.181094    
School16        0.0078894  0.0106108   0.744 0.457219    
School17       -0.0017522  0.0069817  -0.251 0.801849    
School18       -0.0106177  0.0058760  -1.807 0.070863 .  
School19       -0.0244175  0.0074620  -3.272 0.001078 ** 
Grade2         -0.0010602  0.0024780  -0.428 0.668799    
Semester161701 -0.0002314  0.0050437  -0.046 0.963411    
Semester161702  0.0004262  0.0045002   0.095 0.924557    
Semester171801  0.0021099  0.0044487   0.474 0.635338    
GP_Rank         0.0325150  0.0842317   0.386 0.699508    
GP_Birth        0.0033261  0.0062393   0.533 0.594008    
GP_Gender      -0.0052840  0.0049445  -1.069 0.285305    
GP_East        -0.0109419  0.0057558  -1.901 0.057390 .  
GP_Middle      -0.0115420  0.0061322  -1.882 0.059899 .  
GP_Northeast   -0.0127634  0.0095754  -1.333 0.182649    
GP_Edu          0.0017023  0.0050041   0.340 0.733740    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.06122 on 3208 degrees of freedom
Multiple R-squared:  0.1072,	Adjusted R-squared:  0.09693 
F-statistic: 10.41 on 37 and 3208 DF,  p-value: < 2.2e-16


> # 表格输出
> stargazer(out.lm0_lastsem, out.lmX_lastsem, out.lmXGX_lastsem,
+           type = "text", #输出显示为文本
+           omit = c("Rank", "Birth", "Gender", "East", "Middle", "Northeast", "Edu",
+                    "School", "Grade", "Semester", "GP_Rank", "GP_Birth", "GP_Gender", "GP_East",
+                    "GP_Middle", "GP_Northeast", "GP_Edu"), #隐藏不展示的变量
+           omit.stat = c("f", "ser", "adj.rsq"), #隐藏不展示的信息
+           dep.var.labels = "前一学期的社交网络对当期学生学业表现：Score", #因变量标签
+           title = "表A2 前一学期形成的社交网络的同群效应", #表格标题
+           add.lines = list(c("控制主体特征变量", "NO", "YES", "YES"),
+                            c("控制朋友特征变量", "NO", "NO", "YES"),
+                            c("固定效应", "NO", "YES", "YES")), #表格展示控制变量信息
+           digits = 3, #数据保留小数点后3位
+           out = "C:/2024-00222+日志文件/tableA2.html")

表A2 前一学期形成的社交网络的同群效应
==========================================
                  Dependent variable:     
             -----------------------------
               前一学期的社交网络对当期学生学业表现：Score   
                (1)       (2)       (3)   
------------------------------------------
GP_Score     0.293***  0.166***  0.171*** 
              (0.037)   (0.037)   (0.039) 
                                          
Constant     1.635***  1.938***  1.931*** 
              (0.085)   (0.086)   (0.091) 
                                          
------------------------------------------
控制主体特征变量        NO        YES       YES   
控制朋友特征变量        NO        NO        YES   
固定效应            NO        YES       YES   
Observations   3,246     3,246     3,246  
R2             0.019     0.105     0.107  
==========================================
Note:          *p<0.1; **p<0.05; ***p<0.01

日志生成结束时间: 2025-09-09 16:58:31