GithubHelp home page GithubHelp logo

Comments (12)

ianjonsen avatar ianjonsen commented on June 20, 2024

Thanks for the suggestion. Allowing simultaneous fit to Argos and GPS locations is planned for the next update. Until that update is available you can force it by merging the locations, ensuring they are in chronological order, and for the GPS obs - setting lc = 3 and smaj, smin, eor all to NA. If your Argos data are KF, the model will use the error ellipse info for these observations and treat the GPS as though they are LS with lc = 3.

from animotum.

hallegue avatar hallegue commented on June 20, 2024

Ok thanks!
Do you know what value should I set the error ellipse for gps locs?

from animotum.

ianjonsen avatar ianjonsen commented on June 20, 2024

The error ellipse parameters: smaj, smin, eor should all be set to NA. Your input data should look like this:

id, date, lc, lon, lat, smaj, smin, eor
1, 2020-03-25 14:14:50, A, 67.5670, -65.3424, 12030.01, 1345.53, 45
1, 2020-03-25 14:18:34, 3, 64.5521, -65.4435, NA, NA, NA

where the 1st record is an Argos KF observation and the 2nd is GPS

from animotum.

hallegue avatar hallegue commented on June 20, 2024

Ok thanks!

from animotum.

ianjonsen avatar ianjonsen commented on June 20, 2024

An alternative approach is now available - you can merge your Argos & GPS data in a single data.frame/tibble and set lc = "G" for GPS locations. This will scale GPS location errors SD's so they are 0.1 x Argos lc 3, ie. 10 x more precise. See this issue for additional details: #15

from animotum.

hallegue avatar hallegue commented on June 20, 2024

Great! Thanks Ian!

from animotum.

ianjonsen avatar ianjonsen commented on June 20, 2024

I should have also mentioned that to get it, you'll have to install the dev version of foieGras:

remotes::install_github("ianjonsen/foieGras@dev")

from animotum.

hallegue avatar hallegue commented on June 20, 2024

Unfortunatly, it is not working for me. I run the function as:

fit <- foieGras::fit_ssm(d = as.data.frame(dt_loc), time.step = 24, model = "rw", verbose = 1)

And I've got this error:

Warning in prefilter(., vmax = vmax, ang = ang, distlim = distlim, spdf = spdf,  :
  
argosfilter::sdafilter produced an error on id F02-B-17 using argosfilter::vmask instead
|================================================================================================================|100% ~0 s remaining     
fitting SSM...
Error in optim(par = c(l_sigma = 1.43100513556006, l_sigma = 1.00770773184277,  : 
  L-BFGS-B needs finite values of 'fn'
In addition: Warning message:
In if (pls == 0 & unique(d$obs.type) == "GL") { :
  the condition has length > 1 and only the first element will be used
Error in optimHess(par.fixed, obj$fn, obj$gr) : 
  gradient in optim evaluated to length 1 not 7```

Here my session info:

```Session info ----------------------------------------------------------------------------
 setting  value                       
 version  R version 3.6.3 (2020-02-29)
 os       Windows 10 x64              
 system   x86_64, mingw32             
 ui       RStudio                     
 language (EN)                        
 collate  English_United States.1252  
 ctype    English_United States.1252  
 tz       America/New_York            
 date     2020-04-02                  

Packages -------------------------------------------------------------------------------
 ! package     * version  date       lib source                             
   argosfilter   0.63     2012-11-01 [1] CRAN (R 3.5.2)                     
   assertthat    0.2.1    2019-03-21 [1] CRAN (R 3.5.3)                     
   backports     1.1.5    2019-10-02 [1] CRAN (R 3.6.1)                     
   callr         3.4.3    2020-03-28 [1] CRAN (R 3.6.3)                     
   class         7.3-16   2020-03-25 [1] CRAN (R 3.6.3)                     
   classInt      0.4-2    2019-10-17 [1] CRAN (R 3.6.3)                     
   cli           2.0.2    2020-02-28 [1] CRAN (R 3.6.3)                     
   codetools     0.2-16   2018-12-24 [1] CRAN (R 3.6.2)                     
   colorspace    1.4-1    2019-03-18 [1] CRAN (R 3.6.1)                     
   crayon        1.3.4    2017-09-16 [1] CRAN (R 3.6.2)                     
   DBI           1.1.0    2019-12-15 [1] CRAN (R 3.6.2)                     
   desc          1.2.0    2018-05-01 [1] CRAN (R 3.5.3)                     
   devtools      2.2.2    2020-02-17 [1] CRAN (R 3.6.3)                     
   digest        0.6.25   2020-02-23 [1] CRAN (R 3.6.3)                     
   dplyr         0.8.5    2020-03-07 [1] CRAN (R 3.6.3)                     
   e1071         1.7-3    2019-11-26 [1] CRAN (R 3.6.3)                     
   ellipsis      0.3.0    2019-09-20 [1] CRAN (R 3.6.3)                     
   fansi         0.4.1    2020-01-08 [1] CRAN (R 3.6.3)                     
   foieGras    * 0.4.01-3 2020-04-01 [1] Github (ianjonsen/foieGras@35f87db)
   fs            1.4.0    2020-03-31 [1] CRAN (R 3.6.3)                     
   furrr         0.1.0    2018-05-16 [1] CRAN (R 3.6.2)                     
   future        1.16.0   2020-01-16 [1] CRAN (R 3.6.3)                     
   ggplot2       3.3.0    2020-03-05 [1] CRAN (R 3.6.3)                     
   globals       0.12.5   2019-12-07 [1] CRAN (R 3.6.1)                     
   glue          1.3.2    2020-03-12 [1] CRAN (R 3.6.3)                     
   gridExtra     2.3      2017-09-09 [1] CRAN (R 3.6.1)                     
   gtable        0.3.0    2019-03-25 [1] CRAN (R 3.5.3)                     
   KernSmooth    2.23-16  2019-10-15 [2] CRAN (R 3.6.3)                     
   lattice       0.20-40  2020-02-19 [1] CRAN (R 3.6.3)                     
   lifecycle     0.2.0    2020-03-06 [1] CRAN (R 3.6.3)                     
   listenv       0.8.0    2019-12-05 [1] CRAN (R 3.6.3)                     
   lubridate     1.7.4    2018-04-11 [1] CRAN (R 3.5.3)                     
   magrittr      1.5      2014-11-22 [1] CRAN (R 3.2.1)                     
   Matrix        1.2-18   2019-11-27 [1] CRAN (R 3.6.2)                     
   memoise       1.1.0    2017-04-21 [1] CRAN (R 3.6.2)                     
   munsell       0.5.0    2018-06-12 [1] CRAN (R 3.5.3)                     
   packrat       0.5.0-20 2019-08-12 [1] Github (rstudio/packrat@8f93e07)   
   pillar        1.4.3    2019-12-20 [1] CRAN (R 3.6.3)                     
   pkgbuild      1.0.6    2019-10-09 [1] CRAN (R 3.6.3)                     
   pkgconfig     2.0.3    2019-09-22 [1] CRAN (R 3.6.3)                     
   pkgload       1.0.2    2018-10-29 [1] CRAN (R 3.6.3)                     
   prettyunits   1.1.1    2020-01-24 [1] CRAN (R 3.6.3)                     
   processx      3.4.2    2020-02-09 [1] CRAN (R 3.6.3)                     
   ps            1.3.2    2020-02-13 [1] CRAN (R 3.6.3)                     
   purrr         0.3.3    2019-10-18 [1] CRAN (R 3.6.1)                     
   R6            2.4.1    2019-11-12 [1] CRAN (R 3.6.3)                     
   Rcpp          1.0.4    2020-03-17 [1] CRAN (R 3.6.3)                     
   remotes       2.1.1    2020-02-15 [1] CRAN (R 3.6.2)                     
   renv          0.9.3-40 2020-02-27 [1] Github (rstudio/renv@6d6e79d)      
   rlang         0.4.5    2020-03-01 [1] CRAN (R 3.6.3)                     
   rprojroot     1.3-2    2018-01-03 [1] CRAN (R 3.5.3)                     
   rstudioapi    0.11     2020-02-07 [1] CRAN (R 3.6.3)                     
   scales        1.1.0    2019-11-18 [1] CRAN (R 3.6.3)                     
   sessioninfo   1.1.1    2018-11-05 [1] CRAN (R 3.6.3)                     
   sf            0.9-0    2020-03-24 [1] CRAN (R 3.6.3)                     
   stringi       1.4.6    2020-02-17 [1] CRAN (R 3.6.2)                     
   stringr       1.4.0    2019-02-10 [1] CRAN (R 3.6.1)                     
   testthat      2.3.2    2020-03-02 [1] CRAN (R 3.6.3)                     
   tibble        3.0.0    2020-03-30 [1] CRAN (R 3.6.3)                     
   tidyr         1.0.2    2020-01-24 [1] CRAN (R 3.6.3)                     
   tidyselect    1.0.0    2020-01-27 [1] CRAN (R 3.6.3)                     
 D TMB         * 1.7.16   2020-01-15 [1] CRAN (R 3.6.3)                     
   units         0.6-6    2020-03-16 [1] CRAN (R 3.6.3)                     
   usethis       1.5.1    2019-07-04 [1] CRAN (R 3.6.3)                     
   vctrs         0.2.4    2020-03-10 [1] CRAN (R 3.6.3)                     
   withr         2.1.2    2018-03-15 [1] CRAN (R 3.5.3)                     

[1] D:/Dropbox/PhD_encrypted/Analysis/RCode/renv/library/R-3.6/x86_64-w64-mingw32
[2] C:/Users/HASSEN/AppData/Local/Temp/RtmpiWShqx/renv-system-library

 D -- DLL MD5 mismatch, broken installation.```

from animotum.

ianjonsen avatar ianjonsen commented on June 20, 2024

can you provide a small, reproducible example with data?

from animotum.

hallegue avatar hallegue commented on June 20, 2024

OK so here some examples.

First, the data of one seal that has Argos and GPS data.

data_with_gps.txt

library("data.table")
library("lubridate")
  
dt  <- fread("data_with_gps.txt")[ , date := ymd_hms(date)]
fit <- foieGras::fit_ssm(d = as.data.frame(dt), time.step = 24, model = "rw")

This produces the following error (I don't have the error when I remove GPS locs):

Error in optim(par = c(l_sigma = 1.43357604261648, l_sigma = 0.986834461297878,  : 
  L-BFGS-B needs finite values of 'fn'
In addition: Warning message:
In if (pls == 0 & unique(d$obs.type) == "GL") { :
  the condition has length > 1 and only the first element will be used
Error in optimHess(par.fixed, obj$fn, obj$gr) : 
  gradient in optim evaluated to length 1 not 4

Also, I have an error when I fit the locs of some other seals with only Argos locs. See this example:

data_Argos_original.txt

dt  <- fread("data_Argos_original.txt")[ , date := ymd_hms(date)]
fit <- foieGras::fit_ssm(d = as.data.frame(dt), time.step = 24, model = "rw")

Which produces this error:

Error in optim(par = c(l_sigma = 1.63245784700661, l_sigma = 1.7665791112546,  : 
  L-BFGS-B needs finite values of 'fn'
In addition: Warning message:
In if (pls == 0 & unique(d$obs.type) == "GL") { :
  the condition has length > 1 and only the first element will be used

I noticed that this error could emerge when smaj, smin or eor is 0. Therefore, when this is the case instead of just removing the locs, I set the value of smaj, smin and eor to NA so it treats them as LS data. But I still have the same error:

data_Argos_modified.txt

dt  <- fread("data_Argos_modified.txt")[ , date := ymd_hms(date)]
fit <- foieGras::fit_ssm(d = as.data.frame(dt), time.step = 24, model = "rw")
Error in optim(par = c(l_sigma = 1.63245784700661, l_sigma = 1.7665791112546,  : 
  L-BFGS-B needs finite values of 'fn'
In addition: Warning message:
In if (pls == 0 & unique(d$obs.type) == "GL") { :
  the condition has length > 1 and only the first element will be used

from animotum.

ianjonsen avatar ianjonsen commented on June 20, 2024

Hassen, your examples now work. Note, errors in the latter 2 examples were optimizer crashes due to one or more more extreme observations that weren't being flagged by prefilter. This was because the default vmax = 50 m/s was used. I've changed the default to 10 m/s but it's a good habit to specify vmax yourself in the call to fit_ssm, eg:

fit <- foieGras::fit_ssm(d = as.data.frame(dt), vmax = 5, time.step = 24, model = "rw")

from animotum.

hallegue avatar hallegue commented on June 20, 2024

Ok thanks!

from animotum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.