Skip to content

cv.BigVAR assertion code incorrectly written for single lambda parameter #24

@extrospective

Description

@extrospective

My code reads:

Model1 <- constructModel(mdata, p=2, "OwnOther",ownlambdas=TRUE, gran=c(1), intercept=FALSE)
Model1Results = cv.BigVAR(Model1)

An error results:

Error in if (object@Granularity[2] == 1) { : missing value where TRUE/FALSE needed

The cause of this error has been determined as follows:

BigVARObjectClass.R around line 592 attempts to check for gran having length 1, but does so incorrectly:

        if(object@Granularity[2]==1){
            stop("only one penalty parameter; run BigVAR.est instead of cv.BigVAR")
        }

When I invoke with a single parameter for gran, this code is intended to tell me I have one penalty parameter, but instead the condition check fails. Based on other code in the repo, this one line should be corrected to:

if (length(object@Granularity)==1) { ... }

Checking the length rather than dereferencing second element of an array which may have length 1.
As this fix is made, consider whether ==1 or <=1 is more appropriate.

This is a minor issue, now that it is understood and documented here. The seeming workaround is to call BigVAR.est rather than cv.BigVAR when one lambda is supplied. However, as I write below, there are reasons I was trying to use cv.BigVAR, and these are workarounds already.


I could fix and push, but I have run into some other hiccups on this code path. So I can use this ticket also to explain what I am doing and issues I encounter.

a. I want to show that BigVAR and VAR are equivalent at lambda=0, before starting to vary lambda. This is not directly possible since lambda=0 is explicitly allowed (not sure why) and I can approximate with lambda = 0.00000001. FYI. I think it would be nice to support lambda=0. Is there a reason why lambda=0 cannot be directly supported?

b. But when I use BigVAR.est (to test lambda=0.0000001), I encounter problems calculating FEVD with frequencyConnectedness::genFEVD. The latter is designed to work with BigVAR, but explicitly checks the class returned from the fit function (cv or est). cv.BigVAR returns a class which checks out with frequencyConnectedness. But BigVAR.est returns a (fairly limited) list type, and frequencyConnectedness refuses to report the FEVD since the class type assertion fails.

My sense is that this may be a BigVAR issue because BigVAR.est is not building out a full structure similar to cv.BigVAR, and therefore I cannot then use frequencyConnectedness. But I defer to the author in determining whether this is a BigVAR bug, a frequencyConnectedness bug, or a case where the user should build their own structures to simulate what cv.BigVAR would normally be producing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions