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

Problem with edr matrix.... #3

Open
A-Drake opened this issue Mar 8, 2020 · 9 comments
Open

Problem with edr matrix.... #3

A-Drake opened this issue Mar 8, 2020 · 9 comments

Comments

@A-Drake
Copy link

A-Drake commented Mar 8, 2020

I'm experiencing an issue with the localBAMcorrections function in QPAD version 3. It seems to be related to incorporating LCC values into the detection probability (q). The error references "Xr" and occurs only when the edr model specified is >1. It does not occur for model.edr=2 in QPAD version 2.

Update: It seems to be a leveling issue within the LCC variable - either unrecognized categories or missing levels, I was still getting errors in version 2 for my own data until I added empty factor levels so that levels 1-5 were present; I'm still having issues in version 3...

For example, using the ovenbird data (with LCC and pforest derived as in the supplement of Solymos et al. 2013):

bm <- bestmodelBAMspecies("OVEN", type = "BIC")
bc <- with(oven, localBAMcorrections("OVEN", t = dur, r = dist,
jday = JDAY, tssr = TSSR, tree = pforest, lcc = LCC, model.sra = bm$sra,
model.edr = bm$edr))

#Error in Xr %*% coefBAMspecies(species, model.sra, model.edr)$edr : requires
numeric/complex matrix/vector arguments

@psolymos
Copy link
Member

psolymos commented Mar 9, 2020

@A-Drake : the issue might be that some of the functions haven't been updated to v3 of the estimates where the land cover layer has changed from the Canadian to North American, along with the factor levels.

You can find and updated script that I am now working on here:
https://github.com/ABbiodiversity/recurring/blob/master/offset/index.R

I will check the functions so that these at least give a reasonable error message.

@northernbio
Copy link

northernbio commented Dec 21, 2020

Hi Peter. I am having a similar issue as A-Drake. If I use the bestmodel (bm$edr), which for the oven dataset is EDR 3, I get the xR error, however if I explicitly set the EDR model to 0 or 1, the function works. Do I need to make changes to the oven data set to make it compatible to with the North American landcover? If so, is there a URL pointing to example data.
#Error in Xr %*% coefBAMspecies(species, model.sra, model.edr)$edr : requires
numeric/complex matrix/vector arguments

#code snippets based on QPAD_SupportingInfo.pdf
QPAD::load_BAM_QPAD(version = 3)
bm <- bestmodelBAMspecies("OVEN", type = "BIC")
#With QPAD Version 3, only edr models 0 or 1 work.  
bc <- with(oven, localBAMcorrections("OVEN", r = dist, t = dur,
                jday = JDAY, tssr = TSSR, tree = pforest, lcc = LCC, model.sra = bm$sra,
                model.edr = 1))

@psolymos
Copy link
Member

Can you please use do the following and report back here what R prints out?

  • traceback()
  • class(LCC);table(LCC)

@northernbio
Copy link

northernbio commented Dec 21, 2020 via email

@psolymos
Copy link
Member

psolymos commented Jan 4, 2021

@A-Drake @northernbio : I looked at the example, and the problem is with the QPAD functions not quite supporting v3 of the estimates. I found the package's functionality quite restrictive in the sense that user needed to ensure that the correct spatial layers are used etc. This was troublesome, so I wrote some scripts that circumvent that.

See https://github.com/ABbiodiversity/recurring/blob/master/offset/README.md for worked example.

Hope this helps.

@northernbio
Copy link

northernbio commented Jan 4, 2021 via email

@northernbio
Copy link

The example code worked for me, so I appreciate the scripts! A couple of questions: Are the example tif files (e.g. LCC.tif) in a Lambert projection, or are they Geographic (Lat/Long)? In QGIS it says undefined CRS, but the coordinate values seem to be Lambert.

Is it possible to mix raster resolutions? The 1 km^2 resolution for the LCC.tif seems a bit coarse, so I was wondering if a finer resolution landcover map (say 30 m) could be used instead. My study area is relatively small.

@psolymos
Copy link
Member

psolymos commented Jan 5, 2021

@northernbio the lat/long is tranformed into Lambert conical (as the raster crs indicates).

You can use a different resolution but same projection and replace the raster, it should work. You can get the projection as PROJ4 string by proj4string(raster_name).

@northernbio
Copy link

northernbio commented Jan 6, 2021 via email

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

No branches or pull requests

3 participants