Skip to content

Commit 8e54231

Browse files
Merge pull request #219 from rsquaredacademy/develop
CRAN release
2 parents c33e533 + 0e2f959 commit 8e54231

28 files changed

+346
-226
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@
1717
^\.github$
1818
^CODE_OF_CONDUCT\.md$
1919
^revdep$
20+
TODO.md

.github/workflows/rhub.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# R-hub's generic GitHub Actions workflow file. It's canonical location is at
2+
# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml
3+
# You can update this file to a newer version using the rhub2 package:
4+
#
5+
# rhub::rhub_setup()
6+
#
7+
# It is unlikely that you need to modify this file manually.
8+
9+
name: R-hub
10+
run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}"
11+
12+
on:
13+
workflow_dispatch:
14+
inputs:
15+
config:
16+
description: 'A comma separated list of R-hub platforms to use.'
17+
type: string
18+
default: 'linux,windows,macos'
19+
name:
20+
description: 'Run name. You can leave this empty now.'
21+
type: string
22+
id:
23+
description: 'Unique ID. You can leave this empty now.'
24+
type: string
25+
26+
jobs:
27+
28+
setup:
29+
runs-on: ubuntu-latest
30+
outputs:
31+
containers: ${{ steps.rhub-setup.outputs.containers }}
32+
platforms: ${{ steps.rhub-setup.outputs.platforms }}
33+
34+
steps:
35+
# NO NEED TO CHECKOUT HERE
36+
- uses: r-hub/actions/setup@v1
37+
with:
38+
config: ${{ github.event.inputs.config }}
39+
id: rhub-setup
40+
41+
linux-containers:
42+
needs: setup
43+
if: ${{ needs.setup.outputs.containers != '[]' }}
44+
runs-on: ubuntu-latest
45+
name: ${{ matrix.config.label }}
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
config: ${{ fromJson(needs.setup.outputs.containers) }}
50+
container:
51+
image: ${{ matrix.config.container }}
52+
53+
steps:
54+
- uses: r-hub/actions/checkout@v1
55+
- uses: r-hub/actions/platform-info@v1
56+
with:
57+
token: ${{ secrets.RHUB_TOKEN }}
58+
job-config: ${{ matrix.config.job-config }}
59+
- uses: r-hub/actions/setup-deps@v1
60+
with:
61+
token: ${{ secrets.RHUB_TOKEN }}
62+
job-config: ${{ matrix.config.job-config }}
63+
- uses: r-hub/actions/run-check@v1
64+
with:
65+
token: ${{ secrets.RHUB_TOKEN }}
66+
job-config: ${{ matrix.config.job-config }}
67+
68+
other-platforms:
69+
needs: setup
70+
if: ${{ needs.setup.outputs.platforms != '[]' }}
71+
runs-on: ${{ matrix.config.os }}
72+
name: ${{ matrix.config.label }}
73+
strategy:
74+
fail-fast: false
75+
matrix:
76+
config: ${{ fromJson(needs.setup.outputs.platforms) }}
77+
78+
steps:
79+
- uses: r-hub/actions/checkout@v1
80+
- uses: r-hub/actions/setup-r@v1
81+
with:
82+
job-config: ${{ matrix.config.job-config }}
83+
token: ${{ secrets.RHUB_TOKEN }}
84+
- uses: r-hub/actions/platform-info@v1
85+
with:
86+
token: ${{ secrets.RHUB_TOKEN }}
87+
job-config: ${{ matrix.config.job-config }}
88+
- uses: r-hub/actions/setup-deps@v1
89+
with:
90+
job-config: ${{ matrix.config.job-config }}
91+
token: ${{ secrets.RHUB_TOKEN }}
92+
- uses: r-hub/actions/run-check@v1
93+
with:
94+
job-config: ${{ matrix.config.job-config }}
95+
token: ${{ secrets.RHUB_TOKEN }}

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: olsrr
22
Type: Package
33
Title: Tools for Building OLS Regression Models
4-
Version: 0.6.0.9000
4+
Version: 0.6.1
55
Authors@R: person("Aravind", "Hebbali", email = "hebbali.aravind@gmail.com", role = c("aut", "cre"))
66
Description: Tools designed to make it easier for users, particularly beginner/intermediate R users
77
to build ordinary least squares regression models. Includes comprehensive regression output,
@@ -33,5 +33,5 @@ Encoding: UTF-8
3333
LazyData: true
3434
VignetteBuilder: knitr
3535
Roxygen: list(markdown = TRUE)
36-
RoxygenNote: 7.2.3
36+
RoxygenNote: 7.3.2
3737
Config/testthat/edition: 3

NAMESPACE

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ importFrom(stats,complete.cases)
213213
importFrom(stats,confint.lm)
214214
importFrom(stats,cooks.distance)
215215
importFrom(stats,cor)
216+
importFrom(stats,deviance)
216217
importFrom(stats,df.residual)
217218
importFrom(stats,dfbetas)
218219
importFrom(stats,dffits)
@@ -245,7 +246,4 @@ importFrom(stats,sd)
245246
importFrom(stats,shapiro.test)
246247
importFrom(stats,var)
247248
importFrom(utils,combn)
248-
importFrom(utils,install.packages)
249-
importFrom(utils,menu)
250-
importFrom(utils,packageVersion)
251249
importFrom(utils,tail)

