Comments (5)
Hi Esther,
When using aniMotum
to process GPS data you need to specify the location class as "G" in the data frame that you are passing to fit_ssm
. Please check ?fit_ssm
for more info.
I would just reformat your lc column as follows, and then the function should run.
Best,
James
require(tidyverse)
#> Loading required package: tidyverse
require(aniMotum)
#> Loading required package: aniMotum
#> The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
#> which was just loaded, will retire in October 2023.
#> Please refer to R-spatial evolution reports for details, especially
#> https://r-spatial.org/r/2023/05/15/evolution4.html.
#> It may be desirable to make the sf package available;
#> package maintainers should consider adding sf to Suggests:.
#> The sp package is now running under evolution status 2
#> (status 2 uses the sf package in place of rgdal)
#>
#> Attaching package: 'aniMotum'
#> The following object is masked from 'package:purrr':
#>
#> map
df <- read_csv("~/Downloads/Cleaned_GullTrackssubset.csv")
#> Rows: 10 Columns: 5
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> dbl (4): id, lc, lon, lat
#> dttm (1): date
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
df <- df |> mutate(lc = "G")
df
#> # A tibble: 10 × 5
#> id date lc lon lat
#> <dbl> <dttm> <chr> <dbl> <dbl>
#> 1 211696 2021-05-25 04:03:28 G -73.2 40.8
#> 2 211696 2021-05-25 04:18:27 G -73.2 40.8
#> 3 211696 2021-05-25 04:33:31 G -73.2 40.8
#> 4 211696 2021-05-25 04:48:29 G -73.2 40.8
#> 5 211696 2021-05-25 05:03:28 G -73.2 40.8
#> 6 211696 2021-05-25 05:18:34 G -73.2 40.8
#> 7 211696 2021-05-25 05:34:05 G -73.2 40.8
#> 8 211696 2021-05-25 05:48:34 G -73.2 40.8
#> 9 211696 2021-05-25 06:03:42 G -73.2 40.8
#> 10 211696 2021-05-25 06:18:31 G -73.2 40.8
fit <- fit_ssm(df, model = "rw", time.step = 24)
#> fitting rw SSM to 1 tracks...
#> pars: -5.74965 -4.71341 1.91815 0 0 0
plot(fit)
#> $`211696`
Created on 2024-01-08 with reprex v2.0.2
from animotum.
from animotum.
Hi,
I downloaded more data, and I can't get the model to fit anymore.
For the full dataset (dat2), I keep getting this error:
glimpse(dat2)
Rows: 128,144
Columns: 5
$ id "211696", "211696", "211696", "211696", "211696", "211696", "211696", "211696", "211696", "211696", "211…
$ date 2021-05-25 04:03:28, 2021-05-25 04:18:27, 2021-05-25 04:33:31, 2021-05-25 04:48:29, 2021-05-25 05:03:28…
$ lc "G", "G", "G", "G", "G", "G", "G", "G", "G", "G", "G", "G", "G", "G", "G", "G", "G", "G", "G", "G", "G",…
$ lon -73.20768, -73.20767, -73.20747, -73.20747, -73.20737, -73.20757, -73.20767, -73.20756, -73.20740, -73.2…
$ lat 40.83309, 40.83319, 40.83356, 40.83337, 40.83317, 40.83350, 40.83343, 40.83396, 40.83349, 40.83374, 40.8…
fit_crw <- fit_ssm(dat2, model = "crw", time.step = 24)
fitting crw SSM to 9 tracks...
Error in seq.int(from, by = by, length.out = length.out) : 'length.out' must be a non-negative number
I tried this
fit_crw <- fit_ssm(dat2, model = "crw", time.step = NA)
fitting crw SSM to 9 tracks...
pars: 1 1 NA NA NA NA NA NA NA NA 0 0 NA 0 Error in nlminb(obj$par, ifelse(control$verbose == 1, myfn, obj$fn), obj$gr, :
NA/NaN gradient evaluation
Error in optimHess(par.fixed, obj$fn, obj$gr) :
non-finite value supplied by optim
Error in rep$pdHess : $ operator is invalid for atomic vectors
So I did a subset of the first 50 rows and I got this:
df=head(dat2, 50)
fit <- fit_ssm(df, model = "rw", time.step = 24)
fitting rw SSM to 1 tracks...
pars: 1.10021 1.46654 2.46752 1.95034 -0.46163 0.41839
Warning message: In sqrt(as.numeric(object$diag.cov.random)) : NaNs produced
And when I try to plot, I get this error (although type=1 plots fine)
plot(fit, what = "fitted", type = 2, ask = TRUE)##plots 2D
Error in FUN(X[[i]], ...) : !anyNA(x) is not TRUE
I kept increasing the subset. It fit the model for the first 100 rows, but for the first 1000 rows, it gave the same error as for the first 50 rows
Here's the subset of the first 50 rows.
Cleaned_GullTrackssubset2.csv
I checked and my animotum is the latest version, 1.2. I'm not sure what the problem is, and I'd appreciate your help.
Regards,
Esther
from animotum.
Hi Esther,
When running your data the correlated random walk seems to run fine, but not the random walk. I'm not sure why that would be @ianjonsen?
Could it be that time step is set to 24 hours when the example data frame spans less than 24 hours? This would result in aniMotum
trying to generate only one location from the data?
Your example data has a location on average every 15 minutes, and so setting time.step = .25
seems sensible.
Best,
James
require(tidyverse)
#> Loading required package: tidyverse
require(aniMotum)
#> Loading required package: aniMotum
#> The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
#> which was just loaded, will retire in October 2023.
#> Please refer to R-spatial evolution reports for details, especially
#> https://r-spatial.org/r/2023/05/15/evolution4.html.
#> It may be desirable to make the sf package available;
#> package maintainers should consider adding sf to Suggests:.
#> The sp package is now running under evolution status 2
#> (status 2 uses the sf package in place of rgdal)
#>
#> Attaching package: 'aniMotum'
#> The following object is masked from 'package:purrr':
#>
#> map
df <- read_csv("~/Downloads/Cleaned_GullTrackssubset2.csv")
#> Rows: 50 Columns: 5
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (1): lc
#> dbl (3): id, lon, lat
#> dttm (1): date
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
df |> summarise(interval = mean(difftime(date, lag(date)), na.rm = T))
#> # A tibble: 1 × 1
#> interval
#> <drtn>
#> 1 15.00578 mins
fit <- fit_ssm(df, model = "crw", time.step = .25)
#> fitting crw SSM to 1 tracks...
#> pars: 0 0 0 0 pars: 0.65492 0.58628 0.41856 0.2284 pars: 0.65702 1.22032 1.18098 0.35766 pars: -0.31006 2.70153 2.04332 0.82648 pars: 0.22062 2.2577 3.92804 1.07518 pars: -0.05075 2.48466 2.96426 0.948 pars: 0.03115 2.3236 2.79494 1.90501 pars: 0.20592 2.5047 2.41912 2.78398 pars: 1.13183 2.42618 2.34409 2.63158 pars: 2.04353 2.36026 2.15319 2.95591 pars: 1.84063 2.446 2.31948 3.66558 pars: 1.99794 2.54114 2.39723 4.87055 pars: 2.16676 2.57425 2.39979 5.84701 pars: 2.02625 2.58376 2.46564 7 pars: 2.11117 2.53943 2.3937 7 pars: 2.11117 2.53943 2.3937 7
plot(fit)
#> $`211696`
Created on 2024-01-12 with reprex v2.0.2
from animotum.
@enosazeogie, as @jamesgrecian shows, the issues you have been getting are not aniMotum
code issues they are likely due to unfortunate time.step
choices. The best advice I can provide is to try to understand your data by plotting & summarizing (e.g., as @jamesgrecian did) BEFORE you try to fit models to the data! I remind myself to do this almost daily! I am happy to help you overcome issues using aniMotum
but this thread is better placed in Discussions, so I'm moving it there.
Best, Ian
from animotum.
Related Issues (20)
- unknown error code when fitting SSM HOT 5
- Error in FUN(X[[i]], ...) : !anyNA(x) is not TRUE HOT 2
- Addressing data gaps HOT 1
- Error loading `foieGras` for M1/M2 chip macs HOT 2
- min.dt likely not working as intended HOT 13
- map fit_ssm HOT 1
- when none of the input locations from any of the tracks are on land, route_path fails HOT 1
- installation and library(aniMotum) on M2 MBP HOT 4
- Package `foieGras` archived on CRAN and will be removed from the Tracking CTV HOT 1
- error with map function HOT 1
- When running function fit_ssm : Error in MakeADFun. Is someone familiar? HOT 2
- errors when running fit_ssm in animotum HOT 8
- Issue in installing foieGras package in RStudio HOT 3
- not sure if bug or system issue HOT 3
- Error with sim_fit() using different gradient raster HOT 9
- rep$pdHess : $ operator is invalid for atomic vector — Error when fitting ssm HOT 9
- Error in strsplit(names(map), "_") : non-character argument HOT 1
- osar function not finishing the run HOT 2
- Date/time variable not detected in data HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from animotum.