sim_fit error with rw walk model #64
AdriGooden
started this conversation in
General
Replies: 1 comment 1 reply
-
library(aniMotum)
#> Warning: package 'aniMotum' was built under R version 4.3.2
#> Warning in checkTMBPackageVersion(): Package version inconsistency detected.
#> aniMotum was built with TMB version 1.9.10
#> Current TMB version is 1.9.9
#> Please re-install 'aniMotum' from source using install.packages('aniMotum', type = 'source') or remove your current TMB version and re-install using remotes::install_version('TMB', version = '1.9.10')
library(patchwork)
#> Warning: package 'patchwork' was built under R version 4.3.3
library(sf)
#> Warning: package 'sf' was built under R version 4.3.2
#> Linking to GEOS 3.11.2, GDAL 3.7.2, PROJ 9.3.0; sf_use_s2() is TRUE
library(tidyverse)
#> Warning: package 'tidyverse' was built under R version 4.3.2
#> Warning: package 'ggplot2' was built under R version 4.3.3
#> Warning: package 'readr' was built under R version 4.3.2
#> Warning: package 'dplyr' was built under R version 4.3.2
#> Warning: package 'forcats' was built under R version 4.3.2
#> Warning: package 'lubridate' was built under R version 4.3.3
library(purrr)
library(lubridate)
library(ggplot2)
library(readr)
setwd("C:/Users/adrie/OneDrive/Desktop/PhD/Chap 3A - MLRSF/SPOT DATA TAKE 2")
locsduplicate<-read.csv("locsduplicate.csv")
df2 <- subset(locsduplicate, (id %in% c(48,40,375,234,25,179))) # need to try and run a second model for the remainder of the sharks that wouldnt converge using the CRW
fitrw <-
fit_ssm(x = df2,
vmax = 4, ## maximum speed of whale sharks (in m/s)
model = "rw", ## Move persistence model
time.step = 24, ## predict positions every 24 hours
control = ssm_control(verbose = 0))
#> Warning in sqrt(as.numeric(object$diag.cov.random)): NaNs produced
#> Warning: Hessian was not positive-definite so some standard errors could not be calculated. Try simplifying the model by adding the following argument:
#> map = list(psi = factor(NA))
print(fitrw, n= nrow(fitrw))
#> # A tibble: 6 × 5
#> id ssm converged pdHess pmodel
#> <chr> <named list> <lgl> <lgl> <chr>
#> 1 179 <ssm [15]> TRUE TRUE rw
#> 2 234 <ssm [15]> TRUE TRUE rw
#> 3 25 <ssm [15]> TRUE TRUE rw
#> 4 375 <ssm [15]> TRUE TRUE rw
#> 5 40 <ssm [15]> TRUE TRUE rw
#> 6 48 <ssm [15]> TRUE TRUE rw
###Both of these models produced different errors for the RW model###
null_fit <-
sim_fit(fitrw, ## the ssm model we want to base our null models on
what = "predicted", ## component of the model to use
reps = 100) ## number of replicated simulations per animal
#> Error in if (mu[2] < y_rng[1]) {: missing value where TRUE/FALSE needed
st <- sim_fit(fitrw[2,],
what="predicted",
reps=5)
#> Error in FUN(X[[i]], ...): Implausible travel rates detected, check SSM fit for implausible locations
library(terra)
#> Warning: package 'terra' was built under R version 4.3.2
#> terra 1.7.71
#>
#> Attaching package: 'terra'
#> The following object is masked from 'package:tidyr':
#>
#> extract
#> The following object is masked from 'package:patchwork':
#>
#> area
load(system.file("extdata/grad.rda", package = "aniMotum"))
grad <- terra::unwrap(grad)
tibble(whaleshark_fit)
#> Error: object 'whaleshark_fit' not found
## Now lets rerun the simulation including the gradient object
null_fit2 <-
sim_fit(converged_tracks,
what = "predicted",
reps = 120,
grad = grad,
beta = c(-300,-300))
#> Error in eval(expr, envir, enclos): object 'converged_tracks' not found
plot(null_fit2, ncol = 6)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'null_fit2' not found
plot(null_fit, ncol = 3)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'null_fit' not found Created on 2024-06-03 with reprex v2.1.0 I have attached a reprex if that helps with answering the question |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there
I am trying to create pseudo-tracks for my animals and need to create CRW or RW models, as my SSM was originally done under an MP model. However I am getting these errors when running sim_fit on my random walk model. This data set comprises 6 animals that would not converge under the CRW model. The crw model ran through the sim_fit process with no issues. I am not sure why as there are no NAs in the data and the all animals converged or if it is appropriate to do two different ssm models when creating absences. I have attached the data file. I have tried simplifying my RW model to remove the vmax and altering my timestep (although this is the time step that created good tracks under my MP and CRW models)
nonconverge_sharks.csv
SSM code used
This model fits fine as shown below
I tried two different methods for running the sim_fit function on the RW model (the first one ran no issues on my CRW)
Error in if (mu[2] < y_rng[1]) { : missing value where TRUE/FALSE
and
Error in FUN(X[[i]], ...) : Implausible travel rates detected, check SSM fit for implausible locations
There doesn't appear to be any major issues with the locations and they align with others from these animals. I have not had any issues creating tracks from my crw model.
I appreciate your help with this.
Thanks
Adrienne
Beta Was this translation helpful? Give feedback.
All reactions