GithubHelp home page GithubHelp logo

allometric's Issues

nested lists in `model_specifications` are wrapped into a single list in `allometric_models`

See, e.g., montero_2005 models

[ins] r$> allometric_models %>% filter(country == "ES", genus == "Pinus", component == "foliage")
# A tibble: 3 x 13
  id       component measure country   region     family   genus species    model      pub_id       family_name covt_name pub_year
  <chr>    <chr>     <chr>   <list>    <list>     <chr>    <chr> <chr>      <list>     <chr>        <list>      <list>       <dbl>
1 d91bb101 foliage   biomass <chr [1]> <list [1]> Pinaceae Pinus pinea      <FxdEffcM> montero_2005 <chr [3]>   <chr [1]>     2005
2 cc9dca58 foliage   biomass <chr [1]> <list [1]> Pinaceae Pinus radiata    <FxdEffcM> montero_2005 <chr [3]>   <chr [1]>     2005
3 7b50b22c foliage   biomass <chr [1]> <list [1]> Pinaceae Pinus sylvestris <FxdEffcM> montero_2005 <chr [3]>   <chr [1]>     2005

[ins] r$> allometric_models %>% filter(country == "ES", genus == "Pinus", component == "foliage") %>% unnest_models("region")
# A tibble: 3 x 13
  id       component measure country   region    family   genus species    model      pub_id       family_name covt_name pub_year
  <chr>    <chr>     <chr>   <list>    <list>    <chr>    <chr> <chr>      <list>     <chr>        <list>      <list>       <dbl>
1 d91bb101 foliage   biomass <chr [1]> <chr [3]> Pinaceae Pinus pinea      <FxdEffcM> montero_2005 <chr [3]>   <chr [1]>     2005
2 cc9dca58 foliage   biomass <chr [1]> <chr [1]> Pinaceae Pinus radiata    <FxdEffcM> montero_2005 <chr [3]>   <chr [1]>     2005
3 7b50b22c foliage   biomass <chr [1]> <chr [2]> Pinaceae Pinus sylvestris <FxdEffcM> montero_2005 <chr [3]>   <chr [1]>     2005

Eleotério et al. (2019)

Provide a citation of the publication you want us to add.

