Error in predict()

Create issue
Issue #80 resolved
Former user created an issue

Hi,

I have an spls-regression model and use predict() on new X data. This gernerally works fine, but fails when X has only one row: "Error ... attempt to set 'rownames' on an object with no dimensions"

Debugging shows that the error occurs in the line

rownames(Y.hat[[i]]) = rownames(newdata[[i]])
rownames(Y.hat[[i]])

throws a "NULL" in the 1 row case.

Any idea what is going on here?

Comments (4)

  1. Florian Rohart

    Hi there,

    When you say "X has only one row", is that the 'newdata' or the original X of the spls model?

    I can't replicate the problem when 'newdata has only one row (and is a matrix as required)

  2. Sally Weiss

    Hi,

    sorry for the confusion.

    It fails here , if 'newdata' is a one row matrix. I tried to use different one-row 'newdata', but now difference.

    However, I observed this in version 6.1.0, but not in 5.2.0.

  3. Florian Rohart

    Hi Sally,

    Could you provide me with a minimal example that reproduces the problem? I've tried on mixOmics v6.1.0 (the 6.1.1 is out since last October, few bugs fixed) and everything is working fine - see example below with some data available in mixOmics. If it's because of some specificities of your data, you can send us part of your data by email that led to the problem and it will only be used for debugging purposes -everything will be confidential.

    data(liver.toxicity)
    X <- liver.toxicity$gene
    Y <- liver.toxicity$clinic
    
    toxicity.spls <- spls(X, Y, ncomp = 2, keepX = c(50, 50), keepY = c(10, 10))
    
    newdata = matrix(rnorm(3116), nrow=1) # newdata must be a matrix of one row and 3116 columns as X
    colnames(newdata) = colnames(X) # 'newdata' must include all the variables of 'object$X'
    
    pred = predict(toxicity.spls, newdata)
    
  4. Log in to comment