-
Notifications
You must be signed in to change notification settings - Fork 0
/
XX.mixed_effects.R
39 lines (32 loc) · 1.13 KB
/
XX.mixed_effects.R
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
library(lme4)
library(magrittr)
library(dplyr)
source("00_Functions.R")
library(patchwork)
datasets <- c("data_dbscan",'data_test')
datasets %>%
sapply(function(i){
assign(x = i,
value = read.table(paste0("data/",i,".tsv"), header = T , sep = "\t",
na.strings = c(""," ","NA","88","99",
"99.99","777.77","999",
"77.77","77.7","77")),
envir = .GlobalEnv)
}) %>% invisible()
lmer( ga ~ I(crl) + I(crl^2) + (1|enrid), data = data_dbscan)
model_lmer <- function(crl){
6.2679 + crl * 1.53902 - 0.07713 * crl^2
}
pl_data <- data_test %>% transmute(ga, crl) %>%
mutate(garbhini = predict_ga(crl,method = 'Garbhini1') - ga,
mixed_effects = model_lmer(crl) - ga)
p1 <- pl_data %>%
ggplot()+
geom_density(aes(x = garbhini, color = 'Garbhini')) +
geom_density(aes(x = mixed_effects, color = 'lmer')) +
theme_bw()
p2 <- pl_data %>%
ggplot(aes(x = crl))+
geom_point(aes(y = garbhini, color = 'Garbhini')) +
geom_point(aes(y = mixed_effects, color = 'lmer')) +
theme_bw()