Open AndreaNOdell opened 2 years ago
I think this means you need to be careful to include any spatial covariates that are in your fitted model. Depth and depth-squared are in the example, but I don't think you have any spatially varying covariates in the models you are fitting. I might be mis-remembering though. The time-varying covariates like Catch_year and Cohort would be the same across all the locations (like Year in the example). Does that help?
That definitely helps and does seem to be the case. However now I am running into an error message. I'll keep messing around with it, but thought I'd drop it here in case you see something I don't
Run predict function predicted_vals = predict(m4.spatiotemporal, newdata = grid_pred_sdm)
This is what the structure of the new data to predict over looks like. Had to include spatial coordinates for each year. The coordinates are UTM divided by 1000 (similar to what I used when I ran the model)
str(grid_pred_sdm) 'data.frame': 4575 obs. of 3 variables: $ X : num 890 920 980 890 920 ... $ Y : num 3734 3734 3734 3764 3764 ... $ catch_year: Factor w/ 15 levels "1986","1989",..: 1 1 1 1 1 1 1 1 1 1 ...
Seems to be an issue with the vapply function within the predict function. Maybe there is something wrong with my input dataframe, but I am still trying a few different things and messing around with it. Will keep you posted.
I was able to create a new spatial domain to create predictions over using Michael's code - yay! However, now as I try to make predictions, I am realizing that I need to have covariate information for each datapoint in the spatial domain (which I do not have).... I was under the impression the spatio-temporal component of the model could predict those areas between sampling sites. Any thoughts? Below is a link to the vignette I am using and the last sentence of the first paragraph in spatial predictions section is where it mentions about the covariates.
https://pbs-assess.github.io/sdmTMB/articles/basic-intro.html#spatial-predictions