Git Product home page Git Product logo

Comments (11)

ianjonsen avatar ianjonsen commented on September 27, 2024

Hi Paola,

In the joint move persistence model jmpm, the variance parameter for the random walk on γt is shared among individuals, which can lead to optimizer errors (like the one you've encountered) if the tracks being fit represent very different movement patterns. I don't think the different ranges in longitude should matter though.

You could explore this by iteratively removing individual tracks and re-fitting the jmpm, but as the mpm fits did not return errors then you can just go with these. In practice, the γt estimates should be similar.

Ian

from animotum.

paolagab avatar paolagab commented on September 27, 2024

Hi Ian,

Okay, I'll go with the mpm fits then. Thank you for the explanation and for your help!

Paola

from animotum.

dahliasan avatar dahliasan commented on September 27, 2024

Hi Ian,

I'm trying to fit_mpm on southern elephant seal tracks.

I also had the same problem as Paola when I fitted all the animals together in a jmpm so I tried fitting them 1 by 1 instead as an mpm. It worked for most but still had some individuals which failed to converge.

My code for e.g. one of the failed individuals

fit <- foieGras::fit_ssm(d3 %>% filter(id == 'mq4-Billie-00'),
                         vmax = 4,
                         map = list(psi = factor(NA)),
                         model = "crw",
                         time.step = 24)

fit_mpm(fit, what = "predicted", model = "mpm", control = mpm_control(verbose = 0))

and the output from the code above:

Error in nlminb(obj$par, ifelse(control$verbose == 1, myfn, obj$fn), obj$gr,  : 
  NA/NaN gradient evaluation

# A tibble: 1 × 4
  id            mpm            converged model
  <chr>         <named list>   <lgl>     <chr>
1 mq4-Billie-00 <try-errr [1]> FALSE     mpm  

When I check what's the try-errr[1] under the mpm column:

$`mq4-Billie-00`
[1] "Error in opt[[\"par\"]] : subscript out of bounds\n"
attr(,"class")
[1] "try-error"
attr(,"condition")
<simpleError in opt[["par"]]: subscript out of bounds>

Are there any possible solutions from this point? I've tried changing the pre-filtering vmax = 2 but didn't make a difference.

I'm also not familiar with how to tweak the mpm_control settings so any help is greatly appreciated!

from animotum.

ianjonsen avatar ianjonsen commented on September 27, 2024

Hi Dahlia,

I'd need to see the data, or a subset that produces the error to see if there's a solution.

Thanks, Ian

from animotum.

dahliasan avatar dahliasan commented on September 27, 2024

Hi Ian,

I wanted to try testing different vmax and timestep inputs into fit_ssm first as I realise they affect the model convergence for fit_mpm. I've settled at vmax = 4 and timestep = 4.

When I use a different vmax the individuals that failed to converge during the mpm step varies - so I'm wondering if using a different vmax only for problem individuals is advisable?

In any case I've attached the data for the problem seals.

ses_mpmfailed.rds.zip

Hi Dahlia,

I'd need to see the data, or a subset that produces the error to see if there's a solution.

Thanks, Ian

from animotum.

ianjonsen avatar ianjonsen commented on September 27, 2024

Sorry for delayed response, Dahlia. Using foieGras 1.0.0 (currently on GitHub only), I can get both the crw SSM and the jmpm to converge successfully when fitting to all 3 tracks and using vmax=4, time.step=4. However, I'd say the first individual's track is a bit too short to infer anything sensible with fit_mpm, and the 4-h time.step is probably too short for mpm inference (as per the figure below), a 6- or 12-h timestep would probably be more appropriate.

Rplot

from animotum.

dahliasan avatar dahliasan commented on September 27, 2024

Thanks Ian! Using v.1.0.0 and changing it to a 12h time step worked for every seal.

from animotum.

pictuswolf avatar pictuswolf commented on September 27, 2024

Hi
I am having a similar error when using the fit_ssm function, I just cant work out how to resolve...
I too am a newbie to R so any explicit code to help me resolve this would be appreciated

The code is as follows:

Account for location error at observed irregular time interval

fit_crw_fitted <- fit_ssm(dat2, vmax = 1, model = "crw", time.step = NA,
control = ssm_control(verbose = 1))
map = list(rho_o = factor(NA))

print(fit_crw_fitted)

Estimate 'true' locations on irregular sampling interval (by setting time.step = NA)

fit_crw_fitted <- fit_ssm(dat2, vmax = 1, model = "crw", time.step = NA,

  •                       control = ssm_control(verbose = 1))
    

fitting crw SSM to 2 tracks...
pars: 0 0 0 0 Error in nlminb(obj$par, ifelse(control$verbose == 1, myfn, obj$fn), obj$gr, :
NA/NaN gradient evaluation

pars: 0 0 0 0 Error in nlminb(obj$par, ifelse(control$verbose == 1, myfn, obj$fn), obj$gr, :
NA/NaN gradient evaluation
In addition: Warning message:
The optimiser failed. Try simplifying the model with the following argument:
map = list(rho_o = factor(NA))

Warning message:
The optimiser failed. Try simplifying the model with the following argument:
map = list(rho_o = factor(NA))

map = list(rho_o = factor(NA))

print(fit_crw_fitted)

A tibble: 2 × 5

id ssm converged pdHess pmodel

1 C5978 <ssm [7]> FALSE FALSE crw
2 C5979 <ssm [7]> FALSE FALSE crw

All_example.csv

from animotum.

ianjonsen avatar ianjonsen commented on September 27, 2024

Thanks for providing the output and All_example.csv file, but I'l need to see your code that goes from reading in All_example.csv through to generating dat2 - the data input to fit_ssm() in your above example.

from animotum.

pictuswolf avatar pictuswolf commented on September 27, 2024

from animotum.

ianjonsen avatar ianjonsen commented on September 27, 2024

Ok, I just need to see the structure of dat2 to help understand why you're getting convergence failures.

You attached All_example.csv to your previous msg, just save dat2 from R (e.g., write.csv(dat2, file = "dat2.csv")) and add a link to it in your next msg. That way I can try running your code on your data and see if I get the same (failed) result.

Failing that, you could just type dat2 in your R console and copy the first few lines (including column names) into this form. Then I can at least see if the data are structured properly. I suspect they're not and that's why you're getting the convergence failures.

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.