can we have a vignette for how to use the rescale_contrasts() function?

未关闭 适合新手
#79 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
文档
描述清晰度
基本清楚
活跃度
活跃
技术栈
r
领域
documentation

调研方向

从 PsyR 仓库根目录开始,查看现有的 rescale_contrasts() 实现和可用的 PsyR 数据集,然后遵循该包的 vignette 惯例。构建一个 vignette,演示均值差异、两个方向交互作用和三个方向交互作用的缩放,并在可行的情况下调整所提供的示例以使用 PsyR 数据集。完成的标志是 vignette 能成功渲染,其示例能够运行并清楚解释预期结果。

由索引模型根据 Issue 内容生成。

描述

Hey @lane-sj,

Can we have a brand new shiny vignette that shows how to use the rescale_contrasts() function, for mean difference, 2, and 3-way interaction scaling? Below is an example for the interaction scaling. This example generates data, but it would be great if we could use datasets from the PsyR package if possible:

devtools::load_all(".") # From the PsyR repository root

Example 2 × 2 × 2 design with six observations per cell

dat <- expand.grid(
A = factor(c("A1", "A2")),
B = factor(c("B1", "B2")),
C = factor(c("C1", "C2")),
replicate = 1:6
)

dat$response <- with(
dat,
10 +
3 * (A == "A2" & B == "B2" & C == "C2") +
c(-2, -1, 0, 1, 2, 0)[replicate]
)

model <- stats::lm(response ~ A * B * C, data = dat)
emm <- emmeans::emmeans(model, c("A", "B", "C"))

Raw component comparisons, deliberately using different scales

a_raw <- c(2, -2)
b_raw <- c(3, -3)
c_raw <- c(4, -4)

Complete product vector: A varies fastest, then B, then C.

raw_three_way <- list(
"A by B by C" = as.vector(outer(
as.vector(outer(a_raw, b_raw)),
c_raw
))
)

scaled_three_way <- rescale_contrasts(
raw_three_way,
mode = "interaction",
interaction_order = 2
)

scaled_three_way

$A by B by C

[1] 1 -1 -1 1 -1 1 1 -1

three_way_table <- emmeans::contrast(
emm,
method = scaled_three_way,
adjust = "none"
)

summary(three_way_table, infer = c(TRUE, TRUE))

主要语言
R
星标
2
派生
5
平均合并
2 天 5 分钟
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

garner-code/PsyR 的其他 Issue

查看 garner-code/PsyR 的全部 Issue

相似的 Issue

更多 R Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。