Error in if (p.GL > 0.75) { : missing value where TRUE/FALSE needed #52
Replies: 7 comments 2 replies
-
Hi Esther, When using 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 |
Beta Was this translation helpful? Give feedback.
-
Hi James,
I appreciate your help. I've been able to fit the model.
Regards,
Esther
…On Mon, Jan 8, 2024 at 4:29 AM James Grecian ***@***.***> wrote:
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`
<https://camo.githubusercontent.com/221edbda2ce5f505ad71749ca85fc760583d196d15a8d35f2c4a209d2019fc14/68747470733a2f2f692e696d6775722e636f6d2f4638643462426b2e706e67>
Created on 2024-01-08 with reprex v2.0.2 <https://reprex.tidyverse.org>
—
Reply to this email directly, view it on GitHub
<#49 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A5L4JKWSYFZQSYAHZBEB253YNO37HAVCNFSM6AAAAABBO6L7ECVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBQGY2DGOBSG4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
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:
I tried this
Error in optimHess(par.fixed, obj$fn, obj$gr) : So I did a subset of the first 50 rows and I got this:
And when I try to plot, I get this error (although type=1 plots fine)
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. 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, |
Beta Was this translation helpful? Give feedback.
-
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 Your example data has a location on average every 15 minutes, and so setting 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 |
Beta Was this translation helpful? Give feedback.
-
@enosazeogie, as @jamesgrecian shows, the issues you have been getting are not Best, Ian |
Beta Was this translation helpful? Give feedback.
-
Thank you for your help, @jamesgrecian and @ianjonsen. I'm still getting this error, even though I have tried several changes to the code including those you suggested. Considering the first error, I was wondering if there may be an issue with the "control" argument.
Error in optimHess(par.fixed, obj$fn, obj$gr) :
|
Beta Was this translation helpful? Give feedback.
-
Thank you, Ian. That worked. I had previously cleaned out the NAs and duplicates in the latitude, longitude, and time columns, but it turns out there was one sneaky NA in the device ID column which I didn't anticipate. After it took it out, the model ran okay. I appreciate your help. Regards, |
Beta Was this translation helpful? Give feedback.
-
Hi Ian,
I'm trying to fit the SSM model to my GPS tracking data (for a seabird species) but I keep getting this error:
Error in if (p.GL > 0.75) { : missing value where TRUE/FALSE needed
I'm not sure what argument I'm not supplying
Here's a subset of my data:
Cleaned_GullTrackssubset.csv
df <- read.csv("Cleaned_GullTrackssubset.csv", row.names = FALSE)
I have tried various iterations of the arguments:
fitRw <- fit_ssm(df, model = "rw", time.step = NA)
fitCrw<- fit_ssm(df, model = "crw", time.step = NA)
fitMp <- fit_ssm(df, vmax = 5, model = "mp", time.step = NA,
control = ssm_control(verbose = 1))
I even tried to force the data into the right format, but still getting that error
d <- format_data(df, date = "date", coord = c("lon","lat"),
tz = "UTC")
fit <- fit_ssm(d, model = "crw", time.step = 24)
Could you please help me with figuring out what the problem is?
Thank you,
Esther
Beta Was this translation helpful? Give feedback.
All reactions