I've created a model using R pls and now I'm trying to use the model to predict outcomes based on new data. The original data frame has 2154 variables which I distinguished between the X-matrix and the Y-matrix. So the partitioned X-matrix has 2151 variables and columns. There are several intermediary data frames referenced that have between 2151 and 2154 columns. The new data frame I added has 2154 columns, but I am getting this error and I'm not sure how to tell how many columns the pls model is referencing so that I can make the two identical. Any help would be appreciated. Thanks!
Asked
Active
Viewed 818 times
1
-
Welcome to Stack Overflow! Please include the relevant code excerpt producing this error so that we can help debug. – J. Blackadar Aug 29 '18 at 21:31
-
I apologize. I suspected that I'd need to post code. However, given the complexity of it, I didn't know where to begin. I have worked through my previous problem, but am now experiencing a problem with getting my model to read new data. I've tried having the model read as data frame and as matrix. The error I'm receiving as df is "Error in eval(predvars, data, env) : object '`407`' not found" where 407 is the first spectral band column name (not the first column though). The error I'm receiving as matrix is "Error in newX %*% B[-1, , i] : requires numeric/complex matrix/vector arguments". – Ashley Sep 07 '18 at 17:06
-
`pred <- predict(model$finalModel, newdata = test, ncomp = 22, intercept = TRUE)` – Ashley Sep 07 '18 at 17:07
-
colnames `"word" "X407" "X408" "X409"..."X697" "X698" "X699"` – Ashley Sep 07 '18 at 17:10