@article{eleoterio2019aboveground,
  title={Aboveground biomass quantification and tree-level prediction models for the Brazilian subtropical Atlantic Forest},
  author={Eleot{\'e}rio, Jackson Roberto and Uller, Heitor Felippe and Zimermann Oliveira, Laio and Klitzke, Aline Renata and Fantini, Alfredo Celso and Vibrans, Alexander Christian},
  journal={Southern Forests: a Journal of Forest Science},
  volume={81},
  number={3},
  pages={261--271},
  year={2019},
  publisher={NISC (Pty) Ltd}
}

500 models

We should have >= 500 models before 1.0.0 release

Implement validity checks for ISO 3166-1 and 3166-2

If a region is defined, it must be matched with the corresponding country, otherwise it (ModelSet, AllometricModel) are invalid.

If a country is defined it must exist inside a database of ISO 3166-1 character codes, likewise for regions and ISO 3166-2.

Add Publication: Rustagi and Loveless (1990)

Provide a citation of the publication you want us to add.

@article{rustagi1991compatible,
  title={Compatible variable-form volume and stem-profile equations for Douglas-fir},
  author={Rustagi, Krishna P and Loveless Jr, Robert S},
  journal={Canadian journal of forest research},
  volume={21},
  number={2},
  pages={143--151},
  year={1991},
  publisher={NRC Research Press Ottawa, Canada}
}

Handle mixed effects models

Right now predict only takes a vector of parameters and a dataframe of covariates. For mixed effects models, the predict function will need a vector of y's for the target group as well.

Here is a sketch of some possibilities

# Just playing with the idea here...
setClass(
    'MixedEffectsModel',
    contains = 'ParametricModel'
)

setGeneric('predict', function(mod, covariates, ranefs) {
    # This leaves it up to the author to provide random effect estimates
    mod@predict_fn(mod@parameters, covariates, ranefs)
})

# Alternatively we just provide a ... to predict for ParametricModel, the
# structure of ranefs is not always the same, and maybe this is the most
# general way to allow for it. Ranefs are functions of the parameters, covariates
# *and* observations within the target grouping...so a user would need to 
# at least provide those observations, or predict the random effects themselves
# using the model. The ranefs can enter non-linearly

Make Montero branch diameters descriptors

Right now, Montero et al. (2005) branch biomass models have a special response variable name. I think it makes more sense to rework these as model descriptors, since it appears to be a very specialized case

Woodall et al. (2011)

Provide a citation of the publication you want us to add.

@article{woodall2011methods,
  title={Methods and equations for estimating aboveground volume, biomass, and carbon for trees in the US forest inventory, 2010},
  author={Woodall, Christopher W and Heath, Linda S and Domke, Grant M and Nichols, Michael C},
  journal={Gen. Tech. Rep. NRS-88. Newtown Square, PA: US Department of Agriculture, Forest Service, Northern Research Station. 30 p.},
  volume={88},
  pages={1--30},
  year={2011}
}

https://ww2.arb.ca.gov/sites/default/files/cap-and-trade/protocols/usforest/2014/woodall_2011.pdf

Add check for duplicated descriptor name

A Publication can be defined with a descriptor, e.g., region = "OR"

A ModelSet can be defined with a descriptor, e.g. region = "Western OR"

Likewise, a Model can be defined with a descriptor, e.g., region = "Clackamas"

This should be handled when model sets are added to a publication. An error should be thrown when this case is detected, the user should be forced to select a unique name.

Poudel et al. (2019)

Provide a citation of the publication you want us to add.

@article{poudel2019estimating,
  title={Estimating individual-tree aboveground biomass of tree species in the western USA},
  author={Poudel, Krishna P and Temesgen, Hailemariam and Radtke, Philip J and Gray, Andrew N},
  journal={Canadian Journal of Forest Research},
  volume={49},
  number={6},
  pages={701--714},
  year={2019},
  publisher={NRC Research Press}
}

Montero et al. (2020)

Provide a citation of the publication you want us to add.

@article{montero2020production,
  title={Biomass production and carbon sequestration by Spanish shrublands and by the superficial organic horizon of forest soils},
  author={Montero, G and L{\'o}pez-Leiva, C and Ruiz-Peinado, R and L{\'o}pez-Senespleda, E and Onrubia, R and Pasalodos, M},
  journal={Ministry of Agriculture, Fisheries and Food{\'o}n: Madrid, Spain},
  year={2020}
}

Paco says these may need some checking

Trasobares et al. (2022)

Provide a citation of the publication you want us to add.

@article{trasobares2022nationwide,
  title={Nationwide climate-sensitive models for stand dynamics and forest scenario simulation},
  author={Trasobares, Antoni and Mola-Yudego, Blas and Aquilu{\'e}, N{\'u}ria and Gonz{\'a}lez-Olabarria, Jos{\'e} Ram{\'o}n and Garcia-Gonzalo, Jordi and Garc{\'\i}a-Vald{\'e}s, Ra{\'u}l and De C{\'a}ceres, Miquel},
  journal={Forest Ecology and Management},
  volume={505},
  pages={119909},
  year={2022},
  publisher={Elsevier}
}

Allow for unitless units

Some covariates do not have units, such as indicator variables. units::unitless may do the trick but throws an error when compiling models

misaligned formatting of variable summary

vsa [ft3]: volume of the entire stem, including top and stump
dsob [in]: diameter of the stem, outside bark at breast height

should look like

vsa    [ft3]: volume of the entire stem, including top and stump
dsob [in]: diameter of the stem, outside bark at breast height

its the details!

Iterate on `fit_species`

fit_species seems to be inadequate or at least unclear. Sometimes a model is fit for an entire genus, or a set of species within a genus, etc etc

We should have something more general/flexible, but I still think using the taxonomic hierarchy is a good idea. I will wait until I add a few more equations before committing to anything

Allow "intermediate" variables in `predict_fn`

The parameters of a model are determined by "subtracting" the covariates of a predict_fn from the set of all named variables. This is ok, but users may want to define intermediate parameters, such as in the case of Hann (2011) which involves many intermediate steps.

https://github.com/brycefrank/allometric/blob/274e6bb1b28bebe890eae518cc240e506bb71665/R/util.R#L3-L6

One solution may be to require users to write the final line of predict_fn as a mathematical expression (as they are required to now), but allow this expression to have intermediate variables.

Devise a performant structure for holding models

Ideally, the package should be performant for a very large number of models.

My initial idea of writing out functions programmatically is prohibitively slow (to document, build website and install!) at around 10000 equations. That is a super big number of equations, but we should start with something that can deal with that.

So...back to the drawing board.

My other idea is to not directly load allometric functions at all. Instead, the user calls them from a locally stored data structure. The question is, how do data structures like .RDS or .Rdata handle this. Do they need to be loaded into memory? How fast is this?

Replace `component` and `measure` in `allometric_models` with `model_type`

Referring to models with component and measure can be awkward. Instead, we can make something more general called model_type which will link certain response variable names to more typically used names.

For example, dsoh and dsih refer to diameter outside/inside bark at a specificed height. These are taper models, so the table can look something like

response_name  model_type
         dsoh  taper
         dsih  taper

There can be a set of pre-specified model types, and then the rest are just filled in with paste(component, measure) as before. Finally, we get something nice, like allometric_models %>% filter(model_type == "taper") instead of the more awkward allometric_models %>% filter(component == "stem", measure == "diameter"). Another example is hstix** which refer to site index models.

Chojnacky (1985)

Provide a citation of the publication you want us to add.

@book{chojnacky1985pinyon,
  title={Pinyon-juniper volume equations for the central Rocky Mountain States},
  author={Chojnacky, David C},
  volume={339},
  year={1985},
  publisher={US Department of Agriculture, Forest Service, Intermountain Forest and Range~…}
}

https://books.google.com/books?hl=en&lr=&id=uXhe1sdn1eMC&oi=fnd&pg=PA1&dq=Chojnacky,+D.C.+1985.+Pinyon-juniper+volume+equations+for+the+central+Rocky+Mountain+states.+Res.+Pap.+INT-339.+Ogden,+UT:+U.S.+Department+of+Agriculture,+Forest+Service,+Intermountain+Forest+and+Range+Experiment+Station.+27+p.+&ots=DvMrMFOvr5&sig=FE-Hs4YE0XaXwIxyyworNqokjDw#v=onepage&q&f=false

Custom covariate names

It should be possible to create covariate names that are not in the set of defined variables. One motivating example is in Chojnacky (1985), which uses an indicator variable for multi-stemmed juniper trees. Its unlikely that a shared pool of covariate names will ever cover all cases.

This could be covered by optional arguments to ModelSet and AllometricModel that allow for user-defined variable names and definitions. Appropriate validity checks should also be implemented, but this is larger scope than this issue

Feldpausch et al. (2012)

Provide a citation of the publication you want us to add.

@article{feldpausch2012tree,
  title={Tree height integrated into pantropical forest biomass estimates},
  author={Feldpausch, Ted R and Lloyd, Jon and Lewis, Simon L and Brienen, Roel JW and Gloor, Manuel and Monteagudo Mendoza, Abel and Lopez-Gonzalez, Gabriela and Banin, Lindsay and Abu Salim, Kamariah and Affum-Baffoe, Kofi and others},
  journal={Biogeosciences},
  volume={9},
  number={8},
  pages={3381--3403},
  year={2012},
  publisher={Copernicus GmbH}
}

Describe where the models are in the report.
https://bg.copernicus.org/articles/9/3381/2012/bg-9-3381-2012.pdf
Table 3

Vibrans et al. (2015)

Provide a citation of the publication you want us to add.

@article{vibrans2015generic,
  title={Generic and specific stem volume models for three subtropical forest types in southern Brazil},
  author={Vibrans, Alexander C and Moser, Paolo and Oliveira, Laio Z and de Ma{\c{c}}aneiro, Jo{\~a}o P},
  journal={Annals of Forest Science},
  volume={72},
  number={6},
  pages={865--874},
  year={2015},
  publisher={BioMed Central}
}

Describe where the models are in the report.
Table 3

Hibbs et al. (2007)

Provide a citation of the publication you want us to add.

@article{hibbs2007stem,
  title={Stem taper and volume of managed red alder},
  author={Hibbs, David and Bluhm, Andrew and Garber, Sean},
  journal={Western Journal of Applied Forestry},
  volume={22},
  number={1},
  pages={61--66},
  year={2007},
  publisher={Oxford University Press}
}

Expose publications to the user

Right now, Publication objects are loaded when install_models runs. This is undesirable since it occupies memory that is not really used. Instead, we should remove these objects from memory as they are processed in update_models and optionally cache the publication objects for interested users.

extend `tbl_df` using S3 classes

S4 classes cannot inherit tbl_df, but S3 classes can, and mixing class structures is no problem as long as it is done well. We should extend tbl_df for select_model and to prepare for "tidy" use of allometric models in larger inventories (a task for a future milestone)

Add a `model_call` method to `AllometricModel`

Right now, model summaries are ambiguous to the order of arguments given the predict. It should be easy to make a model_call method that can retrieve this and print it in the summary.

Incorrect model string in `rustagi_1991`

Model Form:
vso = k * (a * hso + b * dsob * hso + c * dsob^2 * hso + d * (hsdop67 - vso = 1.37)) + e * dsob * (hsdop67 - 1.37) + f * dsob^2 * (hsdop67 - vso = 1.37)

Note the weird vso = 1.37

Montero et al. (2005)

Provide a citation of the publication you want us to add.

@book{montero2005production,
  title={Biomass production and CO2 fixation by Spanish forests},
  author={Montero, Gregorio and Ruiz-Peinado, Ricardo and Munoz, Marta},
  volume={13},
  year={2005},
  publisher={INIA-National Institute for Agricultural and Food Research{\'\i}and Technology~…}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.