Error in my.RSS.table[as.character(i), 3:4] <- c(pot.index[opt], break.RSS[opt]) : replacement has length zero

Open
#2 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
r
Domain
data

Research direction

Start by reproducing the reported breakpoints() call with the attached CSV, using bfastpp() and bfastts() as shown. Trace how recresid(), X1, break.RSS, and opt produce the NaN and empty replacement; done means the example no longer fails with a replacement-length error and the behavior for this edge case is covered by a regression test.

Written by the indexing model from the issue text.

Description

bug

This is a very odd edge case. With a specific h value and specifically when using both trend and harmon components of bfastpp, for specific data, I get the error:

Error in my.RSS.table[as.character(i), 3:4] <- c(pot.index[opt], break.RSS[opt]) :
    replacement has length zero

Also a lot of warnings about sqrt() producing NaN values. Looks like that line fails because opt is an integer(0), and that is because break.RSS is a single NaN (which probably comes from the sqrt problem, which in turn comes from fr in recresid being a negative value, which comes from X1 having negative values, and I don't know what X1 stands for).

To reproduce, see attached CSV, and then run the code:

breakpoints(formula(response~trend+harmon), data=
    bfastpp(bfastts(CSV$evi, CSV$time), "irregular"), order=3), h=46)

bug.txt

Dominant language
R
Stars
6
Forks
5
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bfast2/strucchangeRcpp

All issues in bfast2/strucchangeRcpp

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.