From bcf6f69da824c57f931c1740d4f7cb85fdccad69 Mon Sep 17 00:00:00 2001 From: rolandproducts Date: Wed, 18 Sep 2019 15:31:01 +1000 Subject: [PATCH 1/2] Update intsvy.reg.pv.R --- R/intsvy.reg.pv.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/R/intsvy.reg.pv.R b/R/intsvy.reg.pv.R index c3f9ad6..c29df09 100644 --- a/R/intsvy.reg.pv.R +++ b/R/intsvy.reg.pv.R @@ -48,7 +48,13 @@ intsvy.reg.pv <- stat.tot <- apply(coe.tot, 1, mean) # Sampling error (variance within) - var.w <- apply(0.05*sapply(lapply(1:config$parameters$PVreps, function(pv) + if(length(config$parameters$BRRreps == 1) & is.numeric(config$parameters$BRRreps)){ + cc<- 1/(config$parameters$BRRreps*(1-0.5)^2) + } else { + cc<- 1/20 + warning("default value for BRR reps (80) used, set this in your config") + } + var.w <- apply(cc*sapply(lapply(1:config$parameters$PVreps, function(pv) (coe.rep[[pv]]-coe.tot[,pv])^2), function(e) apply(e, 1, sum)), 1, mean) # Imputation error (variance between) From 06a6ed39577d6f9db67d401002f1eb9b28dc084f Mon Sep 17 00:00:00 2001 From: rolandproducts Date: Wed, 18 Sep 2019 15:40:38 +1000 Subject: [PATCH 2/2] Update intsvy.mean.pv.R generalise to use BRRreps --- R/intsvy.mean.pv.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/R/intsvy.mean.pv.R b/R/intsvy.mean.pv.R index a167533..7f98957 100644 --- a/R/intsvy.mean.pv.R +++ b/R/intsvy.mean.pv.R @@ -36,7 +36,12 @@ function(pvnames, by, data, export=FALSE, name= "output", folder=getwd(), config MEAN.m <- mean(PV.mean) SD.m <- mean(PV.sd) - cc = 1/20 + if(length(config$parameters$BRRreps == 1) & is.numeric(config$parameters$BRRreps)){ + cc<- 1/(config$parameters$BRRreps*(1-0.5)^2) + } else { + cc<- 1/20 + warning("default value for BRR reps (80) used, set this in your config") + } if (config$parameters$weights == "mixed_piaac") { cntName <- as.character(unique(data[,config$variables$countryID]))[1] cc <- piaacReplicationScheme[cntName,"c"]