Skip to content

Commit

Permalink
Replaced T/F with TRUE/FALSE
Browse files Browse the repository at this point in the history
  • Loading branch information
wleoncio committed Apr 25, 2024
1 parent 45a9a3b commit dc7815e
Show file tree
Hide file tree
Showing 26 changed files with 74 additions and 74 deletions.
2 changes: 1 addition & 1 deletion R/EMJMCMC2016-method-forecast.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ EMJMCMC2016$methods(
res <- 0
for (i in ids)
{
res <- res + statistics1[i, 15] * link.g(sum(statistics1[i, 16:nvars] * covariates, na.rm = T))
res <- res + statistics1[i, 15] * link.g(sum(statistics1[i, 16:nvars] * covariates, na.rm = TRUE))
}
return(list(forecast = res))
}
Expand Down
18 changes: 9 additions & 9 deletions R/EMJMCMC2016-method-modejumping_mcmc.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ EMJMCMC2016$methods(
to.del <- to.del[-sample(x = Nvars, size = sample(x = Nvars - 1, size = 1), prob = p.add + p.epsilon)]
}
if (length(to.del) < Nvars - Nvars.max) {
tdl.id <- order(p.add, decreasing = T)
tdl.id <- order(p.add, decreasing = TRUE)
to.del <- to.del[-tdl.id[1:Nvars.max]]
}
if (glob.model$print.freq > 0L) {
Expand Down Expand Up @@ -186,7 +186,7 @@ EMJMCMC2016$methods(

if (sjm + sjf + 1 <= max.tree.size) {
if (allow_offsprings == 1) {
if (!grepl(father, mother, fixed = T) && !grepl(mother, father, fixed = T)) {
if (!grepl(father, mother, fixed = TRUE) && !grepl(mother, father, fixed = TRUE)) {
proposal <- stri_paste(paste(ifelse(stats::runif(n = 1, min = 0, max = 1) < p.nor, "I((1-", "I(("), mother, sep = ""), paste(ifelse(stats::runif(n = 1, min = 0, max = 1) < p.nor, "(1-", "("), father, "))", sep = ""), sep = ifelse(stats::runif(n = 1, min = 0, max = 1) < p.and, ")&", ")|"))
} else {
if (max(sjm, sjf) > 1) {
Expand Down Expand Up @@ -288,7 +288,7 @@ EMJMCMC2016$methods(

# perform preliminary filtration here
if (Nvars > Nvars.max || j == mutation_rate) {
# pool.cor.prob = T
# pool.cor.prob = TRUE
# do the stuff here
if (j == mutation_rate) {
fparam.pool <<- unique(c(fparam.pool, filtered))
Expand All @@ -311,7 +311,7 @@ EMJMCMC2016$methods(
to.del <- to.del[-sample(x = Nvars, size = sample(x = Nvars - 1, size = 1), prob = p.add + p.epsilon)]
}
if (length(to.del) < Nvars - Nvars.max) {
tdl.id <- order(p.add, decreasing = T)
tdl.id <- order(p.add, decreasing = TRUE)
to.del <- to.del[-tdl.id[1:Nvars.max]]
}
if (glob.model$print.freq > 0L) {
Expand Down Expand Up @@ -688,7 +688,7 @@ EMJMCMC2016$methods(
to.del <- to.del[-sample(x = Nvars, size = sample(x = Nvars - 1, size = 1), prob = p.add + p.epsilon)]
}
if (length(to.del) < Nvars - Nvars.max) {
tdl.id <- order(p.add, decreasing = T)
tdl.id <- order(p.add, decreasing = TRUE)
to.del <- to.del[-tdl.id[1:Nvars.max]]
}
if (glob.model$print.freq > 0L) {
Expand Down Expand Up @@ -1410,7 +1410,7 @@ EMJMCMC2016$methods(
}

if (LocImprove == as.array(0)) {
thact <- sum(ratcand, -ratcur, -SA.forw$log.prob.cur, SA.forw$log.prob.fix, SA.back$log.prob.cur, -SA.back$log.prob.fix, na.rm = T)
thact <- sum(ratcand, -ratcur, -SA.forw$log.prob.cur, SA.forw$log.prob.fix, SA.back$log.prob.cur, -SA.back$log.prob.fix, na.rm = TRUE)
if (log(stats::runif(n = 1, min = 0, max = 1)) <= thact) {
ratcur <- ratcand
mlikcur <- ratcand
Expand Down Expand Up @@ -1439,7 +1439,7 @@ EMJMCMC2016$methods(
modglob <- SA.back$modglob
}
} else {
thact <- sum(ratcand, -ratcur, -SA.forw$log.prob.cur, SA.forw$log.prob.fix, vect[[mod_id]]$log.mod.switchback.prob, -vect[[mod_id]]$log.mod.switch.prob, na.rm = T)
thact <- sum(ratcand, -ratcur, -SA.forw$log.prob.cur, SA.forw$log.prob.fix, vect[[mod_id]]$log.mod.switchback.prob, -vect[[mod_id]]$log.mod.switch.prob, na.rm = TRUE)
if (log(stats::runif(n = 1, min = 0, max = 1)) <= thact) {
ratcur <- ratcand
mlikcur <- ratcand
Expand Down Expand Up @@ -1503,7 +1503,7 @@ EMJMCMC2016$methods(


# if(log(stats::runif(n = 1,min = 0,max = 1))<=(ratcand - ratcur - MTMCMC.forw$log.prob.cur + MTMCMC.forw$log.prob.fix + MTMCMC.back$log.prob.cur - MTMCMC.back$log.prob.fix))
thact <- sum(ratcand, -ratcur, -MTMCMC.forw$log.prob.cur, MTMCMC.forw$log.prob.fix, MTMCMC.back$log.prob.cur, -MTMCMC.back$log.prob.fix, na.rm = T)
thact <- sum(ratcand, -ratcur, -MTMCMC.forw$log.prob.cur, MTMCMC.forw$log.prob.fix, MTMCMC.back$log.prob.cur, -MTMCMC.back$log.prob.fix, na.rm = TRUE)
if (log(stats::runif(n = 1, min = 0, max = 1)) <= thact) {
ratcur <- ratcand
mlikcur <- ratcand
Expand Down Expand Up @@ -1588,7 +1588,7 @@ EMJMCMC2016$methods(


# if(log(stats::runif(n = 1,min = 0,max = 1))<=(ratcand - ratcur - GREEDY.forw$log.prob.cur + GREEDY.forw$log.prob.fix + GREEDY.back$log.prob.cur - GREEDY.back$log.prob.fix))
thact <- sum(ratcand, -ratcur, -GREEDY.forw$log.prob.cur, GREEDY.forw$log.prob.fix, GREEDY.back$log.prob.cur, -GREEDY.back$log.prob.fix, na.rm = T)
thact <- sum(ratcand, -ratcur, -GREEDY.forw$log.prob.cur, GREEDY.forw$log.prob.fix, GREEDY.back$log.prob.cur, -GREEDY.back$log.prob.fix, na.rm = TRUE)
if (log(stats::runif(n = 1, min = 0, max = 1)) <= thact) {
ratcur <- ratcand
mlikcur <- ratcand
Expand Down
4 changes: 2 additions & 2 deletions R/EMJMCMC2016-method-post_proceed_results.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ EMJMCMC2016$methods(
if (nconsum > 0) {
zyx[xyz] <- exp(statistics1[xyz, 1] - statistics1[moddee, 1]) / nconsum
} else {
nnnorm <- sum(statistics1[xyz, 4], na.rm = T)
nnnorm <- sum(statistics1[xyz, 4], na.rm = TRUE)
if (nnnorm == 0) {
nnnorm <- 1
}
Expand All @@ -28,7 +28,7 @@ EMJMCMC2016$methods(
p.post <- (p.post + varcur * statistics1[i, 15])
}

if (!exists("p.post") || is.null(p.post) || sum(p.post, na.rm = T) == 0 || sum(p.post, na.rm = T) > Nvars) {
if (!exists("p.post") || is.null(p.post) || sum(p.post, na.rm = TRUE) == 0 || sum(p.post, na.rm = TRUE) > Nvars) {
p.post <- array(data = 0.5, dim = Nvars)
}

Expand Down
2 changes: 1 addition & 1 deletion R/EMJMCMC2016-method-post_proceed_results_hash.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ EMJMCMC2016$methods(
p.post <- (p.post + varcur * zyx[i])
}

if (!exists("p.post") || is.null(p.post) || sum(p.post, na.rm = T) == 0 || sum(p.post, na.rm = T) > Nvars) {
if (!exists("p.post") || is.null(p.post) || sum(p.post, na.rm = TRUE) == 0 || sum(p.post, na.rm = TRUE) > Nvars) {
p.post <- array(data = 0.5, dim = Nvars)
}
# hash::values(hashStat)[which((1:(lHash * linx)) %%linx == 4)]<-zyx
Expand Down
2 changes: 1 addition & 1 deletion R/estimate.bigm.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
estimate.bigm <- function(formula, data, family, prior, n, maxit = 2, chunksize = 1000000) # nice behaviour
{
out <- biglm::bigglm(
data = data, family = family, formula = formula, sandwich = F,
data = data, family = family, formula = formula, sandwich = FALSE,
maxit = maxit, chunksize = chunksize
)
if (prior == "AIC") {
Expand Down
4 changes: 2 additions & 2 deletions R/estimate.gamma.cpen.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ estimate.gamma.cpen <- function(formula, data, r = 1.0 / 1000.0, logn = log(1000
fobserved <- fmla.proc[1]
fmla.proc[2] <- stringi::stri_replace_all(str = fmla.proc[2], fixed = " ", replacement = "")
fmla.proc[2] <- stringi::stri_replace_all(str = fmla.proc[2], fixed = "\n", replacement = "")
fparam <- stringi::stri_split_fixed(str = fmla.proc[2], pattern = "+I", omit_empty = F)[[1]]
fparam <- stringi::stri_split_fixed(str = fmla.proc[2], pattern = "+I", omit_empty = FALSE)[[1]]
sj <- (stringi::stri_count_fixed(str = fparam, pattern = "*"))
sj <- sj + (stringi::stri_count_fixed(str = fparam, pattern = "+"))
for (rel in relat) {
Expand Down Expand Up @@ -48,7 +48,7 @@ estimate.gamma.cpen_2 = function(formula, data,r = 1.0/223.0,logn=log(223.0),rel
fobserved = fmla.proc[1]
fmla.proc[2]=stri_replace_all(str = fmla.proc[2],fixed = " ",replacement = "")
fmla.proc[2]=stri_replace_all(str = fmla.proc[2],fixed = "\n",replacement = "")
fparam =stri_split_fixed(str = fmla.proc[2],pattern = "+I",omit_empty = F)[[1]]
fparam =stri_split_fixed(str = fmla.proc[2],pattern = "+I",omit_empty = FALSE)[[1]]
sj=(stri_count_fixed(str = fparam, pattern = "*"))
sj=sj+(stri_count_fixed(str = fparam, pattern = "+"))
for(rel in relat)
Expand Down
2 changes: 1 addition & 1 deletion R/estimate.logic.bern.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ estimate.logic.bern = function(formula, data, family = stats::binomial(), n=1000
fobserved = fmla.proc[1]
fmla.proc[2]=stringi::stri_replace_all(str = fmla.proc[2],fixed = " ",replacement = "")
fmla.proc[2]=stringi::stri_replace_all(str = fmla.proc[2],fixed = "\n",replacement = "")
fparam =stringi::stri_split_fixed(str = fmla.proc[2],pattern = "+",omit_empty = F)[[1]]
fparam =stringi::stri_split_fixed(str = fmla.proc[2],pattern = "+",omit_empty = FALSE)[[1]]
sj=(stringi::stri_count_fixed(str = fparam, pattern = "&"))
sj=sj+(stringi::stri_count_fixed(str = fparam, pattern = "|"))
sj=sj+1
Expand Down
4 changes: 2 additions & 2 deletions R/estimate.logic.bern.tCCH.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ estimate.logic.bern.tCCH = function(formula = NULL,y.id = 51, data, n=1000, m=50
#define the function estimating parameters of a given Bernoulli logic regression with robust g prior
if(is.null(formula))
return(list(mlik = -10000 + stats::rnorm(1,0,1),waic =10000 , dic = 10000,summary.fixed =list(mean = 1)))
X = scale(stats::model.matrix(object = formula,data = data),center = T,scale = F)
X = scale(stats::model.matrix(object = formula,data = data),center = TRUE,scale = FALSE)
X[,1] = 1
fmla.proc=as.character(formula)[2:3]
out = stats::glm(formula = stats::as.formula(paste0(fmla.proc[1],"~X+0")),data=data,family = stats::binomial())
Expand All @@ -21,7 +21,7 @@ estimate.logic.bern.tCCH = function(formula = NULL,y.id = 51, data, n=1000, m=50

fmla.proc[2]=stringi::stri_replace_all(str = fmla.proc[2],fixed = " ",replacement = "")
fmla.proc[2]=stringi::stri_replace_all(str = fmla.proc[2],fixed = "\n",replacement = "")
fparam =stringi::stri_split_fixed(str = fmla.proc[2],pattern = "+",omit_empty = F)[[1]]
fparam =stringi::stri_split_fixed(str = fmla.proc[2],pattern = "+",omit_empty = FALSE)[[1]]
sj=(stringi::stri_count_fixed(str = fparam, pattern = "&"))
sj=sj+(stringi::stri_count_fixed(str = fparam, pattern = "|"))
sj=sj+1
Expand Down
2 changes: 1 addition & 1 deletion R/estimate.logic.glm.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fmla.proc<-as.character(formula)[2:3]
fobserved <- fmla.proc[1]
fmla.proc[2]<-stringi::stri_replace_all(str = fmla.proc[2],fixed = " ",replacement = "")
fmla.proc[2]<-stringi::stri_replace_all(str = fmla.proc[2],fixed = "\n",replacement = "")
fparam <-stringi::stri_split_fixed(str = fmla.proc[2],pattern = "+",omit_empty = F)[[1]]
fparam <-stringi::stri_split_fixed(str = fmla.proc[2],pattern = "+",omit_empty = FALSE)[[1]]
sj<-(stringi::stri_count_fixed(str = fparam, pattern = "&"))
sj<-sj+(stringi::stri_count_fixed(str = fparam, pattern = "|"))
sj<-sj+1
Expand Down
2 changes: 1 addition & 1 deletion R/estimate.logic.lm.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fmla.proc<-as.character(formula)[2:3]
fobserved <- fmla.proc[1]
fmla.proc[2]<-stringi::stri_replace_all(str = fmla.proc[2],fixed = " ",replacement = "")
fmla.proc[2]<-stringi::stri_replace_all(str = fmla.proc[2],fixed = "\n",replacement = "")
fparam <-stringi::stri_split_fixed(str = fmla.proc[2],pattern = "+",omit_empty = F)[[1]]
fparam <-stringi::stri_split_fixed(str = fmla.proc[2],pattern = "+",omit_empty = FALSE)[[1]]
sj<-(stringi::stri_count_fixed(str = fparam, pattern = "&"))
sj<-sj+(stringi::stri_count_fixed(str = fparam, pattern = "|"))
sj<-sj+1
Expand Down
2 changes: 1 addition & 1 deletion R/estimate.logic.lm.jef.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ estimate.logic.lm.jef = function(formula= NULL, data, n, m, r = 1,k.max=21)
fobserved = fmla.proc[1]
fmla.proc[2]=stringi::stri_replace_all(str = fmla.proc[2],fixed = " ",replacement = "")
fmla.proc[2]=stringi::stri_replace_all(str = fmla.proc[2],fixed = "\n",replacement = "")
fparam =stringi::stri_split_fixed(str = fmla.proc[2],pattern = "+",omit_empty = F)[[1]]
fparam =stringi::stri_split_fixed(str = fmla.proc[2],pattern = "+",omit_empty = FALSE)[[1]]
sj=(stringi::stri_count_fixed(str = fparam, pattern = "&"))
sj=sj+(stringi::stri_count_fixed(str = fparam, pattern = "|"))
sj=sj+1
Expand Down
4 changes: 2 additions & 2 deletions R/estimate.logic.lm.tCCH.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ estimate.logic.lm.tCCH = function(formula = NULL, data, n=1000, m=50, r = 1, p.a
}
fmla.proc[2]=stringi::stri_replace_all(str = fmla.proc[2],fixed = " ",replacement = "")
fmla.proc[2]=stringi::stri_replace_all(str = fmla.proc[2],fixed = "\n",replacement = "")
fparam =stringi::stri_split_fixed(str = fmla.proc[2],pattern = "+",omit_empty = F)[[1]]
fparam =stringi::stri_split_fixed(str = fmla.proc[2],pattern = "+",omit_empty = FALSE)[[1]]
sj=(stringi::stri_count_fixed(str = fparam, pattern = "&"))
sj=sj+(stringi::stri_count_fixed(str = fparam, pattern = "|"))
sj=sj+1
Jprior = prod(truncfactorial(sj)/((m^sj)*2^(2*sj-2)))
p.v = (n+1)/(p+1)
R.2 = summary(out)$r.squared

mlik = (-0.5*p*log(p.v) -0.5*(n-1)*log(1-(1-1/p.v)*R.2) + log(beta((p.a+p)/2,p.b/2)) - log(beta(p.a/2,p.b/2)) + log(BAS::phi1(p.b/2,(n-1)/2,(p.a+p.b+p)/2,p.s/2/p.v,R.2/(p.v-(p.v-1)*R.2))) - BAS::hypergeometric1F1(p.b/2,(p.a+p.b)/2,p.s/2/p.v,log = T)+log(Jprior) + p*log(r)+n)
mlik = (-0.5*p*log(p.v) -0.5*(n-1)*log(1-(1-1/p.v)*R.2) + log(beta((p.a+p)/2,p.b/2)) - log(beta(p.a/2,p.b/2)) + log(BAS::phi1(p.b/2,(n-1)/2,(p.a+p.b+p)/2,p.s/2/p.v,R.2/(p.v-(p.v-1)*R.2))) - BAS::hypergeometric1F1(p.b/2,(p.a+p.b)/2,p.s/2/p.v,log = TRUE)+log(Jprior) + p*log(r)+n)
if(mlik==-Inf||is.na(mlik)||is.nan(mlik))
mlik = -10000
return(list(mlik = mlik,waic = stats::AIC(out)-n , dic = stats::BIC(out)-n,summary.fixed =list(mean = stats::coef(out))))
Expand Down
2 changes: 1 addition & 1 deletion R/estimate.speedglm.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ estimate.speedglm <- function(formula, data, family, prior, logn) # weird behavi
{
# use dic and aic as bic and aic correspondingly
X <- stats::model.matrix(object = formula,data = data)
out <- speedglm::speedglm.wfit(y = data[,1], X = X, intercept=FALSE, family=family,eigendec = T, method = "Cholesky")
out <- speedglm::speedglm.wfit(y = data[,1], X = X, intercept=FALSE, family=family,eigendec = TRUE, method = "Cholesky")
if(prior == "AIC")
return(list(mlik = -out$aic ,waic = -(out$deviance + 2*out$rank) , dic = -(out$RSS),summary.fixed =list(mean = out$coefficients)))
if(prior=="BIC")
Expand Down
4 changes: 2 additions & 2 deletions R/mcgmj.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file hosts small, internal functions that are used as auxiliary to other,
# user-level functions.

mcgmjpar = function(X,FUN,mc.cores) parallel::mclapply(X= X,FUN = FUN,mc.preschedule = T,mc.cores = mc.cores)
mcgmjpar = function(X,FUN,mc.cores) parallel::mclapply(X= X,FUN = FUN,mc.preschedule = TRUE,mc.cores = mc.cores)

mcgmjpse = function(X,FUN,mc.cores) if(.Platform[[1]]=="unix" & length(mc.cores)>0 & mc.cores >=2) parallel::mclapply(X= X,FUN = FUN,mc.preschedule = T,mc.cores = mc.cores) else lapply(X,FUN)
mcgmjpse = function(X,FUN,mc.cores) if(.Platform[[1]]=="unix" & length(mc.cores)>0 & mc.cores >=2) parallel::mclapply(X= X,FUN = FUN,mc.preschedule = TRUE,mc.cores = mc.cores) else lapply(X,FUN)
4 changes: 2 additions & 2 deletions R/parall.gmj.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ set.seed(as.integer(vect$cpu))
do.call(runemjmcmc, vect[1:vect$simlen])
vals<-hash::values(hashStat)
fparam<-mySearch$fparam
cterm<-max(vals[1,],na.rm = T)
cterm<-max(vals[1,],na.rm = TRUE)
ppp<-mySearch$post_proceed_results_hash(hashStat = hashStat)
post.populi<-sum(exp(hash::values(hashStat)[1,][1:vect$NM]-cterm),na.rm = T)
post.populi<-sum(exp(hash::values(hashStat)[1,][1:vect$NM]-cterm),na.rm = TRUE)
hash::clear(hashStat)
rm(vals)
return(list(post.populi = post.populi, p.post = ppp$p.post, cterm = cterm, fparam = fparam))
Expand Down
2 changes: 1 addition & 1 deletion R/pinferunemjmcmc.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pinferunemjmcmc = function(

if(predict)
{
runemjmcmc.params$save.beta = T
runemjmcmc.params$save.beta = TRUE

if(length(test.data)==0)
{
Expand Down
Loading

0 comments on commit dc7815e

Please sign in to comment.