0

Can anyone help me on this?

I am doing a report for significant effects in unreplicated fractional factorials. I am using R.

The file name is Soup,

    Model.1 <- lm (Yield ~ (.)^2, data = Soup)
    modc <- lm(y~(.)^2, data=soup)
    library(daewr)
    LGB(coef(modc)[-1], rpt = FALSE)

This is code that I have been given previously, which worked.

The error message that I get is:

    Error in LGB(coef(modc)[-1], rpt = FALSE) : could not find function "LGB"

I have installed and loaded the daewr library as noted. When I search for LGB, I get then following:

enter image description here

I am using RStudio 2023.03.0 Build 386 and R Version and the latest version of R.

Can anyone advise how to resolve this? Either I am calling the LGB function incorrectly or there is an issue with it?

If there is a known issue, can an alternative package and library be used instead.

M--
  • 25,431
  • 8
  • 61
  • 93
user3569147
  • 104
  • 3
  • 9
  • 1
    Have you called `library(daewr)` before trying to use `LGB`? Does trying `daewr::LGB` work for you? – Allan Cameron Apr 28 '23 at 13:22
  • See https://stackoverflow.com/q/7027288/3358272 for several ways (in addition to the plain `library(daewr)`) for locating functions in various locations. – r2evans Apr 28 '23 at 13:29

1 Answers1

2

This is a very weird situation where the LGB function, which is indeed listed in the help pages for the daewr package, is not exported by the package. To use it you need three colons (:::), e.g.

m1 <- lm(mpg ~ . - am - gear - carb, mtcars)
daewr:::LGB(coef(m1)[-1], rpt = FALSE)

(LGB says it's constrained to work only for coefficient vectors of length 7,8,11,15,16,26,31,32,35,63,or 127 (???), so I dropped some of the columns of mtcars from the regression).

This seems like a bug in the package. (It's also not clear what LGB is really doing, as it seems to be a trivial wrapper for the [also not exported] LGBc function ... maybe these are experimental functions?) Maybe worth contacting the maintainer (maintainer("daewr")), or asking the person you got the code from?

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453