DistanceDevelopment / dsims

New simulation R library
1 stars 2 forks source link

Perhaps a warning when region objects differ between 'make.design' and 'make.population.description` #88

Open erex opened 10 months ago

erex commented 10 months ago

I created a study region of non-default dimensions:

area <- 1300000 # Table 12 of GRAM report
side1 <- 1000
side2 <- area/side1
outer <- matrix(c(0,0,side1,0,side1,side2,0,side2,0,0),ncol=2, byrow=TRUE)
mp1 <- sf::st_polygon(list(outer))
risso.region <- make.region(shape=mp1, units = "km")

I used risso.region to specify the population description

pop.desc <- make.population.description(region = risso.region,
                                        density = make.density(region=risso.region),
                                        covariates = covariate.list, 
                                        N=groups.studyarea)

However, I failed to specify risso.region when calling make.design

transects <- make.design(samplers=12, truncation=trunc.ship)

The resulting mismatch caused half of the transects to fall within a region where there were animals and the other half of the transects falling in a region without animals. Because I had not specified plot(size.cov.survey) to visualise this problem, I stupidly ran hundreds of simulations producing poor precision in my estimates because of the crazed encounter rate variance I had induced.

Suggested code change

Perhaps somewhere in make.simulation there could be a check of the region object from make.population.description matches the region object used in the specification of make.design

lenthomas commented 10 months ago

Perhaps it could generate a warning if the region object does not match? That way the user could still proceed if they have some good reason for a mis-matched population and design region? (I can't think of a reason offhand, but I'm sure there are some!...)

LHMarshall commented 10 months ago

I have it on my todo list to re-assess the validation function for Simulation creation. I will do this at the same time as #76