---
# System prepended metadata

title: t tests
tags: [Rscripts]

---

---
tags: Rscripts
---
# t tests
---
title: "temp experiment stats"
author: "Dani Blumstein"
date: "5/20/2020"
output: html_document
---

t test summary table
|variable|x|y|t|df|p-value|mean x| mean y|
| -------- | -------- | -------- | -------- |-------- |-------- |-------- |-------- |
|EE|baselineM|baselineF|9.7755|3893.7|< 2.2e-16|0.2033909|0.1635072|
|RQ|baselineM|baselineF|-6.3439|3736.7|2.508e-10|0.9416173|0.9834000
|H2O|baselineM|baselineF|12.266|3723.7|< 2.2e-16|0.1682796|0.1294695|
|EE|baseline nightM|baseline dayM|40.588|627.1|< 2.2e-16|0.3128184|0.0941565|
|RQ|baseline nightM|baseline dayM|-12.988|957.43|< 2.2e-16|0.8603261|0.9864855|
|H2O|baseline nightM|baseline dayM|-6.0397|913.93|= 2.244e-09|0.1399354|0.1676843|
|EE|baseline nightF|baseline dayF|33.132|621.12|< 2.2e-16|0.25905369|0.08243107|
|RQ|baseline nightF|baseline dayF|-16.291|809.74|< 2.2e-16|0.8693106|1.0446184|
|H2O|baseline nightF|baseline dayF|-4.8985|926.21|= 1.14e-06|0.1134582|0.1288508|


**t test for sex**
```{r}
baselineM <- subset(baseline$EE, baseline$Sex == "M")
baselineF <- subset(baseline$EE, baseline$Sex == "F")
EE_ttest <- t.test(baselineM, baselineF)
print(EE_ttest)
```
Welch Two Sample t-test
data:  baselineM and baselineF
t = 9.7755, df = 3893.7, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 0.03188464 0.04788280
sample estimates:
mean of x mean of y 
0.2033909 0.1635072

```{r}
baselineM <- subset(baseline$RQ, baseline$Sex == "M")
baselineF <- subset(baseline$RQ, baseline$Sex == "F")
RQ_ttest <- t.test(baselineM, baselineF)
print(RQ_ttest)
```
Welch Two Sample t-test
data:  baselineM and baselineF
t = -6.3439, df = 3736.7, p-value = 2.508e-10
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.05469583 -0.02886958
sample estimates:
mean of x mean of y 
0.9416173 0.9834000 

```{r}
baselineM <- subset(baseline$H2Omg, baseline$Sex == "M")
baselineF <- subset(baseline$H2Omg, baseline$Sex == "F")
H2O_ttest <- t.test(baselineM, baselineF)
print(H2O_ttest)
```
Welch Two Sample t-test
data:  baselineM and baselineF
t = 12.266, df = 3723.7, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 0.03260651 0.04501362
sample estimates:
mean of x mean of y 
0.1682796 0.1294695


**t test for day night M**
```{r}
night <- with(baseline ,baseline[ hour( StartTime ) >= 0 & hour( StartTime ) < 6 , ] )
day <- with(baseline ,baseline[ hour( StartTime ) >= 13 & hour( StartTime ) < 19 , ] )

nightM <- subset(night$EE, night$Sex == "M")
dayM <- subset(day$EE, day$Sex == "M")
RQ_ttest <- t.test(nightM, dayM)
print(RQ_ttest)
```
Welch Two Sample t-test
data:  nightM and dayM
t = 40.588, df = 627.1, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 0.2080824 0.2292413
sample estimates:
mean of x mean of y 
0.3128184 0.0941565 

```{r}
nightM <- subset(night$RQ, night$Sex == "M")
dayM <- subset(day$RQ, day$Sex == "M")
RQ_ttest <- t.test(nightM, dayM)
print(RQ_ttest)
```
Welch Two Sample t-test
data:  nightM and dayM
t = -12.988, df = 957.43, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.1452216 -0.1070973
sample estimates:
mean of x mean of y 
0.8603261 0.9864855 
```
nightM <- subset(night$H2Omg, night$Sex == "M")
dayM <- subset(day$H2Omg, day$Sex == "M")
H2O_ttest <- t.test(nightM, dayM)
print(H2O_ttest)
```
Welch Two Sample t-test
data:  nightM and dayM
t = -6.0397, df = 913.93, p-value = 2.244e-09
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.03676569 -0.01873213
sample estimates:
mean of x mean of y 
0.1399354 0.1676843

**t test for day night F**
```{r}
nightF <- subset(night$EE, night$Sex == "F")
dayF <- subset(day$EE, day$Sex == "F")
EE_ttest <- t.test(nightF, dayF)
print(EE_ttest)
```
Welch Two Sample t-test
data:  nightF and dayF
t = 33.132, df = 621.12, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 0.1661540 0.1870913
sample estimates:
 mean of x  mean of y 
0.25905369 0.08243107

```{r}
nightF <- subset(night$RQ, night$Sex == "F")
dayF <- subset(day$RQ, day$Sex == "F")
RQ_ttest <- t.test(nightF, dayF)
print(RQ_ttest)
```
Welch Two Sample t-test
data:  nightF and dayF
t = -16.291, df = 809.74, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.1964306 -0.1541850
sample estimates:
mean of x mean of y 
0.8693106 1.0446184

```{r}
nightF <- subset(night$H2Omg, night$Sex == "F")
dayF <- subset(day$H2Omg, day$Sex == "F")
H2O_ttest <- t.test(nightF, dayF)
print(H2O_ttest)
```
Welch Two Sample t-test
data:  nightF and dayF
t = -4.8985, df = 926.21, p-value = 1.14e-06
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 -0.021559452 -0.009225637
sample estimates:
mean of x mean of y 
0.1134582 0.1288508 