From c34c5bd800abed725aec45d69081708ed84058ea Mon Sep 17 00:00:00 2001 From: Constantin Goeldel Date: Wed, 4 Jan 2023 18:42:15 +0100 Subject: [PATCH 1/4] remove duplicate computation of divergence function --- R/ABneutral.R | 5 +++-- R/BOOTmodel.R | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/R/ABneutral.R b/R/ABneutral.R index 96eac9a..dc5f925 100644 --- a/R/ABneutral.R +++ b/R/ABneutral.R @@ -105,8 +105,9 @@ ABneutral<-function(pedigree.data, p0uu, eqp, eqp.weight, Nstarts, out.dir, out. LSE_intercept<-function(param_int) { - sum((pedigree[,4] - param_int[4] - divergence(pedigree, p0mm, p0um, p0uu, param_int[1:3])[[2]])^2) + - eqp.weight*nrow(pedigree)*((divergence(pedigree, p0mm, p0um, p0uu, param_int[1:3])[[1]]- eqp)^2) + d = divergence(pedigree, p0mm, p0um, p0uu, param_int[1:3]) + sum((pedigree[,4] - param_int[4] - d[[2]])^2) + + eqp.weight*nrow(pedigree)*((d[[1]]- eqp)^2) } diff --git a/R/BOOTmodel.R b/R/BOOTmodel.R index 0d2445d..81a8f3b 100644 --- a/R/BOOTmodel.R +++ b/R/BOOTmodel.R @@ -130,8 +130,9 @@ BOOTmodel<-function(pedigree.data, Nboot, out.dir, out.name) ## Defining the Least Square function to be minimized LSE_intercept<-function(param_int) { - sum((pedigree[,4] - param_int[5] - divergence(pedigree, p0mm, p0um, p0uu, param_int[1:4])[[2]])^2) + - eqp.weight*nrow(pedigree)*((divergence(pedigree, p0mm, p0um, p0uu, param_int[1:4])[[1]]- eqp)^2) + d = divergence(pedigree, p0mm, p0um, p0uu, param_int[1:4]) + sum((pedigree[,4] - param_int[5] - d[[2]])^2) + + eqp.weight*nrow(pedigree)*((d[[1]]- eqp)^2) } From 5eafa0c9a18eb82841b7a0ad2bd2fda09a3b5b89 Mon Sep 17 00:00:00 2001 From: Constantin Goeldel Date: Wed, 4 Jan 2023 19:45:35 +0100 Subject: [PATCH 2/4] edited the wrong Boot Model --- R/BOOTmodel.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/BOOTmodel.R b/R/BOOTmodel.R index 81a8f3b..6685db5 100644 --- a/R/BOOTmodel.R +++ b/R/BOOTmodel.R @@ -131,8 +131,8 @@ BOOTmodel<-function(pedigree.data, Nboot, out.dir, out.name) LSE_intercept<-function(param_int) { d = divergence(pedigree, p0mm, p0um, p0uu, param_int[1:4]) - sum((pedigree[,4] - param_int[5] - d[[2]])^2) + - eqp.weight*nrow(pedigree)*((d[[1]]- eqp)^2) + sum((pedigree[,4] - param_int[5] - divergence(pedigree, p0mm, p0um, p0uu, param_int[1:4])[[2]])^2) + + eqp.weight*nrow(pedigree)*((divergence(pedigree, p0mm, p0um, p0uu, param_int[1:4])[[1]]- eqp)^2) } @@ -159,7 +159,7 @@ BOOTmodel<-function(pedigree.data, Nboot, out.dir, out.name) counter<-counter+1 - message("Bootstrap interation: ", counter/Nboot, "\n") + message("Bootstrap interationsssss: ", counter/Nboot, "\n") opt.out <- suppressWarnings(optimx(par = param_int0, fn = LSE_intercept, method=optim.method)) alphafinal<-as.numeric(opt.out[1]) From d42b3ce25b3ea04e5b03dc607dd11a8d9d9e29d7 Mon Sep 17 00:00:00 2001 From: Constantin Goeldel Date: Wed, 4 Jan 2023 20:17:42 +0100 Subject: [PATCH 3/4] speed up Boot --- R/BOOTmodel.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/R/BOOTmodel.R b/R/BOOTmodel.R index 6685db5..e93e817 100644 --- a/R/BOOTmodel.R +++ b/R/BOOTmodel.R @@ -1001,8 +1001,9 @@ BOOTmodel<-function(pedigree.data, Nboot, out.dir, out.name) LSE_intercept<-function(param_int) { - sum((pedigree[,4] - param_int[4] - divergence(pedigree, p0mm, p0um, p0uu, param_int[1:3])[[2]])^2) + - eqp.weight*nrow(pedigree)*((divergence(pedigree, p0mm, p0um, p0uu, param_int[1:3])[[1]]- eqp)^2) + d = divergence(pedigree, p0mm, p0um, p0uu, param_int[1:3]) + sum((pedigree[,4] - param_int[4] - d[[2]])^2) + + eqp.weight*nrow(pedigree)*((d[[1]]- eqp)^2) } @@ -1029,7 +1030,7 @@ BOOTmodel<-function(pedigree.data, Nboot, out.dir, out.name) counter<-counter+1 - message("Bootstrap interation: ", counter/Nboot, "\n") + message("Bootstrap interationssss: ", counter/Nboot, "\n") opt.out <- suppressWarnings(optimx(par = param_int0, fn = LSE_intercept, method=optim.method)) From 150a3eea706566ce6c1b385b5561256044a5c7d5 Mon Sep 17 00:00:00 2001 From: Constantin Goeldel Date: Wed, 4 Jan 2023 20:54:43 +0100 Subject: [PATCH 4/4] remove indication --- R/BOOTmodel.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/BOOTmodel.R b/R/BOOTmodel.R index e93e817..5363e2f 100644 --- a/R/BOOTmodel.R +++ b/R/BOOTmodel.R @@ -1030,7 +1030,7 @@ BOOTmodel<-function(pedigree.data, Nboot, out.dir, out.name) counter<-counter+1 - message("Bootstrap interationssss: ", counter/Nboot, "\n") + message("Bootstrap iterations: ", counter/Nboot, "\n") opt.out <- suppressWarnings(optimx(par = param_int0, fn = LSE_intercept, method=optim.method))