InseeFr / InseeFr/gustave

Control the length of the output of the variance function

Open
#6 0 comments 0 reactions 1 assignee Claimed by @martinchevalier View on GitHub
enhancement
Dominant language
R
Stars
9
Forks
3
PR merge metrics
No merged PRs in 30d

Description

At least in simple cases, the output of the variance function should be of length the number of columns of the Y variable in input.

- [ ] Determine whether this has to be true in all cases
- [ ] If so, try to test it at the variance definition step (it may need a dry-run of the variance function) or at the execution step (easier)

MWE (thanks to @ThomasDeroyon) :

```r
data <- data.frame(id = 1:100, sex= c(rep(1, 50), rep(2, 50)),
y = c(rnorm(50, 1, 3), rnorm(50, 2, 4)), weight = rep(10, 100))

# Dont't work
variance_function <- function(y) 1
variance_wrapper <- gustave::define_variance_wrapper(variance_function = variance_function,
reference_id = data$id,
reference_weight = data$weight,
default_id = "id")
variance_wrapper(data, as.factor(sex))

# Works
variance_function <- function(y) rep(1, NCOL(y))
variance_wrapper <- gustave::define_variance_wrapper(variance_function = variance_function,
reference_id = data$id,
reference_weight = data$weight,
default_id = "id")
variance_wrapper(data, as.factor(sex))
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.