setwd("BayesianiOLD")
#source(paste0(ddmore:::DDMORE.checkConfiguration(),"WinBUGS.R"))
source("D:\\Utenti\\ddmoreTEL\\ddmore-TEL.R\\ddmore.TEL\\R\\WinBUGS.R")
UC1<-"UseCase1.mdl"
UC1_1<-"UseCase1_1.mdl"
UC2<-"UseCase2.mdl"
UC2_1<-"UseCase2_1.mdl"
UC2_2<-"UseCase2_2.mdl"
UC3<-"UseCase3.mdl"
UC4<-"UseCase4.mdl"
UC4_1<-"UseCase4_1.mdl"
UC4_2<-"UseCase4_2.mdl"
UC4_3<-"UseCase4_3.mdl"
UC5<-"UseCase5.mdl"
UC5_1<-"UseCase5_1.mdl"
UC5_2<-"UseCase5_2.mdl"
UC6<-"UseCase6.mdl"
UC6_1<-"UseCase6_1.mdl"
UC6_2<-"UseCase6_2.mdl"
UC6_3<-"UseCase6_3.mdl"
UC7<-"UseCase7.mdl"
UC8<-"UseCase8.mdl"
UC9<-"UseCase9.mdl"
UC10<-"UseCase10.mdl"
UC10_1<-"UseCase10_1.mdl"
UC17<-"UseCase17.mdl"
test<-"InstallationTest_BUGS.mdl"
testCOMP<-"InstallationTest_COMPARTMENT_BUGS.mdl"
BUGSSO<-runWinBUGS(UC1, subfolder="WINBUGSUC1") # ok
BUGSSO<-runWinBUGS(UC2, subfolder="WINBUGSUC2") # ok
BUGSSO<-runWinBUGS(UC3, subfolder="WINBUGSUC3") # ok
BUGSSO<-runWinBUGS(UC4, subfolder="WINBUGSUC4") #dt bo
BUGSSO<-runWinBUGS(UC5, subfolder="WINBUGSUC5") # come 3 + mancano covariate sex e eta NON VA CONNETTORE TRAP 88
BUGSSO<-runWinBUGS(UC6, subfolder="WINBUGSUC6") #  OK ???
BUGSSO<-runWinBUGS(UC7, subfolder="WINBUGSUC7") # OK
BUGSSO<-runWinBUGS(UC9, subfolder="WINBUGSUC9")  # OK
BUGSSO<-runWinBUGS(UC10, subfolder="WINBUGSUC10") # OK??
BUGSSO<-runWinBUGS(UC17, subfolder="WINBUGSUC17") # ERRORE, non so se deve andare. FORSE cE 16?

setwd("Test")
BUGSSO<-runWinBUGS(test, subfolder="WINBUGSUCtest") #ok 
BUGSSO<-runWinBUGS(testCOMP, subfolder="WINBUGSUCtestCOMP") #ok TRAP20
setwd("..")

BUGSSO<-runWinBUGS(UC1_1, subfolder="WINBUGSUC1_1") #ok
BUGSSO<-runWinBUGS(UC2_1, subfolder="WINBUGSUC2_1") # DT
BUGSSO<-runWinBUGS(UC2_2, subfolder="WINBUGSUC2_2") # OK
BUGSSO<-runWinBUGS(UC4_1, subfolder="WINBUGSUC4_1") # OK but error real results
BUGSSO<-runWinBUGS(UC4_2, subfolder="WINBUGSUC4_2") # OK but error real results
BUGSSO<-runWinBUGS(UC4_3, subfolder="WINBUGSUC4_3") # OK but error real results
BUGSSO<-runWinBUGS(UC5_1, subfolder="WINBUGSUC5_1") # NON tetsato
BUGSSO<-runWinBUGS(UC5_2, subfolder="WINBUGSUC5_2") # NON tetstao
BUGSSO<-runWinBUGS(UC6_1, subfolder="WINBUGSUC6_1") # OK but real results
BUGSSO<-runWinBUGS(UC6_2, subfolder="WINBUGSUC6_2") # Non supportata MultivariateNormal1
BUGSSO<-runWinBUGS(UC6_3, subfolder="WINBUGSUC6_3") # MDL errato
BUGSSO<-runWinBUGS(UC10_1, subfolder="WINBUGSUC10_1") # ERRORE WT, poi ojk ma real results

# SIMEONI e SIMENONI POP
setwd("Test/Prova")
Simeoni<-"Simeoni_PAGE_Estimation_BUGS.mdl"
SimeoniPOP<-"Simeoni_PAGE_Estimation_POP_BUGS.mdl"
BUGSSO<-runWinBUGS(Simeoni, subfolder="WINBUGSSSIMEONI") # OK
BUGSSO<-runWinBUGS(SimeoniPOP, subfolder="WINBUGSSSIMEONIPOP") # OK 
setwd("../..")



setwd("Priors")
UC1PrUni<-"UseCase1_PRIOR_univariate.mdl"
UCex331<-"example331.mdl"
UCex3311<-"example3311.mdl"
UCex3312<-"example3312.mdl"
UCex332<-"example332.mdl"
UCex3321<-"example3321.mdl"
UCex334<-"example334.mdl"
UCex335<-"example335.mdl"
BUGSSO<-runWinBUGS(UC1PrUni, subfolder="WINBUGSUC1PrUni")
BUGSSO<-runWinBUGS(UCex331, subfolder="WINBUGSUCex331") # OK
BUGSSO<-runWinBUGS(UCex3311, subfolder="WINBUGSUCex3311") # OK 
BUGSSO<-runWinBUGS(UCex3312, subfolder="WINBUGSUCex3312") # non si capisce cosa vuole fare.
BUGSSO<-runWinBUGS(UCex332, subfolder="WINBUGSUCex332") # BUGS HTML
BUGSSO<-runWinBUGS(UCex3321, subfolder="WINBUGSUCex3321") #vuoto
BUGSSO<-runWinBUGS(UCex334, subfolder="WINBUGSUCex334")  # errore vettore media multivariata
BUGSSO<-runWinBUGS(UCex335, subfolder="WINBUGSUCex335") # errore vetttore

setwd("..")


getPopulationParameters(BUGSSO)$Bayesian
getPopulationParameters(BUGSSO, what="estimates")$Bayesian # o other options,  what= precisions, intervals, all
# it is possible also to omitt $Bayesian
getIndividualParameters(BUGSSO)
