-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmentorship.Rmd
462 lines (318 loc) · 17.4 KB
/
mentorship.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
---
title: "Mentorship"
author: "Daniel E. Weeks"
date: "`r format(Sys.time(), '%B %d, %Y, %R')`"
header-includes:
- \usepackage{pdflscape}
- \newcommand{\blandscape}{\begin{landscape}}
- \newcommand{\elandscape}{\end{landscape}}
output:
pdf_document:
toc: true
number_sections: true
toc_depth: 3
html_document:
df_print: paged
toc: true
number_sections: true
toc_depth: '3'
code_folding: show
# md_extensions: +raw_attribute
github_document:
toc: true
number_sections: true
toc_depth: 3
---
```{r,echo=FALSE,message=FALSE,warning=FALSE}
require(knitr)
# Set so that long lines in R will be wrapped:
opts_chunk$set(tidy.opts=list(width.cutoff=80),tidy=TRUE)
```
```{r,echo=FALSE}
# In the event of a crash, save the working space on exit:
save_all <- function() {
save.image("recover.RData")
}
options(error = save_all)
```
# Load Libraries
```{r load_libraries,message=FALSE}
library(tidyverse)
# library(tidylog)
library(ggExtra)
library(arsenal)
```
# Input directory and files
```{r}
# Print the working directory
getwd()
```
# The AlShebli et al (2020) mentorship paper
Here I examine the data provided by the authors of this paper:
AlShebli B, Makovi K, Rahwan T. The association between early career informal mentorship in academic collaborations and junior author performance. Nat Commun. 2020 Nov 17;11(1):5855. doi: 10.1038/s41467-020-19723-8. PMID: 33203848.
https://pubmed.ncbi.nlm.nih.gov/33203848/
# The data
## The input data
The input data are from the 'bedoor/Mentorship' GitHub repository at
https://github.com/bedoor/Mentorship
Their repository is described as:
'This repository includes all data used in "The Association between Early Career Informal Mentorship in Academic Collaborations and Junior Author Performance".'
```{r}
LinesRead <- 100000
inFile <- "Mentorship/Repository_Data/Data_7yearcutoff.csv"
a <- read_csv(file = inFile, n_max = LinesRead)
names(a)
```
```{r}
total_records <- as.integer(system2("wc",
args = c("-l",
inFile,
" | awk '{print $1}'"),
stdout = TRUE))
total_records
```
## Disclaimer: For speed, only read in the first `r LinesRead` lines
To speed up the analyses, we read only the first `r LinesRead` lines of the input file, instead of reading all `r total_records` lines.
## Problem: No gender information for mentors
There does not appear to be any information in the provided file about the mentor's gender, so the provided data do not appear to be 'all the data'.
There is no data dictionary, so we are left to infer what is in each column of the data file from the column names and content.
# ProtegeFirstPubYear
# Distribution of ProtegeFirstPubYear
"Year of the protege’s first publication: The year in which the protege published their first mentored paper."
```{r, dpi=600, dev='png'}
summary(a$ProtegeFirstPubYear)
ggplot(data = a, mapping = aes(x = ProtegeFirstPubYear)) + geom_histogram() +
ggtitle("Distribution of ProtegeFirstPubYear")
table(a$Pr0tegeGender)
ggplot(data = a, mapping = aes(x = ProtegeFirstPubYear)) + geom_histogram() +
ggtitle("Distribution of ProtegeFirstPubYear") + facet_grid(~ Pr0tegeGender)
a$MaleProtegeFirstPubYear <- a$ProtegeFirstPubYear
a$MaleProtegeFirstPubYear[a$Pr0tegeGender=="female"] <- NA
a$FemaleProtegeFirstPubYear <- a$ProtegeFirstPubYear
a$FemaleProtegeFirstPubYear[a$Pr0tegeGender=="male"] <- NA
summary(a$MaleProtegeFirstPubYear)
summary(a$FemaleProtegeFirstPubYear)
p <- ggplot(data=a, aes(x=x) ) +
geom_histogram(aes(x = MaleProtegeFirstPubYear, y = ..density..), fill="#69b3a2" ) +
annotate("text", x=1950, y=0.03, label="MaleProtegeFirstPubYear", color="#69b3a2") +
geom_histogram(aes(x = FemaleProtegeFirstPubYear, y = -..density..), fill= "#404080") +
annotate("text", x=1950, y=-0.03, label="FemaleProtegeFirstPubYear", color="#404080") +
xlab("ProtegeFirstPubYear") +
ggtitle("Distributions of ProtegeFirstPubYear by gender")
p
p <- ggplot(data=a, aes(x=x) ) +
geom_density(aes(x = MaleProtegeFirstPubYear, y = ..density..), fill="#69b3a2" ) +
annotate("text", x=1950, y=0.03, label="MaleProtegeFirstPubYear", color="#69b3a2") +
geom_density(aes(x = FemaleProtegeFirstPubYear, y = -..density..), fill= "#404080") +
annotate("text", x=1950, y=-0.03, label="FemaleProtegeFirstPubYear", color="#404080") +
xlab("ProtegeFirstPubYear") +
ggtitle("Distributions of ProtegeFirstPubYear by gender")
p
```
## Problem: ProtegeFirstPubYear time range is very large
in the first `r LinesRead` lines of this data set, the `ProtegeFirstPubYear` ranges from `r min(a$ProtegeFirstPubYear)` to `r max(a$ProtegeFirstPubYear)`. It seems that it would be very difficult to properly compare the impact factors of papers published in `r `min(a$ProtegeFirstPubYear)`, well before the advent of team science and the current deluge of scientific publications, to those published as recently `r max(a$ProtegeFirstPubYear)`.
# NumYearsPostMentorship
"The number of years post mentorship: Since our dataset is up to Dec 31st 2019,
we are only able to calculate c5—the number of citations accumulated five years post publication—for papers published before 2015. Thus, given a protege whose first paper was published in year x, the number of years post mentorship is `2015 - (x + 6)`, bearing in mind that the mentorship period is 7 years and we do not include proteges with a gap of 5 years of more in their career history."
## Problem: Error in the equation for NumYearsPostMentorship
Note that the stated equation of `2015 - (x + 6)` for computing the number of years post mentorship is not what was used, as instead `2015 - (x + 2)`, where `x` is the year the protege's paper was first published, as we see here in the first `r LinesRead` lines of the input file:
```{r}
all.equal(a$NumYearsPostMentorship, 2015 -(a$ProtegeFirstPubYear + 2))
```
## Distribution of NumYearsPostMentorship
```{r, dpi=600, dev='png'}
summary(a$NumYearsPostMentorship)
ggplot(data = a, mapping = aes(x = NumYearsPostMentorship)) + geom_histogram() +
ggtitle("Distribution of NumYearsPostMentorship")
```
```{r, dpi=600, dev='png'}
a$ProtegeGender <- as.factor(a$Pr0tegeGender)
p <- ggplot(data = a, mapping = aes(x = ProtegeFirstPubYear, y = NumYearsPostMentorship)) + geom_point() + ggtitle("NumYearsPostMentorship vs. ProtegeFirstPubYear")
ggMarginal(p, type="histogram")
```
## Problem: some values of `NumYearsPostMentorship` are unrealistically large
In the first `r LinesRead` lines of the input file of this data set, there are values of `NumYearsPostMentorship` as large as `r max(a$NumYearsPostMentorship)`. These values are unrealistically large.
# AvgMentorsAcAges
## Distribution of AvgMentorsAcAges
"Average academic age of mentors: This is computed for any given protege by first
computing the academic age of each mentor in the year of their first publication with the protege, and then averaging these numbers over all the mentors."
"Given a scientist whose first paper was published in year x, the academic age of this scientist in year y is y-x."
```{r, dpi=600, dev='png'}
summary(a$AvgMentorsAcAges)
ggplot(data = a, mapping = aes(x = AvgMentorsAcAges)) + geom_histogram() +
ggtitle("Distribution of AvgMentorsAcAges")
ggplot(data = a, mapping = aes(x = ProtegeFirstPubYear, y = AvgMentorsAcAges, col=ProtegeGender)) + geom_point() +
ggtitle("ProtegeFirstPubYear vs. AvgMentorsAcAges")
ggplot(data = a, mapping = aes(x = ProtegeFirstPubYear, y = AvgMentorsAcAges)) + geom_point() + facet_grid(~ ProtegeGender) +
ggtitle("ProtegeFirstPubYear vs. AvgMentorsAcAges by ProtegeGender")
```
## Problem: some `AvgMentorsAcAges` are unrealistically large
There are `AvgMentorsAcAges` as large as `r max(a$AvgMentorsAcAges)` in the first `r LinesRead` lines of this data set. This is unrealistically large.
Among proteges who published their first paper after 2000, there are `AvgMentorsAcAges` as large as `r max(a[a$ProtegeFirstPubYear > 2000, ]$AvgMentorsAcAges)` in this data set. Should we be evaluating the mentorship effects of mentors who were born than 200 years ago?
# Avg_c5
## Distribution of Avg_c5
```{r, dpi=600, dev='png'}
summary(a$Avg_c5)
ggplot(data = a, mapping = aes(x = Avg_c5)) + geom_histogram() +
ggtitle("Distribution of Avg_c5")
ggplot(data = a, mapping = aes(x = ProtegeFirstPubYear, y = Avg_c5, col=ProtegeGender)) + geom_point() +
ggtitle("ProtegeFirstPubYear vs. Avg_c5")
ggplot(data = a, mapping = aes(x = ProtegeFirstPubYear, y = Avg_c5)) + geom_point() + facet_grid( ~ ProtegeGender) +
ggtitle("ProtegeFirstPubYear vs. Avg_c5")
```
## Joint distribution of Avg_c5 and AvgMentorsAcAges
```{r, dpi=600, dev='png'}
ggplot(data = a, mapping = aes(y = Avg_c5, x = AvgMentorsAcAges, col=ProtegeGender)) + geom_point() +
ggtitle("Avg_c5 vs. AvgMentorsAcAges")
ggplot(data = a, mapping = aes(y = Avg_c5, x = AvgMentorsAcAges, col=ProtegeFirstPubYear)) +
geom_point() +
scale_color_gradient(low="red", high="blue") +
facet_grid( ~ ProtegeGender) +
ggtitle("Avg_c5 vs. AvgMentorsAcAges")
```
# Avg_c10
## Distribution of Avg_c10
```{r, dpi=600, dev='png'}
summary(a$Avg_c10)
ggplot(data = a, mapping = aes(x = Avg_c10)) + geom_histogram() +
ggtitle("Distribution of Avg_c10")
ggplot(data = a, mapping = aes(x = ProtegeFirstPubYear, y = Avg_c10, col=ProtegeGender)) + geom_point() +
ggtitle("ProtegeFirstPubYear vs. Avg_c10")
ggplot(data = a, mapping = aes(x = ProtegeFirstPubYear, y = Avg_c10)) + geom_point() + facet_grid( ~ ProtegeGender) +
ggtitle("ProtegeFirstPubYear vs. Avg_c10")
```
## Problem with Avg_c10: Cannot compute a value Avg_c10 for recent publications
As the dataset is up to Dec 31st 2019, how can one compute a valid Avg_c10 for someone whose first publication year was 2012 or 2013?
```{r}
a %>% filter(ProtegeFirstPubYear == max(ProtegeFirstPubYear)-1) %>% select(ProtegeFirstPubYear, Avg_c5, Avg_c10) %>% head(20)
```
# Avg_c5 vs Avg_c10
## Tables of Avg_c5 and Avg_c10
```{r}
my_controls <- tableby.control(
test = T,
total = T,
numeric.stats = c("meansd", "medianq1q3", "range", "Nmiss2"),
cat.stats = c("countpct", "Nmiss2"),
stats.labels = list(
meansd = "Mean (SD)",
medianq1q3 = "Median (Q1, Q3)",
range = "Min - Max",
Nmiss2 = "Missing"
)
)
my_controls2 <- tableby.control(
numeric.stats = c( "medianq1q3"),
stats.labels = list(
medianq1q3 = "Median (Q1, Q3)"
)
)
t.test(Avg_c5 ~ ProtegeGender, data=a)
t.test(Avg_c10 ~ ProtegeGender, data=a)
t1 <- tableby(ProtegeGender ~ ., data = a %>% select(ProtegeGender, Avg_c5, Avg_c10))
```
```{r, results='asis'}
summary(t1, title = "Table of Avg_c5 and Avg_c10 by ProtegeGender")
```
```{r}
t1 <- tableby(ProtegeGender ~ ., data = a %>% select(ProtegeGender, Avg_c5, Avg_c10), control = my_controls2)
```
```{r, results='asis'}
summary(t1, title = "Table of Avg_c5 and Avg_c10 by ProtegeGender")
```
```{r}
t1 <- tableby(ProtegeGender ~ ., data = a %>% select(ProtegeGender, Avg_c5, Avg_c10), control = my_controls)
```
```{r, results='asis'}
summary(t1, title = "Table of Avg_c5 and Avg_c10 by ProtegeGender")
```
## Joint distribution of Avg_c5 and Avg_c10
```{r, dpi=600, dev='png'}
ggplot(data = a, mapping = aes(x = Avg_c5, y = Avg_c10, col=ProtegeGender)) + geom_point() +
geom_abline(intercept = 0, slope = 1, col="red") +
ggtitle("Avg_c5 vs. Avg_c10")
ggplot(data = a, mapping = aes(x = Avg_c5, y = Avg_c10, col=ProtegeFirstPubYear)) +
geom_point() +
scale_color_gradient(low="red", high="blue") +
geom_abline(intercept = 0, slope = 1, col="red") +
facet_grid( ~ ProtegeGender) +
ggtitle("Avg_c5 vs. Avg_c10")
```
# numMentors
## Distribution of numMentors
```{r, dpi=600, dev='png'}
summary(a$numMentors)
ggplot(data = a, mapping = aes(x = numMentors)) + geom_histogram() +
ggtitle("Distribution of numMentors")
ggplot(data = a, mapping = aes(x = ProtegeFirstPubYear, y = numMentors, col=ProtegeGender)) + geom_point() +
ggtitle("ProtegeFirstPubYear vs. numMentors")
ggplot(data = a, mapping = aes(x = ProtegeFirstPubYear, y = numMentors)) + geom_point() + facet_grid( ~ ProtegeGender) +
ggtitle("ProtegeFirstPubYear vs. numMentors")
```
## Problem: some `numMentors` values are too large
How could someone possibly really have more than a handful of mentors?
In the first `r LinesRead` lines of this data set, there are individuals with `r max(a$numMentors)` mentors!
The Supplement states that:
"Whenever a junior scientist publishes a paper with a senior scientist, we consider the former to be a protege, and the latter to be a mentor, as long as they authored at least one paper with 20 or less co-authors and share the same discipline and US-based affiliation."
Oh, but we are really measuring co-authorship at the same US-based affiliation on joint papers with 20 or less co-authors.
# Summary
Here I examine the data provided by the authors of this paper:
AlShebli B, Makovi K, Rahwan T. The association between early career informal mentorship in academic collaborations and junior author performance. Nat Commun. 2020 Nov 17;11(1):5855. doi: 10.1038/s41467-020-19723-8. PMID: 33203848.
https://pubmed.ncbi.nlm.nih.gov/33203848/
For speed, I examined only the first `r LinesRead` lines of the data file `r inFile` from the 'bedoor/Mentorship' GitHub repository at
https://github.com/bedoor/Mentorship
Their repository is described by the authors as:
'This repository includes all data used in "The Association between Early Career Informal Mentorship in Academic Collaborations and Junior Author Performance".'
## Problem: No gender information for mentors
There does not appear to be any information in the provided file about the mentor's gender, so the provided data do not appear to be 'all the data'.
## Problem: ProtegeFirstPubYear time range is very large
In the first `r LinesRead` lines of this data set, the `ProtegeFirstPubYear` ranges from `r min(a$ProtegeFirstPubYear)` to `r max(a$ProtegeFirstPubYear)`. It seems that it would be very difficult to properly compare the impact factors of papers published in `r min(a$ProtegeFirstPubYear)`, well before the advent of team science and the current deluge of scientific publications, to those published as recently `r max(a$ProtegeFirstPubYear)`.
```{r, dpi=600, dev='png', echo=FALSE}
ggplot(data = a, mapping = aes(x = ProtegeFirstPubYear, y = Avg_c5)) + geom_point() + facet_grid( ~ ProtegeGender) +
ggtitle("ProtegeFirstPubYear vs. Avg_c5")
```
## Problem: Error in the equation for NumYearsPostMentorship
Note that the stated equation of `2015 - (x + 6)` for computing the number of years post mentorship is not what was used, as instead `2015 - (x + 2)`, where `x` is the year the protege's paper was first published.
## Problem: some values of `NumYearsPostMentorship` are unrealistically large
In the first `r LinesRead` lines of the input file of this data set, there are values of `NumYearsPostMentorship` as large as `r max(a$NumYearsPostMentorship)`. These values are unrealistically large.
```{r, dpi=600, dev='png', echo=FALSE}
a$ProtegeGender <- as.factor(a$Pr0tegeGender)
p <- ggplot(data = a, mapping = aes(x = ProtegeFirstPubYear, y = NumYearsPostMentorship)) + geom_point() + ggtitle("NumYearsPostMentorship vs. ProtegeFirstPubYear")
ggMarginal(p, type="histogram")
```
## Problem: some `AvgMentorsAcAges` are unrealistically large
There are `AvgMentorsAcAges` as large as `r max(a$AvgMentorsAcAges)` in the first `r LinesRead` lines of this data set. This is unrealistically large.
Among proteges who published their first paper after 2000, there are `AvgMentorsAcAges` as large as `r max(a[a$ProtegeFirstPubYear > 2000, ]$AvgMentorsAcAges)` in this data set. Should we be evaluating the mentorship effects of mentors who were born than 200 years ago?
```{r, dpi=600, dev='png', echo=FALSE}
ggplot(data = a, mapping = aes(x = ProtegeFirstPubYear, y = AvgMentorsAcAges)) + geom_point() + facet_grid(~ ProtegeGender) +
ggtitle("ProtegeFirstPubYear vs. AvgMentorsAcAges by ProtegeGender")
```
## Problem with Avg_c10: Cannot compute a value `Avg_c10` for recent publications
As the dataset is up to Dec 31st 2019, how can one compute a valid `Avg_c10` for someone whose first publication year was 2012 or 2013?
```{r, dpi=600, dev='png', echo=FALSE}
ggplot(data = a, mapping = aes(x = ProtegeFirstPubYear, y = Avg_c10)) + geom_point() + facet_grid( ~ ProtegeGender) +
ggtitle("ProtegeFirstPubYear vs. Avg_c10")
```
## Problem: some `numMentors` values are too large
How could someone possibly really have more than a handful of mentors?
In the first `r LinesRead` lines of this data set, there are individuals with `r max(a$numMentors)` mentors!
The Supplement states that:
"Whenever a junior scientist publishes a paper with a senior scientist, we consider the former to be a protege, and the latter to be a mentor, as long as they authored at least one paper with 20 or less co-authors and share the same discipline and US-based affiliation."
Oh, but we are really measuring **co-authorship** at the same US-based affiliation on joint papers with 20 or less co-authors.
```{r, dpi=600, dev='png', echo=FALSE}
ggplot(data = a, mapping = aes(x = ProtegeFirstPubYear, y = numMentors)) + geom_point() + facet_grid( ~ ProtegeGender) +
ggtitle("ProtegeFirstPubYear vs. numMentors")
```
# Generating GitHub Markdown
```{r}
library(rmarkdown)
library(here)
finalize <- function() {
rmd <- here("mentorship.Rmd")
rmarkdown::render(rmd, "github_document")
}
```
# Session Information
```{r}
sessionInfo()
```