NEWS.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
# olsrr 0.6.0.9000
1+
# olsrr 0.6.1
2+
3+
This is a patch release for urgent bug fixes.
4+
5+
## Bug Fixes
6+
7+
- Limit maximum subset order in `ols_step_all_possible()` ([#202](https://github.com/rsquaredacademy/olsrr/issues/202))
8+
- Check model type ([#204](https://github.com/rsquaredacademy/olsrr/issues/204))
9+
- Mismatch in column names in `ols_step_all_possible()` ([#211](https://github.com/rsquaredacademy/olsrr/issues/211))
10+
- RMSE is not square root of MSE in `ols_regress()` ([#213](https://github.com/rsquaredacademy/olsrr/issues/213))
11+
- `geom_segment()` warning in `ols_plot_obs_fit()` ([#217](https://github.com/rsquaredacademy/olsrr/issues/217))
12+
- New snapshot added every time tests are run ([#218](https://github.com/rsquaredacademy/olsrr/issues/218))
213

314
# olsrr 0.6.0
415

R/ols-all-possible-regression.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ ols_step_all_possible.default <- function(model, max_order = NULL, ...) {
102102
print.ols_step_all_possible <- function(x, ...) {
103103

104104
n <- max(x$result$mindex)
105-
k <- data.frame(x$result)[, c(1:5, 7)]
105+
k <- data.frame(x$result)[, c(1:5, 8)]
106106
names(k) <- c("Index", "N", "Predictors", "R-Square", "Adj. R-Square", "Mallow's Cp")
107107
print(k)
108108

@@ -377,4 +377,4 @@ allpos_helper <- function(model, max_order = NULL) {
377377
)
378378

379379
return(result)
380-
}
380+
}

R/ols-best-subsets-regression.R

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#' # maximum subset
3333
#' model <- lm(mpg ~ disp + hp + drat + wt + qsec, data = mtcars)
3434
#' ols_step_best_subset(model, max_order = 3)
35-
#'
35+
#'
3636
#' # plot
3737
#' model <- lm(mpg ~ disp + hp + wt + qsec, data = mtcars)
3838
#' k <- ols_step_best_subset(model)
@@ -50,8 +50,8 @@ ols_step_best_subset <- function(model, ...) UseMethod("ols_step_best_subset")
5050

5151
#' @export
5252
#' @rdname ols_step_best_subset
53-
#'
54-
ols_step_best_subset.default <- function(model, max_order = NULL,
53+
#'
54+
ols_step_best_subset.default <- function(model, max_order = NULL,
5555
include = NULL, exclude = NULL,
5656
metric = c("rsquare", "adjr", "predrsq",
5757
"cp", "aic", "sbic", "sbc",
@@ -77,7 +77,7 @@ ols_step_best_subset.default <- function(model, max_order = NULL,
7777
stop(paste(paste(exclude[!npm], collapse = ", "), "not part of the model and hence cannot be forcibly excluded. Please verify the variable names."), call. = FALSE)
7878
}
7979
}
80-
80+
8181
if (is.numeric(include)) {
8282
if (any(include > lenterms)) {
8383
stop(paste0("Index of variable to be included should be between 1 and ", lenterms, "."), call. = FALSE)
@@ -88,7 +88,7 @@ ols_step_best_subset.default <- function(model, max_order = NULL,
8888

8989
if (is.numeric(exclude)) {
9090
if (any(exclude > lenterms)) {
91-
stop(paste0("Index of variable to be excluded should be between 1 and ", lenterms, "."), call. = FALSE)
91+
stop(paste0("Index of variable to be excluded should be between 1 and ", lenterms, "."), call. = FALSE)
9292
} else {
9393
exclude <- indterms[exclude]
9494
}
@@ -152,23 +152,23 @@ ols_step_best_subset.default <- function(model, max_order = NULL,
152152
lpreds <- c()
153153

154154
for (i in seq_len(len_elig)) {
155-
predictors <- predicts[[i]]
156-
lp <- length(predictors)
157-
out <- ols_regress(paste(response, "~", paste(predictors, collapse = " + ")), data = data)
158-
mcount <- mcount + 1
159-
lpreds[mcount] <- lp
160-
rsq[[mcount]] <- out$rsq
161-
adjr[[mcount]] <- out$adjr
162-
cp[[mcount]] <- ols_mallows_cp(out$model, model)
163-
aic[[mcount]] <- ols_aic(out$model)
164-
sbic[[mcount]] <- ols_sbic(out$model, model)
165-
sbc[[mcount]] <- ols_sbc(out$model)
166-
gmsep[[mcount]] <- ols_msep(out$model)
167-
jp[[mcount]] <- ols_fpe(out$model)
168-
pc[[mcount]] <- ols_apc(out$model)
169-
sp[[mcount]] <- ols_hsp(out$model)
170-
predrsq[[mcount]] <- ols_pred_rsq(out$model)
171-
preds[[mcount]] <- paste(predictors, collapse = " ")
155+
predictors <- predicts[[i]]
156+
lp <- length(predictors)
157+
out <- ols_regress(paste(response, "~", paste(predictors, collapse = " + ")), data = data)
158+
mcount <- mcount + 1
159+
lpreds[mcount] <- lp
160+
rsq[[mcount]] <- out$rsq
161+
adjr[[mcount]] <- out$adjr
162+
cp[[mcount]] <- ols_mallows_cp(out$model, model)
163+
aic[[mcount]] <- ols_aic(out$model)
164+
sbic[[mcount]] <- ols_sbic(out$model, model)
165+
sbc[[mcount]] <- ols_sbc(out$model)
166+
gmsep[[mcount]] <- ols_msep(out$model)
167+
jp[[mcount]] <- ols_fpe(out$model)
168+
pc[[mcount]] <- ols_apc(out$model)
169+
sp[[mcount]] <- ols_hsp(out$model)
170+
predrsq[[mcount]] <- ols_pred_rsq(out$model)
171+
preds[[mcount]] <- paste(predictors, collapse = " ")
172172
}
173173

174174
ui <- data.frame(
@@ -197,13 +197,13 @@ ols_step_best_subset.default <- function(model, max_order = NULL,
197197
} else {
198198
temp <- lapply(l, function(x) x[order(x[[metrics]]), ][1, ])
199199
}
200-
200+
201201
sorted <- do.call(rbind, temp)
202202
mindex <- seq_len(nrow(sorted))
203203
sorted <- cbind(mindex, sorted)
204204
result <- list(metrics = sorted)
205205
class(result) <- c("ols_step_best_subset")
206-
206+
207207
return(result)
208208

209209
}
@@ -261,8 +261,8 @@ best_subset_plot <- function(d, var, title = "R-Square") {
261261
ggplot(d1, aes(x = a, y = b)) +
262262
geom_line(color = "blue") +
263263
geom_point(color = "blue", shape = 1, size = 2) +
264-
xlab("") +
265-
ylab("") +
264+
xlab("") +
265+
ylab("") +
266266
ggtitle(title) +
267267
theme(axis.ticks = element_blank())
268268

R/ols-observed-vs-predicted-plot.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,20 @@ ols_plot_obs_fit <- function(model, print_plot = TRUE) {
2727

2828
oname <- names(model.frame(model))[1]
2929
d <- obspred(model)
30+
df <- data.frame(x1 = min(d$x), x2 = max(d$x), y1 = min(d$y), y2 = max(d$y))
3031

3132
p <-
3233
ggplot(d, aes(x = x, y = y)) +
3334
geom_point(color = "blue", shape = 1) +
34-
geom_segment(data = d, aes(x = min(x), y = min(y), xend = max(x),
35-
yend = max(y)), colour = "red") +
35+
geom_segment(data = df, aes(x = x1, y = y1, xend = x2,
36+
yend = y2), colour = "red") +
3637
geom_abline(intercept = 0, slope = 1, color = "blue")
3738

3839
p <-
3940
p +
4041
ylab("Fitted Value") +
4142
xlab(paste(oname)) +
42-
ggtitle(paste("Actual vs Fitted for", oname))
43+
ggtitle(paste("Actual vs Fitted for", oname))
4344

4445
if (print_plot) {
4546
print(p)

R/ols-regress_compute.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#' @importFrom stats model.matrix confint.lm
2-
#' @importFrom stats as.formula
2+
#' @importFrom stats as.formula deviance
33
reg_comp <- function(formula, data, conf.level = 0.95, iterm, title = "model") {
44

55
model <- lm(formula = formula, data = data)
@@ -20,7 +20,7 @@ reg_comp <- function(formula, data, conf.level = 0.95, iterm, title = "model") {
2020
sbic <- ols_sbic(model, model)
2121
prsq <- ols_pred_rsq(model)
2222
n <- length(anovam$Df)
23-
mse <- anovam$`Mean Sq`[n]
23+
mse <- mean(model$residuals ^ 2)
2424
error_df <- anovam$Df[n]
2525
model_df <- sum(anovam$Df) - error_df
2626
total_df <- sum(anovam$Df)

R/olsrr.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ if (getRversion() >= "2.15.1") {
2020
"txt", "cd", "fct_color", "ckd", "dbetas", "color", "pred", "ds", "dsr",
2121
"fstatistic", "hadi", "Df", "res", "pot", "lfit", "rerror", "ybar",
2222
"yhat", "predicted", "resid", "lev_thrsh", "leverage", "levrstud",
23-
"sdres"))
23+
"sdres", "x1", "x2", "y1", "y2"))
2424
}

0 commit comments

Comments
 (0)