-
Notifications
You must be signed in to change notification settings - Fork 1
/
writeup-analyses.Rmd
50 lines (39 loc) · 1.36 KB
/
writeup-analyses.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
```{r}
source("lib/function_library.R", echo=F)
# Load other R source files in the lib directory.
load_all_code("lib")
# Load a bunch of required packages, installing missing ones as needed.
load_all_packages(auto_install = T)
# Set some standard settings.
conf = list(data_dir = "data", dir = ".")
```
Dataset
```{r}
load(paste0(conf$data_dir, "/create-dataset.RData"))
# Progression summary.
summary(dataset$outcomes$progression)
sd(dataset$outcomes$progression)
var(dataset$outcomes$progression)
qplot(dataset$outcomes$progression) + theme_bw() + ggtitle("Parkinson's disease progression") + xlab("Progression of UPDRS score: final - baseline") +
ylab("Count of subjects")
ggsave("visuals/progression-hist.png")
```
# Variable importance
# Prediction
```{r}
load(paste0(conf$data_dir, "/predict_results.RData"))
best_results = results[[length(results)]]
names(best_results)
qplot(best_results$SL.predict)
summary(best_results$SL.predict)
cor = cor(best_results$SL.predict, dataset$outcomes$progression)
cor^2
cor.test(best_results$SL.predict, dataset$outcomes$progression)
reg = lm(dataset$outcomes$progression ~ best_results$SL.predict)
summary(reg)
# Manual R^2.
# Doesn't give the same results as the regression. Formula wrong?
y_bar = mean(dataset$outcomes$progression)
r_sqr = sum((best_results$SL.predict - y_bar)^2) / sum((dataset$outcomes$progression - y_bar)^2)
r_sqr
```