knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
mase
is still under development. Please use at your own risk!
mase
contains a collection of model-assisted generalized regression estimators for finite population estimation of a total or mean from a single stage, unequal probability without replacement design. It also contains several variance estimators.
The available estimators are currently:
greg()
horvitzThompson()
postStrat()
gregElasticNet()
gregTree()
modifiedGreg()
ratioEstimator()
ratio()
The available variance estimation techniques are:
See mase/inst/REFERENCES.bib
for sources related to each variance estimator.
Install the latest CRAN release with:
install.packages("mase")
You can also install the developmental version of mase
from GitHub with:
# install.packages("pak") pak::pkg_install("mcconvil/mase")
Here's an example of fitting the Horvitz-Thompson estimator using Forestry data in Idaho. The data comes from the Forestry Inventory & Analysis (FIA) program.
library(mase) library(dplyr) data(IdahoSamp) data(IdahoPop) samp <- filter(IdahoSamp, COUNTYFIPS == 16055) pop <- filter(IdahoPop, COUNTYFIPS == 16055) horvitzThompson(y = samp$BA_TPA_ADJ, N = pop$npixels, var_est = TRUE, var_method = "LinHTSRS")
We can also fit a linear regression estimator using that same data:
xsample <- select(samp, c(tcc, elev, ppt, tmean)) xpop <- select(pop, names(xsample)) greg_est <- greg(y = samp$BA_TPA_ADJ, N = pop$npixels, xsample = xsample, xpop = xpop, var_est = TRUE, var_method = "LinHB", datatype = "means")
We still get the population total and mean estimates along with their variance estimates:
greg_est[c('pop_total','pop_mean', 'pop_total_var', 'pop_mean_var')]
But with this estimator we also get the weights
greg_est["weights"]
and the coefficients for the model
greg_est["coefficients"]
All of the mase regression estimators can also perform variable selection internally using the parameter modelselect
greg_select <- greg(y = samp$BA_TPA_ADJ, N = pop$npixels, xsample = xsample, xpop = xpop, modelselect = TRUE, var_est = TRUE, var_method = "LinHB", datatype = "means")
And we can examine which predictors were chosen:
greg_select["coefficients"]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.