Skip to content

pBCCG doesn't handle missing values well #2

@colinorourke

Description

@colinorourke

I've found an issue with the BCCG distribution functions. They don't gracefully handle missing values due to the use of any(q < 0), which will return NA if any of its inputs are missing. Here's a reprex, and a comparison to the behaviour of pnorm, which behaves as expected:

# quantiles
q1 = c(0,1)
q2 = c(0,1,NA_real_)

# Expected output: 2 numbers
gamlss.dist::pBCCG(q1, mu = 1, sigma = 1, nu = 0)
#> [1] 0.0 0.5
pnorm(q1, 1, 0.5)
#> [1] 0.02275013 0.50000000

# Expected output: 2 numbers and a missing value. pnorm does this,
# but pBCCG returns an error
gamlss.dist::pBCCG(q2, mu = 1, sigma = 1, nu = 0)
#> Error in if (any(q < 0)) stop(paste("q must be positive", "\n", "")): missing value where TRUE/FALSE needed
pnorm(q2, mean = 1, sd = 0.5)
#> [1] 0.02275013 0.50000000         NA

Created on 2023-09-14 with reprex v2.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions