Skip to content

Commit

Permalink
reorders domains in areas
Browse files Browse the repository at this point in the history
  • Loading branch information
peteragao committed Feb 22, 2024
1 parent 2320013 commit 359f338
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion R/smoothArea.R
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ plot.svysae <- function(x, return_list = F, plot.factor = NULL, ...) {
split(combined_est, combined_est$plot),
function(x) {
ggplot2::ggplot(x, ggplot2::aes(x = domain, y = mean, color = method)) +
ggplot2::geom_point(position = position_dodge(width = 0.5)) +
ggplot2::geom_point(position = ggplot2::position_dodge(width = 0.5)) +
ggplot2::geom_linerange(ggplot2::aes(x = domain, ymin = lower, ymax = upper),
position = ggplot2::position_dodge(width = 0.5)) +
ggplot2::scale_color_discrete(name = "Method") +
Expand Down
5 changes: 2 additions & 3 deletions R/smoothUnit.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ smoothUnit <- function(formula,
ftxt <- paste("resp ~ 1")
if (length(all.vars(cov.frm)) > 0) {
ftxt <-
paste(ftxt, paste(all.vars(cov.frm), collapse = " + "), sep = " + ")
paste(ftxt, as.character(cov.frm)[-1], sep = " + ")
}

if (is.null(adj.mat)) {
Expand All @@ -177,7 +177,6 @@ smoothUnit <- function(formula,
model.method <- "bym2.model"
ftxt <- paste0(ftxt, " + f(domain.struct, model = 'bym2', graph=adj.mat, hyper = hyperpc.bym.int)")
}

# fit model
mod.frm <- as.formula(ftxt)
fit <- INLA::inla(mod.frm, family = family, data = mod.dat,
Expand All @@ -192,7 +191,7 @@ smoothUnit <- function(formula,

# identify indices of fixed effects and random effects
fe.idx <- grep(colnames(mm.pop)[1], rownames(samp.all[[1]]$latent))
fe.idx <- fe.idx:(fe.idx + length(all.vars(cov.frm)))
fe.idx <- fe.idx:(fe.idx + ncol(mm.pop) - 1)
re.idx <- grep("domain.struct", x = rownames(samp.all[[1]]$latent))

# aggregate sample predictions
Expand Down

0 comments on commit 359f338

Please sign in to comment.