Skip to content

Commit

Permalink
first submission to CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
saudiwin committed Feb 10, 2023
1 parent 59a089f commit 274dff2
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 21 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ continuous.png
ex_code_plot.R
README.md
anim_ggplot.gif
overwrite_datasets.R
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ BugReports: https://github.com/saudiwin/ordbetareg_pack/issues
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
LazyDataCompression: xz
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.2
Depends:
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
- Improved plot formatting and added theme and label options.
- Updated vignette to include information about `glmmTMB` as an alternative for estimation
and new plot functions.
- Added distribution `rordbeta` and `dordbeta` functions.
- Removed legacy `0 + Intercept` function code. Now accepts any kind of formula.

# ordbetareg v0.5.0

Expand Down
2 changes: 1 addition & 1 deletion R/distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#' @param cutpoints A vector of two numeric values for the cutpoints. Second value should
#' @param log where to return the log density
#' be strictly greater than the first value.
#' @example
#' @examples
#'
#' # examine density (likelihood) of different possible values
#' # given fixed values for ordered beta parameters
Expand Down
3 changes: 3 additions & 0 deletions R/modeling.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
#' @examples
#' # load survey data that comes with the package
#'
#' library(dplyr)
#' data("pew")
#'
#' # prepare data
Expand Down Expand Up @@ -948,6 +949,8 @@ ordbetareg <- function(formula=NULL,
#'
#' data("sim_data")
#'
#' library(dplyr)
#'
#' # will take a while to run this
#' \donttest{
#' sim_data <- sim_ordbeta(N=c(250,750),
Expand Down
35 changes: 18 additions & 17 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,32 @@

0 errors | 0 warnings | 1 notes

> checking installed package size ... NOTE
installed size is 5.7Mb
checking installed package size ... NOTE
installed size is 13.4Mb
sub-directories of 1Mb or more:
data 5.2Mb
data 10.0Mb
doc 3.3Mb

The data sub-directory contains fitted models that are used to illustrate function examples because fitting the model can take up to an hour.

Submitting to win-release results in OK status - no NOTEs or WARNINGs.
Submitting to win-release results in 1 ERROR:

Submitting to win-devel results in the following WARNING:
Error(s) in re-building vignettes:
--- re-building 'package_introduction.Rmd' using rmarkdown
Quitting from lines 247-258 (package_introduction.Rmd)
Error: processing vignette 'package_introduction.Rmd' failed with diagnostics:
could not find function "avg_slopes"
--- failed re-building 'package_introduction.Rmd'

Found the following significant warnings:
Warning: The `size` argument of `element_line()` is deprecated as of ggplot2 3.4.0.
See 'd:/RCompile/CRANguest/R-devel/ordbetareg.Rcheck/00install.out' for details.
SUMMARY: processing the following file failed:
'package_introduction.Rmd'

The ggplot2 3.4.0 package is not currently available in CRAN. To address this issue, I added code that will use the updated function argument if ggplot2 3.4.0 is detected (see plot.R line number 154):
Error: Vignette re-building failed.
Execution halted

```
if(packageVersion('ggplot2')=="3.4.0") {
Submitting to win-devel results in OK status - no NOTEs or WARNINGs.

cont_plot <- cont_plot + geom_density(aes(x=true),linewidth=2,colour="gray",alpha=0.7)
The error in win-release appears to be due to the fact the marginaleffects package, which has the avg_slopes function, does not have a binary available for windows for the current version of the package, 0.9.0. This is the required version listed under the Suggests field in ordbetareg but win-release is installing an older version that does not have the avg_slopes function. However, it is necessary to update to 0.9.0 as otherwise the package vignette fails to compile, and I received an email from the CRAN maintainer requesting that I update the package to handle marginaleffects 0.9.0--see build logs at https://cran.r-project.org/web/checks/check_results_ordbetareg.html. If I do not update the package by 2-16-2023, it will be removed from CRAN.

} else {
As such, it would seem that this error in win-release should be ignored as it is not clear why it is not installing the current version of marginaleffects, which has been available since Feb 1 2023.

cont_plot <- cont_plot + geom_density(aes(x=true),size=2,colour="gray",alpha=0.7)
}
```
Binary file modified data/fit_imputed.rda
Binary file not shown.
Binary file modified data/fit_multivariate.rda
Binary file not shown.
Binary file modified data/ord_fit_mean.rda
Binary file not shown.
Binary file modified data/ord_fit_phi.rda
Binary file not shown.
21 changes: 21 additions & 0 deletions man/dordbeta.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/ordbetareg.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/sim_ordbeta.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions vignettes/package_introduction.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ modelsummary(ord_fit_mean,statistic = "conf.int",
There is a related package, `marginaleffects`, that allows us to convert these coefficients into more meaningful marginal effect estimates, i.e., the effect of the predictors expresses as the actual change in the outcome on the 0 - 1 scale. Because we have two variables in our model that are both ordinal in nature, `marginaleffects` will produce an estimate of the marginal effect of each value of each ordinal predictor. I use the `avg_slopes` function to convert the `ordbetareg` model to a data frame of marginal/conditional effects in the scale of the outcome that can be easily printed:

```{r marg_effect}
library(marginaleffects)
avg_slopes(ord_fit_mean, variables="education") %>%
select(Variable="term",
Expand Down Expand Up @@ -415,14 +414,14 @@ As I explain in the paper, one of the main advantages of using a Beta regression

The one change we need to make to fit this model is to add a formula predicting `phi` in the code below. Because we now have two formulas--one for the mean and one for dispersion--I use the `bf` function to indicate these two sub-models. I also need to specify `phi_reg` to be TRUE because some of the priors will change.

Because there is no need to model the mean, I leave the first formula as `therm ~ 0`. I don't specify 1 for an intercept because the ordered regression model has other intercepts (i.e., the cutpoints). I then specify a separate model for `phi` with an interaction between `age` and `sex` to see if these covariates are associated with dispersion.
Because there is no need to model the mean, I leave the first formula as `therm ~ 1` with the 1 representing only an intercept, not a covariate. I then specify a separate model for `phi` with an interaction between `age` and `sex` to see if these covariates are associated with dispersion.


```{r run_brms_phi}
if(run_model) {
ord_fit_phi <- ordbetareg(bf(therm ~ 0,
ord_fit_phi <- ordbetareg(bf(therm ~ 1,
phi ~ age + sex),
phi_reg = T,
data=model_data,
Expand Down

0 comments on commit 274dff2

Please sign in to comment.