Skip to content

[upstream rENA 0.3.1] Documented x_var form "lm(formula=V ~ ...)" raises an error #3

Description

@HUDongpin

This is an issue in rENA 0.3.1, not in ena-python. It is tracked here because it came out of porting rENA to Python. Reported as an observation, not an accusation — it may be fixed upstream or intended, in which case please correct me. Full write-up: docs/rena-upstream-issues.md

Summary

The x_var form shown in ena.rotate.by.hena.regression's own documentation raises an error. The code accepts a plain formula string instead.

Severity: low — documentation/code mismatch.

Setup (rENA 0.3.1, R 4.4.2)
library(rENA)
rows <- data.frame(
  unit  = rep(paste0("U", 1:6), each = 4),
  conv  = rep(rep(c("c1", "c2"), each = 2), times = 6),
  grp   = rep(c("g1", "g2"), each = 12),
  score = rep(c(10, 20, 30, 40, 50, 60), each = 4),
  A = c(1,0,1,0, 0,1,1,1, 1,1,0,1, 0,0,1,0, 1,0,0,1, 0,1,1,0),
  B = c(0,1,1,1, 1,1,0,0, 0,1,1,0, 1,0,0,1, 0,1,1,0, 1,0,0,1),
  C = c(1,1,0,0, 1,0,1,0, 1,0,0,1, 0,1,1,1, 1,1,0,0, 0,0,1,1),
  D = c(0,0,1,1, 0,1,0,1, 0,1,1,0, 1,1,0,0, 0,0,1,1, 1,1,0,0),
  stringsAsFactors = FALSE)
acc <- ena.accumulate.data(
  units = rows[, "unit", drop = FALSE], conversation = rows[, "conv", drop = FALSE],
  metadata = rows[, c("grp", "score")], codes = rows[, c("A","B","C","D")],
  window.size.back = 2)
set <- ena.make.set(acc, dimensions = 2)

Reproduce

ena.rotate.by.regression.R:11 documents:

x_var: Regression formula for x direction, such as "lm(formula=V ~ Condition + GameHalf + Condition : GameHalf)"

ena.rotate.by.hena.regression(set, list(x_var = "lm(formula = V ~ score)"))
#> Error: attempt to set an attribute on NULL

ena.rotate.by.hena.regression(set, list(x_var = "V ~ score"))
#> works

Root cause

The code calls formula(params$x_var) (lines 55 and 100), which accepts "V ~ score" but not an lm(...) call wrapped in a string. The documentation appears to predate that change.

Suggested fix

Update the docs to the plain formula form, or accept both.

What ena-python does

Accepts the plain formula form and documents it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstream-renaDefect in rENA (upstream reference implementation), not in pyENA

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions