Skip to content

calling bnlror gnlr in a function #5

@guiblanchet

Description

@guiblanchet

I am interested in using both bnlr and gnlr within a function and I found that a chunk of code that works outside a function, when placed within a function sends an error.

To illustrate this here is a simplified example:

Code outside a function

iniParam <- list(rate = 1)

resp <- rbinom(1, n =70,  p = 0.5)
y <- cbind(resp, 1 - resp)
x <- rep(1:7, 10)

res <- gnlm::bnlr(y = y, link = "logit",
                    mu = ~ exp(-rate * x), 
                    pmu = iniParam)

rm(list = ls())

Code within a function

testFunc <- function(){
  iniParam <- list(rate = 1)

  resp <- rbinom(1, n =70,  p = 0.5)
  y <- cbind(resp, 1 - resp)
  x <- rep(1:7, 10)

  res <- gnlm::bnlr(y = y, link = "logit",
                    mu = ~ exp(-rate * x), 
                    pmu = iniParam)
  
  return(res)
}

testFunc()

I have tried to solve this problem by setting a new environment within the function or using tccov class object, but in both cases a different error arose.

I would much appreciate any insight you may have about solving this problem.

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