Skip to content

lm() doesn't like it when you can't invert the QR matrix #124

@EmilHvitfeldt

Description

@EmilHvitfeldt

Simple example here. Gets annoyed during parse_model(). I wonder if we can rewrite this model in orbital to avoid parsing.

library(tidymodels)
library(orbital)

rec_spec <- recipe(Sale_Price ~ ., data = ames) |>
  step_nzv(all_numeric_predictors()) |>
  step_normalize(all_numeric_predictors()) |>
  step_dummy(all_nominal_predictors()) |>
  step_nzv(all_predictors())

mod_spec <- linear_reg()

wf_spec <- workflow(rec_spec, mod_spec)

wf_fit <- fit(wf_spec, ames)

orb <- orbital(wf_fit)
#> Error in qr.solve(qr.R(model$qr)): singular matrix 'a' in solve

Can get working model with:

library(tidymodels)
library(orbital)

rec_spec <- recipe(Sale_Price ~ ., data = ames) |>
  step_normalize(all_numeric_predictors()) |>
  step_dummy(all_nominal_predictors()) |>
  step_zv(all_predictors()) |>
  step_corr(all_predictors())

mod_spec <- linear_reg()

wf_spec <- workflow(rec_spec, mod_spec)

wf_fit <- fit(wf_spec, ames)

orb <- orbital(wf_fit)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions