easystats / easystats/insight

`sampleSelection` and `find_variables`

Open
#424 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement :boom:
Dominant language
R
Stars
442
Forks
47
Avg merge
3d 2h
Merged PRs (30d)
7

Description

A possible bug: I could not use find_variables on a model produced by sampleSelection::heckit or sampleSelection::selection. Example:

library(insight)
library(sampleSelection)

data(Mroz87, package = "sampleSelection")
Mroz87$kids <- (Mroz87$kids5 + Mroz87$kids618 > 0)
model <- heckit(
  lfp ~ age + I(age^2) + faminc + kids + educ,
  wage ~ exper + I(exper^2) + educ + city,
  data = Mroz87)

find_variables(model)
# Error in f[["conditional"]][[3]]: subscript out of bounds

> traceback()
4: .prepare_predictors(x, f, elements)
3: find_predictors.default(x, effects = effects, component = component,
       flatten = flatten, verbose = verbose)
2: find_predictors(x, effects = effects, component = component,
       flatten = flatten, verbose = verbose)
1: find_variables(model)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided sampleSelection::heckit reproduction and trace find_variables() through find_predictors.default() to .prepare_predictors(), where the subscript error occurs. Compare the model structure for heckit or selection objects, then verify that find_variables(model) completes and returns the expected variables without the subscript error.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.