Skip to content

Issue in psfmi_lr with Factor Conversion Causing Errors #11

Description

@AmineBahmed

Hello,

First of all, thank you for providing such a great package, its extremely helpful.

I wanted to report an issue I encountered while fitting a logistic regression model including factor variables using the psfmi_lr() function. I received the following error:

Error in family$linkfun(mustart) :Argument mu must be a nonempty numeric vector

Alongside this, several warnings appeared, all related to factor predictors. Most of them included the message:

Caused by warning in as.numeric(): ! NAs introduced by coercion

After investigating, I noticed that within the code, factor variables are being converted using the following line:

data <- mutate_if(data, is.factor, ~ as.numeric(as.character(.x)))

This transformation introduces NAs when the factor levels are non-numeric (e.g., character labels), which I believe leads to the error.

I tested this by forking the package and removing that line — and everything worked correctly afterwards.

Best regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions