Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dht2 does not understand uniform key function models #151

Open
erex opened this issue Jan 16, 2023 · 2 comments
Open

dht2 does not understand uniform key function models #151

erex opened this issue Jan 16, 2023 · 2 comments
Assignees
Labels

Comments

@erex
Copy link
Member

erex commented Jan 16, 2023

Highlighted by workshop participant (working with dung surveys over short distances). dht2 fails with uninterpretable error message when handed a "fitted" uniform function.

MRE:

library(Distance)
data(ducknest)
units <- convert_units(ducknest_units$Units[2],
                       ducknest_units$Units[1],
                       ducknest_units$Units[3])
uni <- ds(ducknest, key="unif",
          convert_units = units,
          truncation = 2)
hn <-  ds(ducknest, key="hn",
          convert_units = units,
          truncation = 2)
gof_ds(uni)
gof_ds(hn)
trouble <- dht2(uni, flatfile=ducknest,
                convert_units = units,
                strat_formula = ~Region.Label)
notrouble <- dht2(hn, flatfile=ducknest,
                convert_units = units,
                strat_formula = ~Region.Label)

dht2 failure for uniform model

Error in abs(x) : non-numeric argument to mathematical function

generated by this line of code

df_unc <- lapply(ddf, varNhat, data = res)

but quite happy with the half normal model.

@erex
Copy link
Member Author

erex commented Jan 24, 2023

supplement:

the above lapply function is calling varNhat. Suspect the problem is in varNhat which on this line is looking for the Hessian of the fitted model to get some variance bits-and-pieces.

There won't be a Hessian when the detection function is uniform without adjustments.

@LHMarshall
Copy link
Member

LHMarshall commented Apr 29, 2024

as Eric pointed out above in the varNhat function line 50 fails as there is no hessian matrix

>   vcov <- solvecov(model$hessian)$inv
Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x),  : 
  'data' must be of a vector type, was 'NULL'

> model$hessian
NULL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants