Skip to content

fosr error - large matrix and vector lambda supplied. #96

@edwardgunning

Description

@edwardgunning

Hi,

I came across #86 when diagnosing model warnings ( "In optimize(cvfcn, c(0, maxlam), tol = 0.01) : NA/Inf replaced by maximum positive value") using fosr (my data set has # observations ~ 400).

I noticed that when lambda is specified a vector, the pathological example that @julia-wrobel provided still throws an error, rather than a warning. That is:

`library(refund)
library(tidyverse)
set.seed(1988)
dat = pffrSim(n = 300, nygrid = 200, scenario = "int")

covars_df = data.frame(
intercept = rep(1, 300),
age = runif(300, 20, 80),
height = rnorm(300, 68),
weight = rnorm(300, 150)
)

covars_mat = as.matrix(covars_df)
Y_mat = as.matrix(dat$Y)

model_fosr = fosr(Y = Y_mat, X = covars_mat, lambda = 10*seq(0, 5))`

Throws error:

Calculating CV for candidate smoothing parameter values...
lambda LOFO-CV
[1,] 0 NA
[2,] 10 NA
[3,] 20 NA
[4,] 30 NA
[5,] 40 NA
[6,] 50 NA
Error in amc(as.vector(t(respmat)), X.sc %x% Bmat, gam.method = gam.method, :
is.null(lambda) | length(lambda) == n.p is not TRUE

For smaller data (e.g., change n=300 to n=100), no error is produced.

Just letting you know of this error in case the patch can be adapted to handle this.

Best wishes,
Ed

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