Comments (9)
SOLVED: Thanks for the reply. I am running the same versions as you. Turns out after some digging it was TMB
requiring the package Matrix
, and version Matrix_1.6-5
in particular. Got there in the end. Could be edges cases, but maybe add Matrix
as a dependency when you next update? Thanks again
from animotum.
Hi @sharkcatch and @tmillac here is a link to help get you started with producing reproducible examples: https://reprex.tidyverse.org
from animotum.
Hi, can you provide a reproducible example - code AND data? Failing that, try adding the following argument to fit_ssm()
- this will turn off estimation of the observation error correlation parameter:
map = list(rho_o = factor(NA))
this often helps when fitting to GPS data, but I’m just guessing without a reproducible example.
Ian
from animotum.
Apologies, will this work?
Data:
> glimpse(df)
Rows: 29
Columns: 4
$ id <dbl> 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 200…
$ date <dttm> 2021-02-05 05:57:36, 2021-02-05 11:03:06, 2021-02-10 03:54:11, 2021-02-11 16:10:34, 20…
$ lon <dbl> 170.9615, 170.9776, 170.8871, 171.1078, 171.2163, 171.2587, 171.2142, 171.0744, 171.109…
$ lat <dbl> -38.16957, -38.20939, -38.18083, -38.09306, -38.09743, -38.04951, -38.01200, -38.03030,…
Code:
fit_df <-
fit_ssm(df, # Filtered to just look at one tag
model = "mp", # Move persistence state space model
time.step = 6, # Six hour time step
spdf = TRUE,
control = ssm_control(verbose = 0))
I tried your previous suggestion but get the following error:
> fit_df <-
+ fit_ssm(df, # Filtered to just look at one tag
+ model = "mp", # Move persistence state space model
+ time.step = 6, # Six hour time step
+ spdf = TRUE,
+ map = list(rho_o = factor(NA),
+ control = ssm_control(verbose = 0)))
Guessing that all observations are GPS locations.
fitting mp SSM to 1 tracks...
Error in MakeADFun(data, parameters, map = map, random = rnd, hessian = TRUE, :
Names in map must correspond to parameter names
from animotum.
Unfortunately, I can’t access your data that way - glimpse just gives a condensed summary of your data. Easiest would be to use write.csv()
to write your data to a .csv file and attach it to your comment using the Paperclip icon - provided your .csv file is not 100’s of Mb.
The error you received when running that code was due to a missing bracket, your fit_ssm()
call should be:
fit_ssm(df, # Filtered to just look at one tag
model = "mp", # Move persistence state space model
time.step = 6, # Six hour time step
spdf = TRUE,
map = list(rho_o = factor(NA)),
control = ssm_control(verbose = 0))
from animotum.
Hopefully this works! Whoops on the bracket, analysis works with that addition thanks.
from animotum.
Hi Ian
I am getting the same error code running fit_ssm using an 'mp' model. Below is the code I have used but I have also tried the additional code line map = list(rho_o = factor(NA)), as you suggested above
I have attached some of my data.
fit <- fit_ssm(locs, vmax = 3, model = "mp", time.step = 24, control = ssm_control(verbose = 0))
Error in rep$pdHess : $ operator is invalid for atomic vectors
Thank you for your help.
from animotum.
Posting here on behalf and it appears @sharkcatch is the OP of the issue that I am raising here. A repex:
df <- structure(list(id = c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L), date = structure(c(1458088599, 1458088599,
1458088599, 1458118100, 1458143894, 1458197040, 1458413604, 1470885420,
1470885420, 1470885420, 1461019843, 1461026270, 1461026270, 1461469583,
1461469583, 1461469583, 1461469583, 1460269560, 1460269560, 1460269560,
1460269560, 1460269560, 1460269560, 1460269560, 1460278320, 1460418060,
1460418060, 1460418060, 1460467980, 1460467980, 1460467980, 1460671891,
1460671891, 1460841188, 1460841188, 1460841188, 1460841188, 1460870005,
1460949186, 1461016210, 1461016210, 1461016210, 1461016210, 1461016210,
1461016210, 1461016210, 1461016210, 1461016210, 1461016210, 1461469583,
1461469583, 1461469583, 1461469583, 1461469583, 1461469583, 1461469583,
1461469583, 1461469583, 1462979940, 1462952040, 1462952040, 1462952040,
1462952040), class = c("POSIXct", "POSIXt"), tzone = "UTC"),
lc = c("A", "A", "A", "B", "B", "B", "B", "1", "1", "1",
"B", "B", "B", "3", "3", "3", "3", "2", "2", "2", "2", "2",
"2", "2", "B", "A", "A", "A", "A", "A", "A", "B", "B", "0",
"0", "0", "0", "B", "B", "3", "3", "3", "3", "3", "3", "3",
"3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3",
"B", "1", "1", "1", "1"), latitude = c(-31.50391, -31.50391,
-31.50391, -39.82062, -39.93783, -40.0844, -41.0345, -25.46735,
-25.46735, -25.46735, -40.23962, -40.20943, -40.20943, -40.43101,
-40.43101, -40.43101, -40.43101, -40.57273, -40.57273, -40.57273,
-40.57273, -40.57273, -40.57273, -40.57273, -40.58898, -40.60004,
-40.60004, -40.60004, -40.53807, -40.53807, -40.53807, -40.5596,
-40.5596, -40.30304, -40.30304, -40.30304, -40.30304, -40.30302,
-40.35905, -40.2418, -40.2418, -40.2418, -40.2418, -40.2418,
-40.2418, -40.2418, -40.2418, -40.2418, -40.2418, -40.43101,
-40.43101, -40.43101, -40.43101, -40.43101, -40.43101, -40.43101,
-40.43101, -40.43101, -40.58412, -40.5991, -40.5991, -40.5991,
-40.5991), longitude = c(106.90178, 106.90178, 106.90178,
146.76394, 146.81515, 146.89076, 148.13549, 153.41662, 153.41662,
153.41662, 147.57244, 147.56543, 147.56543, 147.94571, 147.94571,
147.94571, 147.94571, 148.41413, 148.41413, 148.41413, 148.41413,
148.41413, 148.41413, 148.41413, 148.4267, 148.32712, 148.32712,
148.32712, 148.3033, 148.3033, 148.3033, 148.37321, 148.37321,
147.74462, 147.74462, 147.74462, 147.74462, 147.72642, 147.66374,
147.57622, 147.57622, 147.57622, 147.57622, 147.57622, 147.57622,
147.57622, 147.57622, 147.57622, 147.57622, 147.94571, 147.94571,
147.94571, 147.94571, 147.94571, 147.94571, 147.94571, 147.94571,
147.94571, 148.49763, 148.50535, 148.50535, 148.50535, 148.50535
)), row.names = c(NA, -63L), class = "data.frame")
Pre-model, NOTE that the cols were called longitude" and "latitude" prior to running this line, and they get converted to "lon" and "lat" after running this line:
df <- format_data(df, date = "date", coord = c("longitude", "latitude"))
The model:
fit <- fit_ssm(df,
vmax = 3,
model = "mp",
time.step = 24,
control = ssm_control(verbose = 0))
The error:
Error in rep$pdHess : $ operator is invalid for atomic vectors
As per your suggestion, I also tried:
fit <- fit_ssm(df,
vmax = 3,
model = "mp",
time.step = 24,
spdf = TRUE,
map = list(rho_o = factor(NA)),
control = ssm_control(verbose = 0))
but I get the same error.
If I convert the lon lat columns to EPSG:3857 the aforementioned error does not persist, but I get this:
Warning in pf_sda_filter(x, spdf, vmax, ang, distlim) :
trip::sda produced an error on id 3 using trip::speedfilter instead
Error in approx(x = select(d, date, x), xout = d.all$date, rule = 2) :
need at least two non-NA values to interpolate
I also tried with the projected data without running format_data()
but still not working.
from animotum.
Thank you for the reprex. Unfortunately, I can't reproduce your error so that makes me wonder what version of aniMotum
and TMB
you are using? The latest aniMotum
version is 1.2-03
.
Running aniMotum 1.2-03
& TMB 1.9.10
with R 4.3.2
on MacOS:
fit <- fit_ssm(df,
vmax = 3,
model = "mp",
time.step = 24, control = ssm_control(verbose = 0))
I get the following warning:
Warning messages:
1: In sqrt(as.numeric(object$diag.cov.random)) : NaNs produced
2: Hessian was not positive-definite so some standard errors could not be calculated.
This indicates that SE's could not be calculated for some model parameters and/or random variables. In this case, the model parameters all have SE's, though rho_p
is close to -1 and its SE is very small which is suggestive of an issue estimating the bivariate process errors that describe variability in the movements:
summary(fit)
Animal id Model Time n.obs n.filt n.fit n.pred n.rr converged AICc
3 mp 24 63 45 18 150 . TRUE 522.3
print individual model parameter tables? [enter / esc to stop]
--------------
3
--------------
Parameter Estimate Std.Err
rho_p -0.9994 5e-04
sigma_x 81.6253 23.4401
sigma_y 20.7539 5.9069
rho_o -0.6713 1.9217
tau_x 0.1126 0.4798
tau_y 0.0661 0.1625
sigma_g 0.1136 0.0785
But looking at the fitted
location estimates, some SE's for the estimated x & y coordinates could not be calculated:
grab(fit, "f")
# A tibble: 18 × 11
id date lon lat x y x.se y.se logit_g logit_g.se g
<chr> <dttm> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 3 2016-03-16 00:36:39 107. -31.5 11900. -3676. 2.69 1.46 2.20 1.71 0.900
2 3 2016-03-16 08:48:20 147. -39.8 16338. -4813. NaN 1.90 2.20 1.44 0.900
3 3 2016-03-17 06:44:00 147. -40.1 16352. -4850. 3.38 2.03 -0.230 1.02 0.443
4 3 2016-03-19 18:53:24 148. -41.0 16490. -4989. 4.92 2.14 1.74 2.08 0.851
5 3 2016-04-10 06:26:00 148. -40.6 16521. -4922. 0.173 0.0852 1.58 3.92 0.829
6 3 2016-04-10 08:52:00 148. -40.6 16523. -4923. NaN NaN 1.58 3.91 0.829
7 3 2016-04-11 23:41:00 148. -40.6 16512. -4926. 2.69 1.45 1.41 3.80 0.804
8 3 2016-04-12 13:33:00 148. -40.5 16509. -4917. 2.69 1.45 1.44 3.62 0.808
9 3 2016-04-16 21:13:08 148. -40.3 16447. -4882. 1.54 0.985 1.28 3.40 0.783
10 3 2016-04-17 05:13:25 148. -40.3 16445. -4883. 1.82 1.76 1.28 3.37 0.783
11 3 2016-04-18 03:13:06 148. -40.4 16438. -4890. 2.66 1.94 1.30 2.97 0.785
12 3 2016-04-18 21:50:10 148. -40.2 16428. -4874. 0.113 0.0661 1.58 1.99 0.830
13 3 2016-04-18 22:50:43 148. -40.2 16427. -4872. NaN NaN 1.59 1.99 0.830
14 3 2016-04-19 00:37:50 148. -40.2 16427. -4870. NaN NaN 1.58 1.99 0.830
15 3 2016-04-24 03:46:23 148. -40.4 16469. -4901. 0.113 0.0661 1.57 4.19 0.828
16 3 2016-05-11 07:34:00 149. -40.6 16532. -4926. 0.419 0.169 3.41 8.00 0.968
17 3 2016-05-11 15:19:00 148. -40.6 16531. -4923. 4.98 2.14 3.42 8.00 0.968
18 3 2016-08-11 03:17:00 153. -25.5 17078. -2915. 0.419 0.169 6.06 19.0 0.998
This is an indication that there's an issue with the data, and a look at the model fit shows that the data are highly sporadic with huge data gaps relative to the 24-h prediction interval:
plot(fit, "p")
Highly sporadic data like this are far less than ideal for fitting any SSM and especially the mp
model because you are asking the model to do far too much interpolation of locations and this in turn affects the move persistence estimates. It's difficult to provide more informative error and warning messages, but I can try to improve them so that you get a better idea of why the model is not fitting as expected. As I've tried to show in this reply, some exploration of the data and model fit(s) usually help identify the problem.
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
- Error in if (p.GL > 0.75) { : missing value where TRUE/FALSE needed HOT 5
- not sure if bug or system issue HOT 3
- Error with sim_fit() using different gradient raster 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.