From 0aeb3e5a13ea41162e992259504fafaa9b5c0250 Mon Sep 17 00:00:00 2001 From: Richard Li Date: Thu, 9 Nov 2023 10:22:20 -0800 Subject: [PATCH] replace T with TRUE to pass check --- R/smoothArea.R | 34 +++++++++++++++++----------------- R/smoothUnit.R | 18 +++++++++--------- man/compareEstimates.Rd | 4 ++-- man/mapEstimates.Rd | 4 ++-- man/smoothArea.Rd | 2 +- man/smoothUnit.Rd | 2 +- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/R/smoothArea.R b/R/smoothArea.R index eeb21b5..30facb2 100644 --- a/R/smoothArea.R +++ b/R/smoothArea.R @@ -34,7 +34,7 @@ #' data(DemoMap2) #' library(survey) #' des0 <- svydesign(ids = ~clustid+id, strata = ~strata, -#' weights = ~weights, data = DemoData2, nest = T) +#' weights = ~weights, data = DemoData2, nest = TRUE) #' Xmat <- aggregate(age~region, data = DemoData2, FUN = mean) #' #' # EXAMPLE 1: Continuous response model @@ -118,7 +118,7 @@ smoothArea <- function(formula, # known domain sizes if (!is.null(domain.size)) { direct.est <- - survey::svyby(resp.frm, domain, design = design, svytotal, na.rm = T) + survey::svyby(resp.frm, domain, design = design, svytotal, na.rm = TRUE) direct.est$domain.size <- domain.size[match(direct.est[, 1], domain.size[, 1]), 2] direct.est[, 2] = direct.est[, 2] / direct.est$domain.size @@ -126,7 +126,7 @@ smoothArea <- function(formula, direct.est <- direct.est[, 1:3] } else { direct.est <- - survey::svyby(resp.frm, domain, design = design, svymean, na.rm = T) + survey::svyby(resp.frm, domain, design = design, svymean, na.rm = TRUE) direct.est[, 3] <- direct.est[, 3] ^ 2 } } else { @@ -165,10 +165,10 @@ smoothArea <- function(formula, mod.X.domain <- X.domain mod.X.domain$domain <- X.domain[[domain.var]] mod.X.domain <- mod.X.domain[, names(mod.X.domain) != domain.var] - mod.dat <- merge(mod.dat, mod.X.domain, by = "domain", all.y = T) + mod.dat <- merge(mod.dat, mod.X.domain, by = "domain", all.y = TRUE) direct.est <- merge(direct.est, data.frame(domain = mod.X.domain$domain), - by = "domain", all.y = T) + by = "domain", all.y = TRUE) direct.est$method = "Direct" } else if(!is.null(adj.mat)) { if (any(is.na(match(mod.dat$domain, rownames(adj.mat))))) { @@ -180,10 +180,10 @@ smoothArea <- function(formula, } mod.dat <- merge(mod.dat, data.frame(domain = rownames(adj.mat)), - by = "domain", all.y = T) + by = "domain", all.y = TRUE) direct.est <- merge(direct.est, data.frame(domain = rownames(adj.mat)), - by = "domain", all.y = T) + by = "domain", all.y = TRUE) direct.est$method = "Direct" } mod.dat$domain.id <- 1:nrow(mod.dat) @@ -260,12 +260,12 @@ smoothArea <- function(formula, data.frame(domain = mod.dat$domain, mean = rowMeans(iid.model.mat), median = apply(iid.model.mat, 1, - function(x) median(x, na.rm = T)), + function(x) median(x, na.rm = TRUE)), var = apply(iid.model.mat, 1, var), lower = apply(iid.model.mat, 1, - function(x) quantile(x, (1-level)/2, na.rm = T)), + function(x) quantile(x, (1-level)/2, na.rm = TRUE)), upper = apply(iid.model.mat, 1, - function(x) quantile(x, 1-(1-level)/2, na.rm = T)), + function(x) quantile(x, 1-(1-level)/2, na.rm = TRUE)), method = paste0("Area level model: IID")) out$iid.model.est <- @@ -320,12 +320,12 @@ smoothArea <- function(formula, data.frame(domain = mod.dat$domain, mean = rowMeans(bym2.model.mat), median = apply(bym2.model.mat, 1, - function(x) median(x, na.rm = T)), + function(x) median(x, na.rm = TRUE)), var = apply(bym2.model.mat, 1, var), lower = apply(bym2.model.mat, 1, - function(x) quantile(x, (1-level)/2, na.rm = T)), + function(x) quantile(x, (1-level)/2, na.rm = TRUE)), upper = apply(bym2.model.mat, 1, - function(x) quantile(x, 1-(1-level)/2, na.rm = T)), + function(x) quantile(x, 1-(1-level)/2, na.rm = TRUE)), method = paste0("Area level model: BYM2")) out$bym2.model.est <- out$bym2.model.est[match(out$direct.est$domain, out$bym2.model.est$domain),] @@ -437,7 +437,7 @@ plot.svysae <- function(x, return_list = F, plot.factor = NULL, ...) { #' data(DemoMap2) #' library(survey) #' des0 <- svydesign(ids = ~clustid+id, strata = ~strata, -#' weights = ~weights, data = DemoData2, nest = T) +#' weights = ~weights, data = DemoData2, nest = TRUE) #' Xmat <- aggregate(age~region, data = DemoData2, FUN = mean) #' #' cts.res <- smoothArea(tobacco.use ~ 1, @@ -448,7 +448,7 @@ plot.svysae <- function(x, return_list = F, plot.factor = NULL, ...) { #' pc.alpha = 0.01, #' pc.u.phi = 0.5, #' pc.alpha.phi = 2/3, -#' return.samples = T) +#' return.samples = TRUE) #' compareEstimates(cts.res) #' } compareEstimates <- function(x, @@ -549,7 +549,7 @@ compareEstimates <- function(x, #' data(DemoMap2) #' library(survey) #' des0 <- svydesign(ids = ~clustid+id, strata = ~strata, -#' weights = ~weights, data = DemoData2, nest = T) +#' weights = ~weights, data = DemoData2, nest = TRUE) #' Xmat <- aggregate(age~region, data = DemoData2, FUN = mean) #' geo.data <- sf::st_as_sf(DemoMap2$geo) #' geo.data$domain <- geo.data$REGNAME @@ -561,7 +561,7 @@ compareEstimates <- function(x, #' pc.alpha = 0.01, #' pc.u.phi = 0.5, #' pc.alpha.phi = 2/3, -#' return.samples = T) +#' return.samples = TRUE) #' mapEstimates(cts.res, geo.data = geo.data, variable = "median") #' mapEstimates(cts.res, geo.data = geo.data, variable = "var") #' } diff --git a/R/smoothUnit.R b/R/smoothUnit.R index 962292b..1a091b0 100644 --- a/R/smoothUnit.R +++ b/R/smoothUnit.R @@ -29,7 +29,7 @@ #' data(DemoMap2) #' library(survey) #' des0 <- svydesign(ids = ~clustid+id, strata = ~strata, -#' weights = ~weights, data = DemoData2, nest = T) +#' weights = ~weights, data = DemoData2, nest = TRUE) #' #' # EXAMPLE 1: Continuous response model #' cts.res <- smoothUnit(formula = tobacco.use ~ 1, @@ -87,14 +87,14 @@ smoothUnit <- function(formula, # DIRECT ESTIMATES ----------------------------------------------------------- # compute direct estimates (Hajek estimates if domain size unknown) if (!is.null(domain.size)) { - direct.est <- svyby(resp.frm, domain, design = design, svytotal, na.rm = T) + direct.est <- svyby(resp.frm, domain, design = design, svytotal, na.rm = TRUE) direct.est$domain.size <- domain.size$size[match(direct.est[, 1], domain.size[[domain.var]])] direct.est[, 2] = direct.est[, 2] / direct.est$domain.size direct.est[, 3] = (direct.est[, 3] / direct.est$domain.size) ^ 2 direct.est <- direct.est[, 1:3] } else { - direct.est <- svyby(resp.frm, domain, design = design, svymean, na.rm = T) + direct.est <- svyby(resp.frm, domain, design = design, svymean, na.rm = TRUE) direct.est[, 3] <- direct.est[, 3] ^ 2 } rownames(direct.est) <- NULL @@ -125,7 +125,7 @@ smoothUnit <- function(formula, direct.est <- merge(direct.est, data.frame(domain = domain.table$domain), - by = "domain", all.y = T) + by = "domain", all.y = TRUE) direct.est$method = "Direct" out$direct.est <- direct.est @@ -181,8 +181,8 @@ smoothUnit <- function(formula, # fit model mod.frm <- as.formula(ftxt) fit <- INLA::inla(mod.frm, family = family, data = mod.dat, - control.compute = list(dic = T, mlik = T, - cpo = T, config = TRUE), + control.compute = list(dic = TRUE, mlik = TRUE, + cpo = TRUE, config = TRUE), control.predictor = list(compute = TRUE), lincomb = NULL, quantiles = c((1-level)/2, 0.5, 1-(1-level)/2)) @@ -218,12 +218,12 @@ smoothUnit <- function(formula, data.frame(domain = domain.table$domain, mean = rowMeans(est.mat), median = apply(est.mat, 1, - function(x) median(x, na.rm = T)), + function(x) median(x, na.rm = TRUE)), var = apply(est.mat, 1, var), lower = apply(est.mat, 1, - function(x) quantile(x, (1-level)/2, na.rm = T)), + function(x) quantile(x, (1-level)/2, na.rm = TRUE)), upper = apply(est.mat, 1, - function(x) quantile(x, 1-(1-level)/2, na.rm = T)), + function(x) quantile(x, 1-(1-level)/2, na.rm = TRUE)), method = paste0("Unit level model: ", ifelse(is.null(adj.mat), "IID", "BYM2"))) if (return.samples) { diff --git a/man/compareEstimates.Rd b/man/compareEstimates.Rd index 8cc800c..d3a2c71 100644 --- a/man/compareEstimates.Rd +++ b/man/compareEstimates.Rd @@ -23,7 +23,7 @@ data(DemoData2) data(DemoMap2) library(survey) des0 <- svydesign(ids = ~clustid+id, strata = ~strata, - weights = ~weights, data = DemoData2, nest = T) + weights = ~weights, data = DemoData2, nest = TRUE) Xmat <- aggregate(age~region, data = DemoData2, FUN = mean) cts.res <- smoothArea(tobacco.use ~ 1, @@ -34,7 +34,7 @@ cts.res <- smoothArea(tobacco.use ~ 1, pc.alpha = 0.01, pc.u.phi = 0.5, pc.alpha.phi = 2/3, - return.samples = T) + return.samples = TRUE) compareEstimates(cts.res) } } diff --git a/man/mapEstimates.Rd b/man/mapEstimates.Rd index 77bc4f5..4bdb3dc 100644 --- a/man/mapEstimates.Rd +++ b/man/mapEstimates.Rd @@ -27,7 +27,7 @@ data(DemoData2) data(DemoMap2) library(survey) des0 <- svydesign(ids = ~clustid+id, strata = ~strata, - weights = ~weights, data = DemoData2, nest = T) + weights = ~weights, data = DemoData2, nest = TRUE) Xmat <- aggregate(age~region, data = DemoData2, FUN = mean) geo.data <- sf::st_as_sf(DemoMap2$geo) geo.data$domain <- geo.data$REGNAME @@ -39,7 +39,7 @@ cts.res <- smoothArea(tobacco.use ~ 1, pc.alpha = 0.01, pc.u.phi = 0.5, pc.alpha.phi = 2/3, - return.samples = T) + return.samples = TRUE) mapEstimates(cts.res, geo.data = geo.data, variable = "median") mapEstimates(cts.res, geo.data = geo.data, variable = "var") } diff --git a/man/smoothArea.Rd b/man/smoothArea.Rd index 42bd35f..1672392 100644 --- a/man/smoothArea.Rd +++ b/man/smoothArea.Rd @@ -70,7 +70,7 @@ data(DemoData2) data(DemoMap2) library(survey) des0 <- svydesign(ids = ~clustid+id, strata = ~strata, - weights = ~weights, data = DemoData2, nest = T) + weights = ~weights, data = DemoData2, nest = TRUE) Xmat <- aggregate(age~region, data = DemoData2, FUN = mean) # EXAMPLE 1: Continuous response model diff --git a/man/smoothUnit.Rd b/man/smoothUnit.Rd index 14dd0e3..766019d 100644 --- a/man/smoothUnit.Rd +++ b/man/smoothUnit.Rd @@ -66,7 +66,7 @@ data(DemoData2) data(DemoMap2) library(survey) des0 <- svydesign(ids = ~clustid+id, strata = ~strata, - weights = ~weights, data = DemoData2, nest = T) + weights = ~weights, data = DemoData2, nest = TRUE) # EXAMPLE 1: Continuous response model cts.res <- smoothUnit(formula = tobacco.use ~ 1,