Skip to content

Fix problem with vector handling in ST3 derivatives#4

Open
BerriJ wants to merge 1 commit intogamlss-dev:mainfrom
BerriJ:main
Open

Fix problem with vector handling in ST3 derivatives#4
BerriJ wants to merge 1 commit intogamlss-dev:mainfrom
BerriJ:main

Conversation

@BerriJ
Copy link

@BerriJ BerriJ commented May 7, 2024

The ST3 derivatives enforce various bounds on the dsq1 and dsq2 objects using ifelse.
However, ifelse poorly handles non-matching lengths of the inputs. Consider this example:

ifelse(TRUE, c(1, 2), c(3, 4))

This evaluates to 1.

Similarly in ST3()$dldm

w1 <- ifelse(tau < 1000000, (tau+1)/(tau+dsq1),1)
w2 <- ifelse(tau < 1000000, (tau+1)/(tau+dsq2),1)

Evaluate to the first element of the vector (tau+1)/(tau+dsq1) and (tau+1)/(tau+dsq2). I believe outputting the whole vectors (tau+1)/(tau+dsq1) and (tau+1)/(tau+dsq2) would be correct here.
I suggest to fix that by repeating the input so that it matches the length of y which determines the length of dsq1 and dsq2. Like so: rep(tau, length(y)).

This is what this PR does.

Best regards,
BerriJ

@BerriJ
Copy link
Author

BerriJ commented Jun 9, 2025

Did you have a chance to review this?
Since this is a non-technical pull request and gamlss depends on it, it would be nice to get this merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant