Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Greenwood #18

Merged
merged 21 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6b09d6b
Fixed a bug in plot_compare that didn't loop through different plots …
greenwood-stat Mar 4, 2023
fe3f9df
Fixed cutoff in cookd cutoff_cookd to use SAS's 4/n rule (was overwri…
greenwood-stat Mar 6, 2023
6a234ee
Change to documentation in label and resolution driving Cook's D cont…
greenwood-stat Aug 10, 2023
dc53d3d
New function resid_calibrate for comparing observed residuals to simu…
greenwood-stat Dec 28, 2023
7cecb7c
Modify smoother choices to add smoothing line in residuals vs fitted …
greenwood-stat Dec 29, 2023
3bb2cd2
Edits to html page
greenwood-stat Dec 30, 2023
fa28b46
Simplified resid_calibrate interface using model.frame to extract ori…
greenwood-stat Dec 31, 2023
b8c1f86
Make default lm QQ-plot of stdres standardized residuals
greenwood-stat Jan 4, 2024
a98548e
Fixing issues in lev (no smoother) and qq plot (switch version of res…
greenwood-stat Jan 6, 2024
9401b41
Fixes for extreme leverage cases
greenwood-stat Jan 7, 2024
10d88c1
Changed Cook's D legend label and made yvp fixed aspect ratio
greenwood-stat Jan 9, 2024
e8293de
Merge pull request #17 from greenwood-stat/master
goodekat Jan 10, 2024
6e1bc00
small fixes to remove errors/warnings/notes from eval check
goodekat Nov 1, 2024
0b770d4
updated to do list
goodekat Nov 1, 2024
51e7897
added another task
goodekat Nov 1, 2024
f667af7
adding badges and connecting with github actions
goodekat Jan 14, 2025
5757352
working on adding changes from posit conf
goodekat Jan 14, 2025
68b9569
adding more changes from posit course
goodekat Jan 15, 2025
ff41131
updated package number
goodekat Jan 15, 2025
7b18feb
attempting to remove codecov.yml
goodekat Jan 15, 2025
afb5406
added Mark as a contributor
goodekat Jan 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
^.*\.Rproj$
^\.Rproj\.user$
^codecov.yml$
^cran-comments.md$
^CRAN-RELEASE$
^doc$
^docs$
^figures$
^\.github$
^Ideas for Future Work$
^Meta$
^pkgdown$
Expand Down
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
51 changes: 51 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:

name: R-CMD-check.yaml

permissions: read-all

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
61 changes: 61 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:

name: test-coverage.yaml

permissions: read-all

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr, any::xml2
needs: coverage

- name: Test coverage
run: |
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v4
with:
# Fail if error if not on PR, or if on PR and token is given
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
file: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
27 changes: 21 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@ Package: ggResidpanel
Type: Package
Title: Panels and Interactive Versions of Diagnostic Plots using 'ggplot2'
Version: 0.3.0.9000
Authors@R: c(person("Katherine", "Goode", email = "[email protected]", role = c("aut", "cre")),
person("Kathleen", "Rey", email = "[email protected]", role = c("aut")))
Description: An R package for creating diagnostic plots for models. The package allows for the
creation of panels of plots and interactive plots.
Authors@R: c(
person(
"Katherine", "Goode",
email = "[email protected]",
role = c("aut", "cre")
),
person(
"Kathleen", "Rey",
email = "[email protected]",
role = c("aut")),
person(
"Greenwood", "Mark",
email = "[email protected]",
role = c("ctb"))
)
Description: An R package for creating diagnostic plots for models. The package
allows for the creation of panels of plots and interactive plots.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Expand All @@ -16,11 +29,12 @@ Imports:
grDevices,
grid,
MASS,
methods,
plotly,
qqplotr,
stats,
stringr
RoxygenNote: 7.1.1
RoxygenNote: 7.3.2
Suggests:
dplyr,
forcats,
Expand All @@ -31,8 +45,9 @@ Suggests:
randomForest,
rmarkdown,
rpart,
testthat,
testthat (>= 3.0.0),
vdiffr,
wesanderson
VignetteBuilder: knitr
Depends: R (>= 3.0.0)
Config/testthat/edition: 3
9 changes: 8 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(resid_auxpanel)
export(resid_calibrate)
export(resid_compare)
export(resid_interact)
export(resid_panel)
Expand All @@ -10,7 +11,8 @@ importFrom(cowplot,draw_label)
importFrom(cowplot,ggdraw)
importFrom(cowplot,plot_grid)
importFrom(ggplot2,aes)
importFrom(ggplot2,aes_string)
importFrom(ggplot2,after_stat)
importFrom(ggplot2,coord_fixed)
importFrom(ggplot2,element_blank)
importFrom(ggplot2,element_text)
importFrom(ggplot2,expand_limits)
Expand All @@ -30,6 +32,7 @@ importFrom(ggplot2,ggplot)
importFrom(ggplot2,ggplotGrob)
importFrom(ggplot2,ggplot_build)
importFrom(ggplot2,labs)
importFrom(ggplot2,scale_color_gradient2)
importFrom(ggplot2,scale_x_continuous)
importFrom(ggplot2,scale_y_continuous)
importFrom(ggplot2,stat_function)
Expand All @@ -43,6 +46,7 @@ importFrom(ggplot2,ylab)
importFrom(grDevices,extendrange)
importFrom(grid,gpar)
importFrom(grid,textGrob)
importFrom(methods,is)
importFrom(plotly,"%>%")
importFrom(plotly,ggplotly)
importFrom(plotly,layout)
Expand All @@ -54,9 +58,12 @@ importFrom(qqplotr,stat_qq_point)
importFrom(stats,cooks.distance)
importFrom(stats,dnorm)
importFrom(stats,fitted)
importFrom(stats,formula)
importFrom(stats,hatvalues)
importFrom(stats,lm)
importFrom(stats,lowess)
importFrom(stats,model.frame)
importFrom(stats,resid)
importFrom(stats,sd)
importFrom(stats,simulate)
importFrom(stringr,str_sub)
29 changes: 29 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
# ggResidpanel 0.4.0

## Major

- Added resid_calibrate
- For lm model:
- Standardized residuals are now the default instead of raw residuals
- Fixed issue when leverage is equal to 1 when computing standardized residuals - report Pearson residuals instead
- Added alpha value in all functions
- Adjustments to Cook's D plots
- "Return a warning if any of the leverage values are equal to 1 and add lines to plot"
- Need to add more descriptions here
- In plot_constlev, removed "Compute the values for the lowess curve"
- In plot_lev, :
- "Create the cutoff SAS uses with Cook's D"
- "Count number over cutoff"
- Adjusted the way constant leverage is handled
- Added Cook's D values
- When creating hat values, "Add more resolution for large n"
- In plot_ls, "If smoother is set to true, do not add it to the plot"
- Adjustments to the smoother options across various plot types

## Minor

- Typo fixes in documentation
- Small fixes to code for better practices
- Small updates to plot_hist grid
- Clean up of some plot labels

# ggResidpanel 0.3.0

## Major:
Expand Down
17 changes: 0 additions & 17 deletions R/helper_checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,3 @@ check_leverage <- function(model, plots){
}

}

# Return a warning about choosing the number of bins if a histogram is included
# and the number of bins has not been specified and return the default option if
# not specified
# check_bins <- function(plots, bins){
#
# if("default" %in% plots | "SAS" %in% plots | "all" %in% plots | "hist" %in% plots){
# if(is.na(bins)){
# bins = 30
# warning("By default, bins = 30 in the histogram of residuals. If necessary,
# specify an appropriate number of bins.")
# }
# }
#
# return(bins)
#
# }
6 changes: 3 additions & 3 deletions R/helper_plotly_label.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ if(class(model)[1]%in%c("lm", "glm")){
#Trim variables that are numeric and contain a decimal
#down to 3 decimal places
# for(i in 1:ncol(plotly_data)){
# #First part checks for rows in teh column that contain a decimal
# #if they do not contian a decimal, do nothing to them.
# #First part checks for rows in the column that contain a decimal
# #if they do not contain a decimal, do nothing to them.
#
# #The second part checks to see if the row values are value numbers
# #A cateogrical value could contain a period
# #A categorical value could contain a period
# plotly_data[grepl("\\.", as.character(plotly_data[,i]))&!is.na(as.numeric(plotly_data[,i])),i] <- round(as.numeric(as.character(plotly_data[grepl("\\.", as.character(plotly_data[,i]))&!is.na(as.numeric(plotly_data[,i])),i])), 3)
# }

Expand Down
16 changes: 11 additions & 5 deletions R/helper_resid.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ helper_resid <- function(type = NA, model){
# lm residuals
if(class(model)[1] == "lm"){

# Default: raw residuals
if(is.na(type) | type == "response"){
return(resid(model, type = "response"))
# Default: standardized residuals
if(is.na(type) | type == "standardized"){
if (any(!is.finite(stdres(model)))){
warning("Leverage 1 observation(s) encountered, reporting Pearson Residuals")
return(resid(model, type = "response") / summary(model)$sigma)
} else {
return(stdres(model))
}
}else if(type == "pearson"){
return(resid(model, type = "response") / summary(model)$sigma)
}else if(type == "standardized"){
return(stdres(model))
}else if(type == "response"){
return(resid(model, "response"))
}


# glm residuals
} else if (class(model)[1] == "glm"){
Expand Down
5 changes: 3 additions & 2 deletions R/plot_auxboxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ plot_auxboxplot <- function(resid, theme, axis.text.size, title.text.size, title
## Creation of Plot ---------------------------------------------------------------

# Create the boxplot of residuals
plot <- ggplot(model_values, aes_string(x = " ", y = "Residual")) +
plot <-
ggplot(model_values, aes(x = " ", y = {{Residual}})) +
geom_boxplot(width = .5) +
geom_point(alpha = 0) +
labs(x = " ", y = "Residuals")
Expand All @@ -28,7 +29,7 @@ plot_auxboxplot <- function(resid, theme, axis.text.size, title.text.size, title
plot <- plot + theme_grey()
}

# Set text size of title and axis lables, determine whether to include a title,
# Set text size of title and axis labels, determine whether to include a title,
# and return plot
if (title.opt == TRUE){
plot +
Expand Down
Loading
Loading