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

[BUG] olink_lmer not working with numeric main variables #283

Open
joshielevy opened this issue Aug 6, 2023 · 2 comments
Open

[BUG] olink_lmer not working with numeric main variables #283

joshielevy opened this issue Aug 6, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@joshielevy
Copy link

Describe the bug

If I specify a main variable that is numeric, it's failing the number_of_samples_w_more_than_one_level check, because the main variable is being added to the single_fixed_effects vector here:

    if(!is.null(covariates)){
      factors_in_df <- names(df)[sapply(df, is.factor)]
      single_fixed_effects <- c(variable,
                                intersect(covariates,
                                          factors_in_df))
    }else{
      single_fixed_effects <- variable
    }

To Reproduce
Steps to reproduce the behavior:

try with a numeric variable

Expected behavior

should run without errors

reccomended fix

set single_fix_effects to not include numeric variables, for example:

      single_fixed_effects <- setdiff(c(variable,
                                intersect(covariates,
                                          factors_in_df)), num.vars)
@joshielevy joshielevy added the bug Something isn't working label Aug 6, 2023
@kathy-nevola
Copy link
Contributor

Thanks for reaching out. When you say a numeric variable, do you mean a continuous variable or a categorical that is stored as number? Is this seen for only a fixed effect or any variable? Can you give me an example of the input you are running?

@joshielevy
Copy link
Author

Hi Kathy - I was using a continuous variable. Here's an example:

I'm taking some real data I have - just the olink and identifier columns, then adding fake NPX and a fake continuous test_var:

fake_data$test_var <- rnorm(nrow(fake_data), 0, 10)
fake_data$visit_day <- sample(1:4, size = nrow(fake_data), replace = TRUE)

lmer_results <- olink_lmer(df = fake_data,
variable = c('test_var'),
random = 'visit_day',
return.covariates = TRUE,
verbose=TRUE
)

I get the following:

Error in withCallingHandlers({ :
There are 40 samples that do not have a unique level for the effect test_var. Only one level per sample is allowed.

If I run the same call but using the fix I mentioned above, I don't get that error.

If I were you I'd start with some real data and add the fake continuous variable, otherwise you'll get more errors...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants