Research scientist focusing on tropical forest dynamics, structure and function.
-
Northern Arizona University
- Flagstaff, AZ
- https://al.shenkin.org
- https://orcid.org/0000-0003-2358-9367
- @ashenkin
- ashenkin
- in/alexandershenkin
Highlights
- Pro
Pinned Loading
-
-
-
Deviation (sum to zero) contrasts ar...
Deviation (sum to zero) contrasts are important to use in models when one is interested in grand mean parameters and per-level deviations from that mean. However, the usual method of coding these contrasts in R ends up throwing away the associated variable names. As long as you understand what deviation contrasts do, there is no danger in maintaining these names (some assert this is dangerous, but I really don't think it is). The code below sets deviation contrasts, and maintains the names of the factor levels. 1contr.sum.keepnames <- function(...) {
2# make deviation contrasts that don't lose the names of the factors in the model results
3# from https://stackoverflow.com/questions/10808853/why-does-changing-contrast-type-change-row-labels-in-r-lm-summary
4conS <- contr.sum(...)
5colnames(conS) = rownames(conS)[-length(rownames(conS))]
-
How to predict results from lme4's g...
How to predict results from lme4's glmer when fit with scaled data 1# We often fit LMM/GLMM's with scaled variables. However, making predictions using those models isn't straightforward (at least to me!)
2# It turns out that you have to re-scale your prediction data using the same parameters used to scale your original data frame used to fit the model
3# See below, and pay special attention to the section where the new data are rescaled.
45library(lme4)
-
Efficiently get higher taxon names (...
Efficiently get higher taxon names (family, order, and subdivision) when you know genus or family. Merges NCBI and ITIS database returns. 1query_higher_taxa_classes <- function(species_list, known = "genus", order = c("dataframe", "unique_sp")) {
2# Pass in a character vector of species, genera, families, or whatever (the search is flexible)
3# Returns a dataframe with the columns: query, db, family, order, subdivision
4# The dataframe returned is guaranteed to be in the same order as the species list passed in if order is "dataframe"
5order = match.arg(order)
-
You have a digital elevation model (...
You have a digital elevation model (DEM), and you want to make an elevation profile between two or more points. You want that elevation profile to reflect an average elevation across a swath, and not just a single point from a line. Here's one way to do it in R. Thanks to Forrest Stevens and other folks from the R-sig-geo list. 1# Thanks to Forrest Stevens. Some of the code here borrowed from him here: https://github.com/ForrestStevens/Scratch/blob/master/swath_slices.R
23library(raster)
4library(rgdal)
5library(sp)
Something went wrong, please refresh the page to try again.
If the problem persists, check the GitHub status page or contact support.
If the problem persists, check the GitHub status page or contact support.