-
Notifications
You must be signed in to change notification settings - Fork 5
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
predict function issue #22
Comments
Hi, Hmmm, it's hard to know with the information provided. When you say "the exercise", which one do you mean? Could you provide a link to the line in the tutorial? I do have a first guess though. Is it possible that the names of each variable (also known as attribute) in your |
I am in the "Predicting" section of the Marine Species Distribution Model (SDM) Tutorial (https://oceanhackweek.org/tutorials_marine_sdm/SDM/Turtle_maxnet.html) |
Those definitely look like a match to me. Next to test is the crop of env.stars - debugging is always just a series of little steps ruling out possibilities. Does this throw an error when you run it?
|
I have stepped through this markdown and I can't replicate the error you see. That makes me wonder if there is a difference in the versions in the stars packages we are using. Here is the output of my I seem to be running stars version 0.6-4
|
I have run and works. I reviewed the "predict" function of the raster package in detail and came across other examples of models where the attributes within it are ordered differently. First the environmental variables (env.stars) and then the model (sdm.model). I ran the following code and it worked: cropped = env.stars |> sf::st_crop(bb) Is that correct? Finally, here is the output of my sessionInfo() : |
Well, it seems we are using the same version of stars, so that helps. And glad to know that cropping works. I am not aware that the [dismo] package supports The predict() function actually is a wrapper function for another function specifically written for your model type that must exist somewhere in your current session of R. It will look for a function named predict.classname_goes_here() The classname looked for is the first one listed in the class hierarchy when you run the class() function. class(sdm.model)
So in this case R will look for predict.maxnet() That function can be found here… P.S. Other packages may provide predict functions for other classes of models. During any session of R you can list the available predict functions using... methods(predict)
|
Ooooh, here's what might be happening... There is a predicted <- predict(cropped, sdm.model, clamp = TRUE, type = "cloglog") But we still don't know why your original attempt, like that shown below, fails. predicted <- predict(sdm.model, cropped, clamp = clamp, type = type) I hate to ask, but have you tried restarting your session of R and knitting the tutorial? If you do that does it still throw an error? |
Hi, I am trying to run the predict function following the same steps as in the exercise but I get the following error:
predicted <- predict(sdm.model,
envs.tars %>% sf::st_crop(bb),
clamp = clamp, type = type)
Error in
[.stars
(newdata, , v) :selecting using invalid value label(s)?
Everything else I managed to replicate without problem. But I have not been able to solve this error.
The text was updated successfully, but these errors were encountered: