Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndvPred_lme : Error in right_rows(newdata, newdata[[timeVar]], id, times_to_pred) : 'list' object cannot be coerced to type 'double' #88

Open
jilljb18 opened this issue Nov 24, 2021 · 3 comments

Comments

@jilljb18
Copy link

I am using IndvPred_lme to cross-validate an lme model, which looks like this:
final = lme(IHS_Ypd ~
L_S383D *
(Encr + Trt),
data = Boot.temp,
random = ~ 1 | Plot,
correlation = corARMA(form = ~ visit | Plot / Tind, p = 1))

I'm then trying to apply this model to new data, with different unique levels of Tind (different values of Plot could also occur by chance):

preds <- JMbayes::IndvPred_lme(final, newdata = Boot.test, timeVar = "visit")

I also tried this:
final_light <- JMbayes::extract_lmeComponents(final, timeVar = "visit")
preds <- JMbayes::IndvPred_lme(final_light, newdata = Boot.test, timeVar = "visit")

[side note: I'm not sure if converting to the light version is necessary]

Either way, I'm getting this error:
Error in right_rows(newdata, newdata[[timeVar]], id, times_to_pred) :
'list' object cannot be coerced to type 'double'

I've tried converting 'visit' to a numeric (rather than the original integer), and also converting all characters to factors prior to splitting the data and fitting the model, and ensuring levels of Tind are appropriately unique in the training versus test set, but none of fixes the issue.

I'm guessing this is probably something simple, but I can't figure it out. I'm not an expert coder, so apologies for the possibly dumb question. Thanks!

@drizopoulos
Copy link
Owner

drizopoulos commented Nov 24, 2021 via email

@jilljb18
Copy link
Author

Thanks for the reply.

I am just trying to predict for the times that are present in the Boot.test dataset, not forecast past those. Also (and unfortunately) the times (visit) values are not the same for each Tree, i.e. some trees are missing measurements/data for some 'visits'.

I just now tried adding 'times=Boot.test$visit'. This seems like it would at least only predict for the values within the Boot.temp data, but I'm guessing this is not what the function actually 'wants' and adding it doesn't prevent the error.

Just for the sake of trying something (even though this is not what I want), I added 'times = c(7,8)' and got this error:
Error in col(ind) : a matrix-like object is required as argument to 'col'
So I guess I'm unclear on what the 'times' argument should look like.

Lastly, again, just to try something, if I add 'all_times = TRUE' without the times argument, I get a different error:
Error in m[i, , drop = FALSE] : subscript out of bounds
Note again, that I don't actually want to predict for all times, as explained above.

Thanks again for your help!

@deconinckflo
Copy link

Hello,

I am in the same situation as you, have you found a solution to your problem ?

Like you, when I try to use IndvPred_lme, I go this error :
Error in col(ind) : a matrix-like object is required as argument to 'col'

Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants