format_vcd: format-p-values-vcd

format_vcdR Documentation

format-p-values-vcd

Description

How to format p-values in an association plot made with "vcd"?

Usage

legend_resbased2(
  fontsize = 12,
  fontfamily = "",
  x = unit(1, "lines"),
  y = unit(0.1, "npc"),
  height = unit(0.8, "npc"),
  width = unit(0.7, "lines"),
  digits = 2,
  check_overlap = TRUE,
  text = NULL,
  steps = 200,
  ticks = 10,
  pvalue = TRUE,
  range = NULL
)

shading_hcl2(
  observed,
  residuals = NULL,
  expected = NULL,
  df = NULL,
  h = NULL,
  c = NULL,
  l = NULL,
  interpolate = c(2, 4),
  lty = 1,
  eps = NULL,
  line_col = "black",
  p.value = NULL,
  level = 0.95,
  ...
)

Details

https://stackoverflow.com/questions/54674441/how-to-format-p-values-in-an-association-plot-made-with-vcd

Examples


require(vcd)
#' class(legend_resbased)
legend_resbased<-stp25plot::legend_resbased2
shading_hcl <-stp25plot::shading_hcl2
assignInNamespace("legend_resbased", legend_resbased, pos = "package:vcd")
assignInNamespace("shading_hcl", shading_hcl, pos = "package:vcd")
#' 
pst <- function(txt) {
  paste(txt, "n =", n)
}

ipol <- function(x)
  pmin(x / 10, 1)


# figure-2 --------------------------------------------------------


dat <- stp25tools::get_data(
  "
racing diet    sex Freq
    km10 omnv female  147
      HM omnv female  238
    M_UM omnv female  215
    km10 vgtr female  113
      HM vgtr female  143
    M_UM vgtr female  125
    km10 vegn female  208
      HM vegn female  271
    M_UM vegn female  168
   km10 omnv   male   76
     HM omnv   male  197
   M_UM omnv   male  399
   km10 vgtr   male   29
     HM vgtr   male   72
   M_UM vgtr   male  116
   km10 vegn   male   49
     HM vegn   male  111
   M_UM vegn   male  187"
)

xtabs(Freq ~ racing + diet + sex, dat)

mosaic(
  Freq ~ racing + diet | sex,
  dat,
  shade = TRUE,
  legend = TRUE ,
  varnames = F,
  labeling_args = list(abbreviate_labs = c(8, 5, 4)),
  gp = shading_hcl,
  gp_args = list(
    interpolate = ipol,
    c = 100,
    lty = 1
  ),
  gp_labels = gpar(fontsize = 11),
  labeling = labeling_residuals,
  gp_text  =  gpar(fontsize = 9)
)


cotabplot(
  Freq ~ racing + diet + sex,
  dat,
  panel = cotab_coindep,
  n = 5000,
  type = "assoc",
  test = "maxchisq",
  interpolate = 1:2,
  legend = TRUE
)



cotabplot(
  Freq ~ racing + diet + sex,
  dat,
  panel = cotab_coindep,
  n = 5000,
  #  type = "assoc",
  test = "maxchisq",
  interpolate = 1:2,
  legend = TRUE
)

stp4/stp25plot documentation built on March 29, 2025, 4:26 p.m.