-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1_OCMATE_hormone_reliability.html
766 lines (703 loc) · 26.2 KB
/
1_OCMATE_hormone_reliability.html
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
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta name="author" content="Jones et al., multilevel reliability calculations by Arslan et al." />
<title>1_OCMATE_hormone_reliability.utf8.md</title>
<script src="site_libs/jquery-1.11.3/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="site_libs/bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<script src="site_libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/respond.min.js"></script>
<script src="site_libs/navigation-1.1/tabsets.js"></script>
<link href="site_libs/highlightjs-9.12.0/default.css" rel="stylesheet" />
<script src="site_libs/highlightjs-9.12.0/highlight.js"></script>
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
pre:not([class]) {
background-color: white;
}
</style>
<script type="text/javascript">
if (window.hljs) {
hljs.configure({languages: []});
hljs.initHighlightingOnLoad();
if (document.readyState && document.readyState === "complete") {
window.setTimeout(function() { hljs.initHighlighting(); }, 0);
}
}
</script>
<style type="text/css">
h1 {
font-size: 34px;
}
h1.title {
font-size: 38px;
}
h2 {
font-size: 30px;
}
h3 {
font-size: 24px;
}
h4 {
font-size: 18px;
}
h5 {
font-size: 16px;
}
h6 {
font-size: 12px;
}
.table th:not([align]) {
text-align: left;
}
</style>
</head>
<body>
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
code {
color: inherit;
background-color: rgba(0, 0, 0, 0.04);
}
img {
max-width:100%;
height: auto;
}
.tabbed-pane {
padding-top: 12px;
}
.html-widget {
margin-bottom: 20px;
}
button.code-folding-btn:focus {
outline: none;
}
</style>
<style type="text/css">
/* padding for bootstrap navbar */
body {
padding-top: 51px;
padding-bottom: 40px;
}
/* offset scroll position for anchor links (for fixed navbar) */
.section h1 {
padding-top: 56px;
margin-top: -56px;
}
.section h2 {
padding-top: 56px;
margin-top: -56px;
}
.section h3 {
padding-top: 56px;
margin-top: -56px;
}
.section h4 {
padding-top: 56px;
margin-top: -56px;
}
.section h5 {
padding-top: 56px;
margin-top: -56px;
}
.section h6 {
padding-top: 56px;
margin-top: -56px;
}
</style>
<script>
// manage active state of menu based on current page
$(document).ready(function () {
// active menu anchor
href = window.location.pathname
href = href.substr(href.lastIndexOf('/') + 1)
if (href === "")
href = "index.html";
var menuAnchor = $('a[href="' + href + '"]');
// mark it active
menuAnchor.parent().addClass('active');
// if it's got a parent navbar menu mark it active as well
menuAnchor.closest('li.dropdown').addClass('active');
});
</script>
<div class="container-fluid main-container">
<!-- tabsets -->
<script>
$(document).ready(function () {
window.buildTabsets("TOC");
});
</script>
<!-- code folding -->
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">Fertility diary</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="1_power_analysis.html">Power analysis</a>
</li>
<li>
<a href="1_researcher_df_analysis.html">Researcher degree of freedom simulation</a>
</li>
<li>
<a href="1_wrangle_data.html">Data wrangling</a>
</li>
<li>
<a href="2_descriptives.html">Descriptives</a>
</li>
<li>
<a href="3_fertility_as_prereg.html">Preregistered analyses</a>
</li>
<li>
<a href="3_fertility_robustness.html">Robustness tests</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
<div class="fluid-row" id="header">
</div>
<div id="re-analysis-of-ocmate-data-to-get-reliability-of-change" class="section level1 tab-content">
<h1>Re-analysis of OCMATE data to get reliability of change</h1>
<div id="pre-process-data" class="section level2">
<h2>Pre-process data</h2>
<pre class="r"><code># Load packages
library(tidyr)
library(dplyr)</code></pre>
<pre><code>##
## Attaching package: 'dplyr'</code></pre>
<pre><code>## The following objects are masked from 'package:stats':
##
## filter, lag</code></pre>
<pre><code>## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union</code></pre>
<pre class="r"><code>library(ggplot2)
library(lme4)</code></pre>
<pre><code>## Loading required package: Matrix</code></pre>
<pre><code>##
## Attaching package: 'Matrix'</code></pre>
<pre><code>## The following object is masked from 'package:tidyr':
##
## expand</code></pre>
<pre class="r"><code>library(lmerTest)</code></pre>
<pre><code>##
## Attaching package: 'lmerTest'</code></pre>
<pre><code>## The following object is masked from 'package:lme4':
##
## lmer</code></pre>
<pre><code>## The following object is masked from 'package:stats':
##
## step</code></pre>
<pre class="r"><code>library(knitr)
options(scipen=999)
knitr::opts_chunk$set(cache=TRUE)</code></pre>
<pre class="r"><code># calculate standard errors
se <- function(x, na.rm = FALSE) {
if (na.rm) {
the.SE <- sqrt(var(x,na.rm=TRUE)/length(na.omit(x)))
} else {
the.SE <- sqrt(var(x,na.rm=FALSE)/length(x))
}
return(the.SE)
}
# short summaries for lmerTest
mySummary<-function(lmer_summary) {
coefTable <- lmer_summary$coefficients %>%
round(3) %>%
as.data.frame() %>%
rownames_to_column()
if (ncol(coefTable)>5) {
coefTable <- coefTable %>%
mutate(
sig = ifelse(.[6]<.001, " * * * ",
ifelse(.[6]<.01, " * * ",
ifelse(.[6]<.05, " * ",
ifelse(.[6]<.10, "+", "")))))
}
return(list(lmer_summary$ngrps, kable(coefTable)))
}</code></pre>
<div id="load-data" class="section level3">
<h3>Load data</h3>
<p>Data entered from all white, heterosexual women not using any form of hormonal contraceptives Each row is all data from a single session (i.e. oc_id:date)</p>
<ul>
<li>“oc_id” = ID of the subject<br />
</li>
<li>“block” = testing block (1, 2 or 3)</li>
<li>“block_N” = how many testing sessions completed in that block</li>
<li>“age” = age (in years) of subject on day of testing<br />
</li>
<li>“ethnicity” = ethnic group of subject (all white)</li>
<li>“sexpref” = sexual preference of subject (all heterosexual)</li>
<li>“date” = date of testing session</li>
<li>“partner” = does subject currently have a romantic partner? (0 = no partner, 1 = yes partner)</li>
<li>“block_partner” = all unique partner column values in the block (0 if never had partner, 1 if always had partner, otherwised mixed: e.g., 1,0)</li>
<li>“behavior_soi” = behavior subscale of SOI-R</li>
<li>“attitude_soi” = attitude subscale of SOI-R</li>
<li>“desire_soi” = desire subscale of SOI-R</li>
<li>“current_sexdrive”= current sex drive score</li>
<li>“solitary_SDI” = solitary desire subscale of SDI-2</li>
<li>“dyadic_SDI” = dyadic desire subscale of SDI-2</li>
<li>“total_SDI” = total score on SDI-2</li>
<li>“progesterone” = salivary progesterone for that session</li>
<li>“estradiol” = salivary estradiol for that session</li>
<li>“testosterone” = salivary testosterone for that session</li>
<li>“cortisol” = salivary cortisol for that session</li>
</ul>
<pre class="r"><code>data_start <- read.csv("OCMATE_sexdrive_anon.csv", stringsAsFactors = F) </code></pre>
<div id="re-code-variables" class="section level4">
<h4>Re-code variables</h4>
<ul>
<li>partner.e = partnership status (no = -0.5, partner = +0.5, mixed = NA)</li>
</ul>
<pre class="r"><code># wide to long format
# effect code partnership status (no = -0.5, partner = 0.5)
data_all <- data_start %>%
gather(question, score, behavior_soi:total_SDI) %>%
mutate(
partner.e = ifelse(block_partner==0, -0.5, ifelse(block_partner==1, 0.5, NA)),
prog = progesterone,
estr = estradiol,
test = testosterone,
cort = cortisol
)</code></pre>
</div>
</div>
<div id="age" class="section level3">
<h3>Age</h3>
<pre class="r"><code># mean age at start of testing
data_all %>%
group_by(oc_id) %>%
summarise(
min_age = min(age, na.rm = TRUE)
) %>%
ungroup() %>%
group_by() %>%
summarise(
n = n(),
mean_age = mean(min_age, na.rm = TRUE),
sd_age = sd(min_age, na.rm = TRUE)
) %>% t()</code></pre>
<pre><code>## [,1]
## n 375
## mean_age Inf
## sd_age Inf</code></pre>
</div>
<div id="descriptive-stats-for-questionaires" class="section level3">
<h3>Descriptive Stats for Questionaires</h3>
<pre class="r"><code>data_all %>%
group_by(question) %>%
summarise(
N_valid = sum(!is.na(score)),
N_missing = sum(is.na(score)),
mean_score = mean(score, na.rm = TRUE),
sd_score = sd(score, na.rm = TRUE)
)</code></pre>
<pre><code>## # A tibble: 7 x 5
## question N_valid N_missing mean_score sd_score
## <chr> <int> <int> <dbl> <dbl>
## 1 attitude_soi 2189 87 9.22 3.50
## 2 behavior_soi 2140 136 5.74 2.67
## 3 current_sexdrive 2145 131 3.77 1.56
## 4 desire_soi 2168 108 8.06 2.96
## 5 dyadic_SDI 2098 178 35.5 11.9
## 6 solitary_SDI 2099 177 8.63 6.46
## 7 total_SDI 2051 225 44.1 15.7</code></pre>
</div>
<div id="the-number-of-sessions-completed-per-woman" class="section level3">
<h3>The number of sessions completed per woman</h3>
<pre class="r"><code>data_all %>%
group_by(oc_id) %>%
summarise(
sessions = n_distinct(date)
) %>%
group_by(sessions) %>%
summarise(
n = n()
) %>%
spread(sessions, n) %>%
t()</code></pre>
<pre><code>## [,1]
## 1 15
## 2 9
## 3 5
## 4 9
## 5 233
## 6 1
## 7 1
## 8 2
## 9 2
## 10 98</code></pre>
</div>
<div id="exclude-observations-with-missing-estr-prog-and-test" class="section level3">
<h3>Exclude observations with missing estr, prog and test</h3>
<pre class="r"><code>## Exclude observations with EPT missing hormone values
sub_hormones_no_EPT <- data_all %>%
filter(
!is.na(prog) |
!is.na(estr) |
!is.na(test)
)</code></pre>
</div>
<div id="exclude-subjects-with-only-a-single-session-in-a-block" class="section level3">
<h3>Exclude subjects with only a single session in a block</h3>
<p>This is necessary because you can’t calculate subject-centered means with only one data point.</p>
<pre class="r"><code>check_single_session <- sub_hormones_no_EPT %>%
group_by(oc_id, block) %>%
summarise(sessions = n_distinct(date)) %>%
ungroup() %>%
filter(sessions == 1)
sub_hormones_multisession <- sub_hormones_no_EPT %>%
anti_join(check_single_session, by=c('oc_id', 'block'))</code></pre>
</div>
<div id="remove-outlier-hormone-values" class="section level3">
<h3>Remove outlier hormone values</h3>
<p>Remove below bottom sensitivity thresholds for assays (progesterone < 5, estrogen < 0.1), and remove outlier values (+/- 3SD from the mean)</p>
<pre class="r"><code>sub_hormones_no_outliers <- sub_hormones_multisession %>%
mutate(
prog = ifelse(prog >= 5, prog, NA),
estr = ifelse(estr >= 0.1, estr, NA),
prog = if_else(prog>mean(prog, na.rm=TRUE) + 3*sd(prog, na.rm=TRUE) |
prog<mean(prog, na.rm=TRUE) - 3*sd(prog, na.rm=TRUE), NA_real_, prog),
estr = ifelse(estr>mean(estr, na.rm=TRUE) + 3*sd(estr, na.rm=TRUE) |
estr<mean(estr, na.rm=TRUE) - 3*sd(estr, na.rm=TRUE), NA, estr),
test = ifelse(test>mean(test, na.rm=TRUE) + 3*sd(test, na.rm=TRUE) |
test<mean(test, na.rm=TRUE) - 3*sd(test, na.rm=TRUE), NA, test),
cort = ifelse(cort>mean(cort, na.rm=TRUE) + 3*sd(cort, na.rm=TRUE) |
cort<mean(cort, na.rm=TRUE) - 3*sd(cort, na.rm=TRUE), NA, cort)
)
qplot(sub_hormones_no_outliers$prog)</code></pre>
<pre><code>## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.</code></pre>
<pre><code>## Warning: Removed 287 rows containing non-finite values (stat_bin).</code></pre>
<p><img src="1_OCMATE_hormone_reliability_files/figure-html/unnamed-chunk-10-1.png" width="672" /></p>
<pre class="r"><code># how many included?
check_hormone_exclusions <- sub_hormones_no_outliers %>%
group_by(oc_id, date) %>%
summarise(
e = is.na(mean(estr)),
p = is.na(mean(prog)),
t = is.na(mean(test)),
c = is.na(mean(cort))
) %>%
ungroup() %>%
select(e:c) %>%
gather('hormone','na', e:c) %>%
group_by(hormone) %>%
summarise(
'valid' = n() - sum(na),
'excluded' = sum(na)
) %>%
arrange(hormone)
kable(check_hormone_exclusions)</code></pre>
<table>
<thead>
<tr class="header">
<th align="left">hormone</th>
<th align="right">valid</th>
<th align="right">excluded</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">c</td>
<td align="right">2155</td>
<td align="right">11</td>
</tr>
<tr class="even">
<td align="left">e</td>
<td align="right">2146</td>
<td align="right">20</td>
</tr>
<tr class="odd">
<td align="left">p</td>
<td align="right">2125</td>
<td align="right">41</td>
</tr>
<tr class="even">
<td align="left">t</td>
<td align="right">2143</td>
<td align="right">23</td>
</tr>
</tbody>
</table>
<pre class="r"><code> check_hormone_exclusions %>%
group_by() %>%
summarise(
total_hormone_samples_valid = sum(valid),
total_hormone_samples_excluded = sum(excluded)
) %>% gather("stat", "value", 1:length(.))</code></pre>
<pre><code>## # A tibble: 2 x 2
## stat value
## <chr> <int>
## 1 total_hormone_samples_valid 8569
## 2 total_hormone_samples_excluded 95</code></pre>
</div>
<div id="subject-mean-centre-hormones" class="section level3">
<h3>Subject-mean-centre hormones</h3>
<p>Divide results by a constant to put all hormones on ~ -0.5 to +0.5 scale</p>
<pre class="r"><code># subject-mean-centre hormones
# and divide by a constant to put all hormones on ~ -0.5 to +0.5 scale
data_hormones <- sub_hormones_no_outliers %>%
group_by(oc_id) %>%
mutate(prog.s = (prog-mean(prog, na.rm=TRUE))/400,
estr.s = (estr-mean(estr, na.rm=TRUE))/5,
test.s = (test-mean(test, na.rm=TRUE))/100,
cort.s = (cort-mean(cort, na.rm=TRUE))/0.5,
ep_ratio.s = ((estr/prog)-mean(estr/prog, na.rm=TRUE))/0.075) %>%
ungroup() %>%
as.data.frame()
data_hormones %>%
group_by(oc_id, date, prog.s, estr.s, test.s, cort.s, ep_ratio.s) %>%
summarise(n = n()) %>%
ungroup() %>%
gather("hormone", "value", prog.s:ep_ratio.s) %>%
ggplot(aes(value, colour=hormone)) +
geom_density(alpha=.5) +
scale_x_continuous(limits = c(-1,1))</code></pre>
<pre><code>## Warning: Removed 200 rows containing non-finite values (stat_density).</code></pre>
<p><img src="1_OCMATE_hormone_reliability_files/figure-html/unnamed-chunk-13-1.png" width="672" /></p>
</div>
<div id="mean-hormone-levels" class="section level3">
<h3>Mean Hormone Levels</h3>
<pre class="r"><code>data_hormones %>%
group_by(oc_id, date, prog, estr, test, cort) %>%
summarise(n = n()) %>%
ungroup() %>%
group_by() %>%
summarise(
mean_prog = mean(prog, na.rm = TRUE),
sd_prog = sd(prog, na.rm = TRUE),
se_prog = se(prog, na.rm = TRUE),
mean_estr = mean(estr, na.rm = TRUE),
sd_estr = sd(estr, na.rm = TRUE),
se_estr = se(estr, na.rm = TRUE),
mean_test = mean(test, na.rm = TRUE),
sd_test = sd(test, na.rm = TRUE),
se_test = se(test, na.rm = TRUE),
mean_cort = mean(cort, na.rm = TRUE),
sd_cort = sd(cort, na.rm = TRUE),
se_cort = se(cort, na.rm = TRUE)
) %>% gather("stat", "value", 1:length(.)) %>%
mutate(value = round(value, 4)) %>%
separate(stat, c("stat", "hormone")) %>%
spread(stat, value)</code></pre>
<pre><code>## # A tibble: 4 x 4
## hormone mean sd se
## <chr> <dbl> <dbl> <dbl>
## 1 cort 0.229 0.164 0.0035
## 2 estr 3.30 1.27 0.0275
## 3 prog 149. 96.2 2.09
## 4 test 87.6 27.2 0.587</code></pre>
</div>
<div id="partnership" class="section level3">
<h3>Partnership</h3>
<p>Exclude blocks with partner inconsistently reported and women who change partnership status between blocks, only for analyses considering partnership status</p>
<pre class="r"><code>data_hormones_partner <- data_hormones %>%
filter(block_partner == "0" | block_partner =="1") %>%
group_by(oc_id) %>%
mutate(pchange = mean(partner.e)) %>%
ungroup() %>%
filter(pchange %in% c(-.5, .5)) %>%
select(-pchange)</code></pre>
<hr />
</div>
</div>
<div id="multilevel-reliability-generalizability-analyses" class="section level2 tab-content active">
<h2>Multilevel Reliability / Generalizability Analyses</h2>
<pre class="r"><code>library(psych)
data_wide = data_hormones %>% select(oc_id, date, block, estr, prog, test, cort) %>% unique()
data_wide <- data_wide %>% group_by(oc_id) %>%
arrange(oc_id, date) %>%
mutate(timepoint = row_number()) %>%
ungroup() %>% as.data.frame()</code></pre>
<div id="estradiol" class="section level3">
<h3>Estradiol</h3>
<pre class="r"><code>multilevel.reliability(data_wide %>% select(oc_id, date, estr), "oc_id", "date", 3, aov = F)</code></pre>
<pre><code>## Warning in cov2cor(C): diag(.) had 0 or NA entries; non-finite result is
## doubtful</code></pre>
<pre><code>##
## Multilevel Generalizability analysis
## Call: multilevel.reliability(x = data_wide %>% select(oc_id, date,
## estr), grp = "oc_id", Time = "date", items = 3, aov = F)
##
## The data had 352 observations taken over 306 time intervals for 1 items.
##
## Alternative estimates of reliability based upon Generalizability theory
##
## RkRn = 1 Generalizability of between person differences averaged over time (time nested within people)
## Rcn = 0.83 Generalizability of within person variations averaged over items (time nested within people)
## The nested components of variance estimated from lme are:
## Variance Percent
## id 0.92 0.548
## id(time) 0.63 0.377
## residual 0.13 0.075
## total 1.68 1.000
##
## To see the ANOVA and alpha by subject, use the short = FALSE option.
## To see the summaries of the ICCs by subject and time, use all=TRUE
## To see specific objects select from the following list:
## ANOVA s.lmer s.lme alpha summary.by.person summary.by.time ICC.by.person ICC.by.time lmer long Call</code></pre>
<pre class="r"><code>data_wide %>%
select(oc_id, timepoint, estr) %>%
spread(timepoint, estr) %>%
select(-oc_id) %>%
cor(use='na.or.complete') %>%
corrr::rplot(print_cor = T)</code></pre>
<p><img src="1_OCMATE_hormone_reliability_files/figure-html/unnamed-chunk-17-1.png" width="672" /></p>
</div>
<div id="progesterone" class="section level3">
<h3>Progesterone</h3>
<pre class="r"><code>multilevel.reliability(data_wide %>% select(oc_id, date, prog), "oc_id", "date", 3, aov = F)</code></pre>
<pre><code>##
## Multilevel Generalizability analysis
## Call: multilevel.reliability(x = data_wide %>% select(oc_id, date,
## prog), grp = "oc_id", Time = "date", items = 3, aov = F)
##
## The data had 352 observations taken over 306 time intervals for 1 items.
##
## Alternative estimates of reliability based upon Generalizability theory
##
## RkRn = 0.99 Generalizability of between person differences averaged over time (time nested within people)
## Rcn = 0.86 Generalizability of within person variations averaged over items (time nested within people)
## The nested components of variance estimated from lme are:
## Variance Percent
## id 3014 0.324
## id(time) 5392 0.579
## residual 899 0.097
## total 9305 1.000
##
## To see the ANOVA and alpha by subject, use the short = FALSE option.
## To see the summaries of the ICCs by subject and time, use all=TRUE
## To see specific objects select from the following list:
## ANOVA s.lmer s.lme alpha summary.by.person summary.by.time ICC.by.person ICC.by.time lmer long Call</code></pre>
<pre class="r"><code>data_wide %>%
select(oc_id, timepoint, prog) %>%
spread(timepoint, prog) %>%
select(-oc_id) %>%
cor(use='na.or.complete') %>%
corrr::rplot(print_cor = T)</code></pre>
<p><img src="1_OCMATE_hormone_reliability_files/figure-html/unnamed-chunk-18-1.png" width="672" /></p>
</div>
<div id="testosterone" class="section level3">
<h3>Testosterone</h3>
<pre class="r"><code>multilevel.reliability(data_wide %>% select(oc_id, date, test), "oc_id", "date", 3, aov = F)</code></pre>
<pre><code>## Warning in cov2cor(C): diag(.) had 0 or NA entries; non-finite result is
## doubtful</code></pre>
<pre><code>##
## Multilevel Generalizability analysis
## Call: multilevel.reliability(x = data_wide %>% select(oc_id, date,
## test), grp = "oc_id", Time = "date", items = 3, aov = F)
##
## The data had 352 observations taken over 306 time intervals for 1 items.
##
## Alternative estimates of reliability based upon Generalizability theory
##
## RkRn = 1 Generalizability of between person differences averaged over time (time nested within people)
## Rcn = 0.83 Generalizability of within person variations averaged over items (time nested within people)
## The nested components of variance estimated from lme are:
## Variance Percent
## id 432 0.573
## id(time) 268 0.355
## residual 55 0.072
## total 755 1.000
##
## To see the ANOVA and alpha by subject, use the short = FALSE option.
## To see the summaries of the ICCs by subject and time, use all=TRUE
## To see specific objects select from the following list:
## ANOVA s.lmer s.lme alpha summary.by.person summary.by.time ICC.by.person ICC.by.time lmer long Call</code></pre>
<pre class="r"><code>data_wide %>%
select(oc_id, timepoint, test) %>%
spread(timepoint, test) %>%
select(-oc_id) %>%
cor(use='na.or.complete') %>%
corrr::rplot(print_cor = T)</code></pre>
<p><img src="1_OCMATE_hormone_reliability_files/figure-html/unnamed-chunk-19-1.png" width="672" /></p>
<pre class="r"><code># data_wide %>% select(oc_id, date, test) %>% group_by(oc_id) %>%
# arrange(oc_id, date) %>%
# mutate(
# date = as.Date(date),
# time_since_start = round(as.numeric(date - min(date)))) %>%
# ungroup() %>%
# spread(time_since_start, test) %>%
# select(-oc_id, -date) %>%
# cor(use='na.or.complete') %>%
# corrr::rplot(print_cor = T)</code></pre>
</div>
<div id="cortisol" class="section level3">
<h3>Cortisol</h3>
<pre class="r"><code>multilevel.reliability(data_wide %>% select(oc_id, date, cort), "oc_id", "date", 3, aov = F)</code></pre>
<pre><code>## Warning in cov2cor(C): diag(.) had 0 or NA entries; non-finite result is
## doubtful
## Warning in cov2cor(C): diag(.) had 0 or NA entries; non-finite result is
## doubtful</code></pre>
<pre><code>##
## Multilevel Generalizability analysis
## Call: multilevel.reliability(x = data_wide %>% select(oc_id, date,
## cort), grp = "oc_id", Time = "date", items = 3, aov = F)
##
## The data had 352 observations taken over 306 time intervals for 1 items.
##
## Alternative estimates of reliability based upon Generalizability theory
##
## RkRn = 1 Generalizability of between person differences averaged over time (time nested within people)
## Rcn = 0.85 Generalizability of within person variations averaged over items (time nested within people)
## The nested components of variance estimated from lme are:
## Variance Percent
## id 0.0123 0.432
## id(time) 0.0137 0.481
## residual 0.0025 0.087
## total 0.0285 1.000
##
## To see the ANOVA and alpha by subject, use the short = FALSE option.
## To see the summaries of the ICCs by subject and time, use all=TRUE
## To see specific objects select from the following list:
## ANOVA s.lmer s.lme alpha summary.by.person summary.by.time ICC.by.person ICC.by.time lmer long Call</code></pre>
<pre class="r"><code>data_wide %>%
select(oc_id, timepoint, cort) %>%
spread(timepoint, cort) %>%
select(-oc_id) %>%
cor(use='na.or.complete') %>%
corrr::rplot(print_cor = T)</code></pre>
<p><img src="1_OCMATE_hormone_reliability_files/figure-html/unnamed-chunk-20-1.png" width="672" /></p>
</div>
</div>
</div>
</div>
<script>
// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
$('tr.header').parent('thead').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
bootstrapStylePandocTables();
});
</script>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>