-
Notifications
You must be signed in to change notification settings - Fork 0
/
show_models_fit.R
60 lines (56 loc) · 1.99 KB
/
show_models_fit.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# TODO: Implement pseudoR2 for poissonModel = TRUE
# TODO: print results in consol
show_models_fit <- function(modelDir, samples, thin, nChains, panelsDir, poissonModel = FALSE) {
#filenameout = paste("modelFit_thin_", as.character(thin),
# "_samples_", as.character(samples),
# "_chains_",as.character(nChains),
# ".pdf",sep = "")
#filenameout = file.path(panelsDir, filenameout)
#if (file.exists(filenameout)) {
# print(paste("File already exists -- Skipping:", filenameout))
#
#} else {
filename = paste("MF_thin_", as.character(thin),
"_samples_", as.character(samples),
"_chains_",as.character(nChains),
".Rdata",sep = "")
filename = file.path(modelDir, filename)
load(filename)
nm = length(MF)
#pdf(file = filenameout)
for(j in 1:nm){
cMF = MF[[j]]
cMFCV = MFCV[[j]]
if(!is.null(cMF$TjurR2)){
plot(cMF$TjurR2,cMFCV$TjurR2,xlim=c(-1,1),ylim=c(-1,1),
xlab = "explanatory power",
ylab = "predictive power",
main=paste0(modelnames[[j]],", thin = ",as.character(thin),", samples = ",as.character(samples),": Tjur R2"))
abline(0,1)
abline(v=0)
abline(h=0)
}
if(!is.null(cMF$R2)){
plot(cMF$R2,cMFCV$R2,xlim=c(-1,1),ylim=c(-1,1),
xlab = "explanatory power",
ylab = "predictive power",
main=paste0(modelnames[[j]],", thin = ",as.character(thin),", samples = ",as.character(samples),": R2"))
abline(0,1)
abline(v=0)
abline(h=0)
}
if(!is.null(cMF$AUC)){
print(mean(cMF$AUC))
print(mean(cMFCV$AUC))
plot(cMF$AUC,cMFCV$AUC,xlim=c(0,1),ylim=c(0,1),
xlab = "explanatory power",
ylab = "predictive power",
main=paste0(modelnames[[j]],", thin = ",as.character(thin),", samples = ",as.character(samples),": AUC"))
abline(0,1)
abline(v=0.5)
abline(h=0.5)
}
}
#dev.off()
#}
}