-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathabd17-28.Rmd
99 lines (90 loc) · 3 KB
/
abd17-28.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
---
title: "Analysis of Biological Data Chapter 17 Assignment Problem 28"
author: "your name"
date: "`r Sys.Date()`"
output:
html_document:
highlight: pygments
toc: yes
major: regression modeling; ABD
minor: ordinary least squares
---
# Data
The data are from Sherwood, C. C., _et al_. 2006. _Proceedings of the National Academy of Sciences (USA)_ **103**: 13606–13611.
```{r setup}
require(rms)
knitrSet(lang='markdown')
```
```{r input}
# What is between data <- .. and ') is exactly like an external .csv file
data <- textConnection('
species,mass,ratio
homo sapiens,1373.3,1.65
pan troglodytes,336.2,1.2
gorilla gorilla,509.2,1.21
pongo pygmaeus,342.7,.98
hylobates muelleri,101.8,1.22
papio anubis,155.8,.97
mandrillus sphinx,159.2,1.02
macaca maura,92.6,1.09
erythrocebus patas,102.3,.84
cercopithecus kandti,71.6,1.15
colobus angolensis,74.4,1.20
trachypithecus francoisi,91.2,1.14
alouatta caraya,55.8,1.12
saimire boliviensis,24.1,.51
aotus trivirgatus,13.2,.63
saguinus oedipus,10,.46
leontopithecus rosalia,12.2,.6
pithecia pithecia,30,.64
')
d <- csv.get(data)
close(data)
d <- upData(d, labels=c(species = 'Species', mass='Brain Mass',
ratio = 'Glia-neuron Ratio'),
units=c(mass='g'))
xl <- label(d$mass, plot=TRUE, units=TRUE)
yl <- label(d$ratio)
```
Raw data are logging x then logging both x and y.
```{r show,h=4}
contents(d)
d # same as print(d)
# Function to form 2-letter versions of species names using
# first letter of each word
w <- function(x) {
x <- strsplit(as.character(x), split=' ')
sapply(x, function(y) paste(substring(y, 1, 1), collapse=''))
}
ggplot(d, aes(x=mass, y=ratio, color=species)) + geom_point() +
geom_text(aes(label=w(species)), size=2, hjust=1.3) +
scale_x_log10(breaks=c(10,25,50,100,200,500,1000)) + xlab(xl) + ylab(yl) +
guides(col=guide_legend(nrow=4, override.aes=list(size=1))) +
theme(legend.position='bottom', legend.text=element_text(size=4),
legend.key.size=unit(2, 'mm'))
ggplot(d, aes(x=mass, y=ratio, color=species)) + geom_point() +
geom_text(aes(label=w(species)), size=2, hjust=1.3) +
scale_x_log10(breaks=c(10,25,50,100,200,500,1000)) + xlab(xl) + ylab(yl) +
scale_y_log10(breaks=c(.25,.5,.75,1,1.25,1.5,2)) +
theme(legend.position='none')
dd <- datadist(d); options(datadist='dd')
```
# Linear Regression in Log Brain Mass
Note that it is unusual not to log a ratio, but the preliminary analysis in ABD indicates that raw ratios will work (you may want to check this). The regression line is fit to non-human primates.
```{r fit}
f <- ols(ratio ~ log(mass), data=d, subset=species != 'homo sapiens')
f
ggplot(Predict(f, mass=seq(10, 1400, by=25)), ylab=yl) +
geom_point(aes(x=mass, y=ratio), data=d)
```
# Prediction of Glia-Neuron Ratio for Human Brain Mass
# Model Diagnostics
Insert your code and interpretations here.
# Computing Environment
```{r rsession,echo=FALSE}
si <- sessionInfo(); si$loadedOnly <- NULL
print(si, locale=FALSE)
```
```{r cite,results='asis',echo=FALSE}
print(citation(), style='text')
```