femininity <- mutate_branch(
1 * (MasFem > 6), 1 * (MasFem > mean(MasFem))
)
y <- mutate_branch(log(alldeaths + 1), alldeaths)
intensity <- mutate_branch(
Minpressure_Updated_2014,
Category,
NDAM,
HighestWindSpeed
)
model <- formula_branch(
y ~ femininity,
y ~ femininity * intensity
)
family <- family_branch(
gaussian, poisson
)
match_poisson <- branch_condition(alldeaths, poisson)
match_gaussian <- branch_condition(log(alldeaths + 1), gaussian)
stable <- mverse(hurricane) %>%
add_mutate_branch(y, femininity, intensity) %>%
add_formula_branch(model) %>%
add_family_branch(family) %>%
add_branch_condition(match_poisson, match_gaussian) %>%
glm_mverse() %>%
spec_summary("femininity")
# default behaviour
spec_curve(stable)
# coloring and sorting based on other variable
stable %>%
dplyr::mutate(colour_by = y_branch) %>%
spec_curve(order_by = c("estimate", "colour_by"), colour_by = "colour_by")
# Because the output is a \code{ggplot} object, you can
# further modify the asethetics of the specification curve
# using \code{ggplot2::theme()} and the specication matrix
# using \code{ggupset::theme_combmatrix()}
spec_curve(stable) +
ggplot2::labs(y = "Estimates", colour = "Significant at 0.05 level",
title = "Specification curve of femininity") +
ggplot2::theme(legend.position = "bottom") +
ggupset::theme_combmatrix(
combmatrix.label.width = ggplot2::unit(c(25, 100, 0, 0), "pt")
)
Run the code above in your browser using DataLab