Skip to content

seemingly strange behavior from customPSE()  #47

@jamisbruening

Description

@jamisbruening

I think I'm seeing some odd behavior from customPSE() when making area:area ratio estimates using a spatial mask to define the areal estimation boundaries.  If I use a mask that crosses state boundaries, customPSE() seems to return a different estimate made from the CONDs in different states, rather than an estimate for the entire area.  This doesn't happen when I just calculate forested area using the area() function.  This also doesn't happen for all state boundaries, from what I can tell it's mainly for states in the SRS, and it doesn't seem to be related to year.  In this MRE there are different years associated with the two estimates returned from customPSE(), but in others instances the year has been the same. Apologies in advance if I'm doing something stupid. I'm using the devtools version of rFIA, which I reinstalled today to make sure its not a package versioning issue on my end.

MRE:

library(rFIA)
library(sf)
library(dplyr)

set.seed(54)

lon = c(-83, -82)
lat = c(38, 39)
Poly_Coord_df = data.frame(lon, lat)

poly = st_polygon(
  list(
    cbind(
      Poly_Coord_df$lon[c(1,2,2,1,1)], 
      Poly_Coord_df$lat[c(1,1,2,2,1)])
  )
) %>% st_sfc(crs=4326) %>% st_sf()


FIA <- readFIA('/Volumes/RESEARCH/rFIA/original_data', nCores=10, inMemory=T, states=c('WV','OH','KY')) 
fia <- clipFIA(FIA, mostRecent=T, mask=poly)

cl <- fia %>% area(landType='forest', condList=T, nCores=10) %>% 
  # generate dummy variable to use to estimate area with customPSE
  mutate(class = sample(0:1, size=n(), replace=T, prob=c(.6,.4)),
         # scale by prop_forest to estimate amount of forest land where class == 1
         class_scaled = class * PROP_FOREST)

prop_class <- customPSE(db = fia, x = cl, xVars = c(class_scaled), y = cl, yVars = c(PROP_FOREST)) 
prop_forest <- fia %>% area(landType='all', nCores = 1) 

prop_class
prop_forest

## make sure plots are located in different states
cl %>% inner_join(fia$PLOT) %>% pull(STATECD) %>% table()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions