Skip to content

Commit

Permalink
preparing for cran submission
Browse files Browse the repository at this point in the history
  • Loading branch information
joshyam-k committed Feb 6, 2024
1 parent a737807 commit a8680a3
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 60 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
sandbox
^data-raw$
^\.github$
^figs$
^cran-comments\.md$
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
.Rhistory
.RData
.Ruserdata
*.Rproj
*.Rproj
51 changes: 2 additions & 49 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,7 @@ knitr::opts_chunk$set(

`saeczi` is an R package that implements a small area estimator that uses a two-stage modeling approach for zero-inflated response variables. In particular, we are working with variables that follow a semi-continuous distribution with a mixture of zeroes and positive continuously distributed values. An example can be seen below.

```{r zi-plot, dpi = 600, fig.width = 10, fig.height=6, echo=F, message=F, warning=F}
set.seed(6)
library(tidyverse)
z <- tibble(
z = rep(0, 2500)
)
nz <- tibble(
nz = rgamma(1000, 3, 4)
)
ggplot() +
geom_density(
data = filter(nz, nz > 0.25),
aes(x = nz, y = ..count..),
fill = "#023047",
color = "white",
alpha = 0.9
) +
geom_histogram(
data = z,
aes(x = z),
fill = "#023047",
color = "white",
alpha = 0.9
) +
labs(
x = "Response Variable"
) +
theme_bw()
```
![](figs/README-zi-plot-1.png)

`saeczi` first fits a linear mixed model to the non-zero portion of the response and then a generalized linear mixed model with binomial response to classify the probability of zero for a given data point. In estimation these models are each applied to new data points and combined to compute a final prediction.

Expand Down Expand Up @@ -108,20 +77,4 @@ result$res |> head()

This output format allows for easy results plotting

```{r res_plot, dpi = 600, echo = FALSE, warning = FALSE, message=FALSE}
library(tidyverse)
result$res |>
mutate(domain = fct_reorder(domain, est)) |>
ggplot() +
geom_point(aes(x = domain, y = est), alpha = 0.7, size = 0.8) +
geom_errorbar(aes(x = domain,
ymin = est - 1.96*sqrt(mse),
ymax = est + 1.96*sqrt(mse)),
color = "midnightblue") +
theme_bw() +
theme(
axis.text.x = element_text(angle = 45, vjust = 0.7)
) +
labs(x = "County", y = "Biomass")
```

![](figs/README-res_plot-1.png)
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ In particular, we are working with variables that follow a
semi-continuous distribution with a mixture of zeroes and positive
continuously distributed values. An example can be seen below.

![](README-zi-plot-1.png)<!-- -->
![](figs/README-zi-plot-1.png)

`saeczi` first fits a linear mixed model to the non-zero portion of the
response and then a generalized linear mixed model with binomial
Expand Down Expand Up @@ -70,8 +70,13 @@ result <- saeczi(samp_dat = samp,
mse_est = TRUE,
B = 500,
parallel = FALSE)
#> creating bootstraps...
#> estimating mse...
#> ================================================================================
#> • Fitting Models...
#> • Beginning Bootstrap...
#> - Fitting to Bootstrap samples ✓
#> - Estimating MSE ✓
#> • Compiling Results...
#> ================================================================================
```

The function returns the original call, a data frame containing the
Expand All @@ -91,14 +96,14 @@ few rows of the results:
``` r
result$res |> head()
#> domain mse est
#> 1 41001 374.82344 14.85495
#> 2 41003 10.97949 97.74967
#> 3 41005 708.82223 86.02207
#> 4 41007 251.39503 76.24752
#> 5 41009 382.08787 70.28624
#> 6 41011 77.06537 87.65072
#> 1 41001 173.58940 14.85495
#> 2 41003 42.43279 97.74967
#> 3 41005 581.01815 86.02207
#> 4 41007 35.98329 76.24752
#> 5 41009 222.58951 70.28624
#> 6 41011 213.38928 87.65072
```

This output format allows for easy results plotting

![](README-res_plot-1.png)<!-- -->
![](figs/README-res_plot-1.png)
5 changes: 5 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## R CMD check results

0 errors | 0 warnings | 1 note

* This is a new release.
File renamed without changes
File renamed without changes

0 comments on commit a8680a3

Please sign in to comment.