Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control the length of the output of the variance function #6

Open
2 tasks
martinchevalier opened this issue Jul 9, 2021 · 0 comments
Open
2 tasks
Assignees

Comments

@martinchevalier
Copy link
Collaborator

martinchevalier commented Jul 9, 2021

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) :

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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant