Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating B-spline basis functions from an extended knot sequence #2

Closed
wenjie2wang opened this issue Aug 8, 2021 · 5 comments
Closed

Comments

@wenjie2wang
Copy link
Contributor

Hi @BerriJ

It seems that the package profoc needs constructing B-splines with an extended knot sequence. You used the package splines2 that I maintained for this task. However, the constructor you are using is not intended for the extended knot sequences. The future version of package splines2 will check the placement of the internal knots more strictly to resolve wenjie2wang/splines2#5. As a result, the testing examples in tests/testthat/test-spline-basis.R will fail.

To resolve this issue, I would suggest using the constructor intended for the extended knot sequences. For example,

Rcpp::sourceCpp(code = "
#include <RcppArmadillo.h>
#include <splines2Armadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::depends(splines2)]]
using namespace splines2;
using namespace arma;
// [[Rcpp::export]]
mat splines2_basis(const vec &x,
                   const vec &knots,
                   const unsigned int deg)
{
    splines2::BSpline bs_obj{x, deg, knots};
    return bs_obj.basis(true);
}")

order <- 4
deg <- order - 1
pstep <- 0.01
x <- seq(pstep, 1 - pstep, pstep)
knots <- seq.int(- 0.2, 1.2, 0.1)
res0 <- splines::splineDesign(knots, x, order, outer.ok = TRUE)
res1 <- splines2_basis(x, knots, deg)
all.equal(res0, res1)
#> [1] TRUE

Created on 2021-08-08 by the reprex package (v2.0.0)

BerriJ added a commit that referenced this issue Aug 8, 2021
@BerriJ
Copy link
Owner

BerriJ commented Aug 8, 2021

Hi @wenjie2wang,

I just added some commits onto your PR and merged it. Btw thank you very much. I keep the main branch strictly corresponding to the latest CRAN release. Therefore, I merged into develop.

Do you already know when your changes are hitting CRAN?

Best
Jonathan

@wenjie2wang
Copy link
Contributor Author

Thanks for your quick actions!

Do you already know when your changes are hitting CRAN?

I intended to submit a new version of splines2 in two weeks. Thus, I would appreciate it if you could submit the updated version of profoc to CRAN in one or two weeks.

@BerriJ
Copy link
Owner

BerriJ commented Aug 9, 2021

I expect that I'm able to submit it to CRAN early next week (~16.08.2021). I hope this suits you well.

By the way: thanks a lot for your great package. It resolved a lot of hassle. :)

@wenjie2wang
Copy link
Contributor Author

That would be great. Thanks!

@BerriJ
Copy link
Owner

BerriJ commented Aug 15, 2021

V 0.8.3 which resolves this issue was released on CRAN today.

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

No branches or pull requests

2 participants