Type: | Package |
Title: | GREGORY Estimation |
Version: | 0.1.0 |
Description: | Functions which make using the Generalized Regression Estimator(GREG) J.N.K. Rao, Isabel Molina, (2015) <doi:10.3390/f11020244> and the Generalized Regression Estimator Operating on Resolutions of Y (GREGORY) easier. The functions are designed to work well within a forestry context, and estimate multiple estimation units at once. Compared to other survey estimation packages, this function has greater flexibility when describing the linear model. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
Imports: | dplyr, purrr, tidyr, magrittr |
RoxygenNote: | 7.1.1 |
Suggests: | knitr, rmarkdown |
NeedsCompilation: | no |
Packaged: | 2021-09-02 22:34:44 UTC; olkow |
Author: | Olek Wojcik [cre, aut], Sam Olson [aut] |
Maintainer: | Olek Wojcik <olkowaty@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2021-09-06 09:00:08 UTC |
greg_all
Description
This function runs the Generalized Regression estimator, also know as GREG, on a set of data.
Usage
greg_all(plot_df, estimation, pixel_estimation_means, formula)
Arguments
plot_df |
A data frame containing the response variable, predictors, estimation unit, and resolution unit for each "plot" |
estimation |
A character specifying the estimation column name within the other dataframes |
pixel_estimation_means |
A dataframe with a column for the estimation unit and a column for the mean response variable value per that estimation unit |
formula |
Formula to be used for the model, names should be consistent with the column names in plot_df and pixel_estimation_means |
Value
A dataframe with each row representing each estimation unit, its estimate, and its estimated variance.
Examples
#create plot data
planet_plot_data <- data.frame(plot_number = 1:20,
planet = c(rep("Kashyyyk", 5),
rep("Forest Moon of Endor", 5),
rep("Dagobah", 5),
rep("Naboo", 5)),
count_of_trees = c(204, 156, 240, 286, 263,
112, 167, 131, 25, 145,
141, 65, 127, 15, 98,
100, 12, 49, 94, 69),
forest_cover = c(85, 74, 89, 95, 92,
70, 73, 69, 11, 68,
67, 30, 62, 15, 42,
59, 5, 17, 25, 22))
#create mean data
planet_means <- data.frame(planet = c("Kashyyyk",
"Forest Moon of Endor",
"Dagobah",
"Naboo"),
forest_cover = c(95,
85,
50,
30))
x1 <- greg_all(plot_df = planet_plot_data,
estimation = "planet",
pixel_estimation_means = planet_means,
formula = count_of_trees ~ forest_cover)
x1
gregory_all
Description
This function runs the Generalized Regression Operating on Resolutions of Y estimator, also know as GREGORY, on a set of data.
Usage
gregory_all(
plot_df,
resolution,
estimation,
pixel_estimation_means,
proportions,
formula,
prop
)
Arguments
plot_df |
A data frame containing the response variable, predictors, estimation unit, and resolution unit for each "plot" |
resolution |
A character specifying the resolution column name within the other dataframes |
estimation |
A character specifying the estimation column name within the other dataframes |
pixel_estimation_means |
A dataframe with a column for the estimation unit and a column for the mean response variable value per that estimation unit |
proportions |
A dataframe with three columns: one for resolution, one for estimation, and one for the proportion of a resolution area found in each estimation area |
formula |
Formula to be used for the model, names should be consistent with the column names in plot_df and pixel_estimation_means |
prop |
A character specifying the column name of the proportion found in proportions |
Value
A dataframe with each row representing each estimation unit, its estimate, and its estimated variance.
Examples
#create plot data
planet_plot_data <- data.frame(plot_number = 1:20,
planet = c(rep("Kashyyyk", 5),
rep("Forest Moon of Endor", 5),
rep("Dagobah", 5),
rep("Naboo", 5)),
count_of_trees = c(204, 156, 240, 286, 263,
112, 167, 131, 25, 145,
141, 65, 127, 15, 98,
100, 12, 49, 94, 69),
forest_cover = c(85, 74, 89, 95, 92,
70, 73, 69, 11, 68,
67, 30, 62, 15, 42,
59, 5, 17, 25, 22),
eco_province = c("forest", "swamp", "forest", "forest", "forest",
"forest", "forest", "forest", "grassland", "forest",
"forest", "swamp", "swamp", "grassland", "swamp",
"forest", "grassland", "grassland",
"swamp", "swamp"))
#create mean data
planet_means <- data.frame(planet = c("Kashyyyk",
"Forest Moon of Endor",
"Dagobah",
"Naboo"),
forest_cover = c(95,
85,
50,
30))
#create proportion data
planet_province_prop <- data.frame(planet = c(rep("Kashyyyk", 2),
rep("Forest Moon of Endor", 2),
rep("Dagobah", 3),
rep("Naboo", 3)),
eco_province = c("forest", "swamp",
"forest", "grassland",
"forest", "grassland", "swamp",
"forest", "grassland", "swamp"),
prop = c(0.8, 0.2,
0.75, 0.25,
0.1, 0.1, 0.8,
0.2, 0.4, 0.4))
x1 <- gregory_all(plot_df = planet_plot_data,
resolution = "eco_province",
estimation = "planet",
pixel_estimation_means = planet_means,
proportions = planet_province_prop,
formula = count_of_trees ~ forest_cover,
prop = "prop")
x1