Skip to content

Commit

Permalink
Fix to ensure all mcmapply calls have mc.set.seed = FALSE
Browse files Browse the repository at this point in the history
  • Loading branch information
sgreenbury committed Jan 10, 2024
1 parent 77ab433 commit bc92494
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion scripts/data_prep/SPC_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ addToData2 <- function(data,region,coefFFT,coefFPT,coefMFT,coefMPT){
coefFPTR <- coefFPT[which(coefFFT$region == region),]
coefMFTR <- coefMFT[which(coefFFT$region == region),]
coefMPTR <- coefMPT[which(coefFFT$region == region),]
incs <- mcmapply(function(x){fillIncome2(x,old,pwkstat,coefFFTR,coefFPTR,coefMFTR,coefMPTR,region)}, 1:nrow(old), mc.cores = detectCores())
incs <- mcmapply(function(x){fillIncome2(x,old,pwkstat,coefFFTR,coefFPTR,coefMFTR,coefMPTR,region)}, 1:nrow(old), mc.cores = detectCores(), mc.set.seed = FALSE)
old$incomeH <- incs[1,]
old$incomeY <- incs[2,]
old$incomeHAsIf <- incs[3,]
Expand Down
8 changes: 4 additions & 4 deletions scripts/data_prep/SPC_pipelineLAD.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ merge$HOUSE_NCars <- merge$HOUSE_NCars - 1
merge <- merge[order(merge$MSOA11CD,merge$hid,-merge$age),]
rownames(merge) <- 1:nrow(merge)
msoas <- unique(merge$MSOA11CD)
merge$hid <- unname(unlist(mcmapply(function(x){addIdH(x,merge$MSOA11CD,merge$hid)}, msoas, mc.cores = cores)))
merge$hid <- unname(unlist(mcmapply(function(x){addIdH(x,merge$MSOA11CD,merge$hid)}, msoas, mc.cores = cores, mc.set.seed = FALSE)))
merge$pid <- addIdP(merge$hid)

# Transform ethnicity
Expand All @@ -61,7 +61,7 @@ age35gH <- age35g
if(countryR == "Wales"){
age35gH[age35gH > 19] <- 19
}
ind <- mcmapply(function(x){findHSEMatch(x,merge$sex,age35gH,HS)},1:nrow(merge), mc.cores = cores)
ind <- mcmapply(function(x){findHSEMatch(x,merge$sex,age35gH,HS)},1:nrow(merge), mc.cores = cores, mc.set.seed = FALSE)
merge$id_HS <- HS$id_HS[ind]
merge$HEALTH_diabetes <- HS$diabetes[ind]
merge$HEALTH_bloodpressure <- HS$bloodpressure[ind]
Expand All @@ -84,7 +84,7 @@ if(countryR == "England"){
coefM <- BMIdiff$ScotlandM
minBMI <- 14.71
}
merge$HEALTH_bmi <- mcmapply(function(x){applyBMI(x,merge,dMean,varData)}, 1:nrow(merge), mc.cores = cores)
merge$HEALTH_bmi <- mcmapply(function(x){applyBMI(x,merge,dMean,varData)}, 1:nrow(merge), mc.cores = cores, mc.set.seed = FALSE)
merge$HEALTH_bmi[which(merge$HEALTH_bmi < minBMI)] <- minBMI


Expand All @@ -108,7 +108,7 @@ if(countryR == "England" | countryR == "Wales"){


# Match with TUS
ind <- unlist(mcmapply(function(x){findTUSMatch(x,merge,indivTUS)}, 1:nrow(merge), mc.cores = cores))
ind <- unlist(mcmapply(function(x){findTUSMatch(x,merge,indivTUS)}, 1:nrow(merge), mc.cores = cores, mc.set.seed = FALSE))

merge$id_TUS_hh <- indivTUS$id_TUS[ind]
merge$id_TUS_p <- indivTUS$pnum[ind]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ rownames(merge) <- seq_len(nrow(merge))
msoas <- unique(merge$MSOA11CD)
merge$hid <- unname(unlist(mcmapply(function(x) {
addIdH(x, merge$MSOA11CD, merge$hid)
}, msoas, mc.cores = cores)))
}, msoas, mc.cores = cores, mc.set.seed = FALSE)))
merge$pid <- addIdP(merge$hid)

# Transform ethnicity
Expand Down

0 comments on commit bc92494

Please sign in to comment.