From e42355c9489db2435eba600dda49553dc93a2acc Mon Sep 17 00:00:00 2001
From: Patric Wyss <patric.wyss@upd.unibe.ch>
Date: Tue, 2 Nov 2021 19:09:02 +0000
Subject: [PATCH] Remove reference to global training variable

---
 R/POSEIDON.R | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/R/POSEIDON.R b/R/POSEIDON.R
index 600fe95..87663d5 100644
--- a/R/POSEIDON.R
+++ b/R/POSEIDON.R
@@ -63,16 +63,16 @@ daLmeMulti<- function(resp, variable, diagnosis, predFix, predRand, clust, metho
   }
   
   # 4) fit linear mixed-effects model
-  model = nlme::lme(formulaFix, data = data,
-              random = formulaRand,
-              weights = weightsLmer,
-              control = lmeControl(returnObject=F, natural=F,
-                                   maxIter=maxIter, msMaxIter=msMaxIter,
-                                   niterEM=niterEM, msMaxEval=msMaxEval,
-                                   optimMethod=optimMethod))
+  model<- nlme::lme(formulaFix, data = data,
+                    random = formulaRand,
+                    weights = weightsLmer,
+                    control = lmeControl(returnObject=F, natural=F,
+                                         maxIter=maxIter, msMaxIter=msMaxIter,
+                                         niterEM=niterEM, msMaxEval=msMaxEval,
+                                         optimMethod=optimMethod))
   
   # 5) Compute relative frequencies of diagnoses in trainin set
-  dataTrainNoDup<- dataTrain[duplicated(dataTrain[[clust]])==F, ]
+  dataTrainNoDup<- data[duplicated(data[[clust]])==F, ]
   relFreq<- table(dataTrainNoDup[[diagnosis]])/sum(table(dataTrainNoDup[[diagnosis]]))
   diagLabels<- names(relFreq)
   prior<- relFreq[[2]]
@@ -116,10 +116,6 @@ predDistParamLme<- function(model, dataSub){
   ## (for multivariate models fitted by fitLmeMulti only)
   varName<- model$input$variable
   
-  ## Extract training data and estimate priors
-  dataTrain<- model$input$dTrain
-  dataTrain<- dataTrain[duplicated(dataTrain[[nameSubId]])==F, ]
-  
   ## Extract prior
   priorD1<- model$input$prior
   
-- 
GitLab