Skip to content

Commit

Permalink
closes #58
Browse files Browse the repository at this point in the history
  • Loading branch information
aravindhebbali committed Oct 18, 2018
1 parent 3cb051d commit 1878f69
Show file tree
Hide file tree
Showing 19 changed files with 224 additions and 80 deletions.
12 changes: 11 additions & 1 deletion R/blr-backward-elimination.R
Expand Up @@ -17,6 +17,7 @@
#' \code{"blr_step_aic_backward"}. An object of class
#' \code{"blr_step_aic_backward"} is a list containing the following components:
#'
#' \item{model}{model with the least AIC; an object of class \code{glm}}
#' \item{candidates}{candidate predictor variables}
#' \item{steps}{total number of steps}
#' \item{predictors}{variables removed from the model}
Expand All @@ -40,6 +41,11 @@
#'
#' # plot
#' plot(blr_step_aic_backward(model))
#'
#' # final model
#' k <- blr_step_aic_backward(model)
#' k$model
#'
#' }
#'
#' @family variable selection procedures
Expand Down Expand Up @@ -256,13 +262,17 @@ blr_step_aic_backward.default <- function(model, details = FALSE, ...) {
print(fi)
}

final_model <- glm(paste(response, "~", paste(preds, collapse = " + ")),
data = l, family = binomial(link = 'logit'))

out <- list(
candidates = nam,
steps = step,
predictors = rpred,
aics = laic,
bics = lbic,
devs = ldev
devs = ldev,
model = final_model
)

class(out) <- "blr_step_aic_backward"
Expand Down
12 changes: 11 additions & 1 deletion R/blr-forward-selection.R
Expand Up @@ -16,6 +16,7 @@
#' \code{"blr_step_aic_forward"}. An object of class
#' \code{"blr_step_aic_forward"} is a list containing the following components:
#'
#' \item{model}{model with the least AIC; an object of class \code{glm}}
#' \item{candidates}{candidate predictor variables}
#' \item{steps}{total number of steps}
#' \item{predictors}{variables entered into the model}
Expand All @@ -39,6 +40,11 @@
#'
#' # plot
#' plot(blr_step_aic_forward(model))
#'
#' # final model
#' k <- blr_step_aic_forward(model)
#' k$model
#'
#' }
#'
#' @importFrom shiny isRunning
Expand Down Expand Up @@ -273,13 +279,17 @@ blr_step_aic_forward.default <- function(model, details = FALSE, ...) {
print(fi)
}

final_model <- glm(paste(response, "~", paste(preds, collapse = " + ")),
data = l, family = binomial(link = 'logit'))

out <- list(
candidates = nam,
steps = step,
predictors = preds,
aics = laic,
bics = lbic,
devs = ldev
devs = ldev,
model = final_model
)

class(out) <- "blr_step_aic_forward"
Expand Down
11 changes: 10 additions & 1 deletion R/blr-stepwise-backward-regression.R
Expand Up @@ -18,6 +18,7 @@
#' An object of class \code{"blr_step_p_backward"} is a list containing the
#' following components:
#'
#' \item{model}{model with the least AIC; an object of class \code{glm}}
#' \item{steps}{total number of steps}
#' \item{removed}{variables removed from the model}
#' \item{aic}{akaike information criteria}
Expand All @@ -40,6 +41,10 @@
#' data = hsb2, family = binomial(link = 'logit'))
#' k <- blr_step_p_backward(model)
#' plot(k)
#'
#' # final model
#' k$model
#'
#' }
#'
#' @importFrom dplyr full_join select
Expand Down Expand Up @@ -167,12 +172,16 @@ blr_step_p_backward.default <- function(model, prem = 0.3, details = FALSE, ...)
)
print(fi)

final_model <- glm(paste(response, "~", paste(preds, collapse = " + ")),
data = l, family = binomial(link = 'logit'))

out <- list(removed = rpred,
indvar = cterms,
steps = step,
bic = bic,
aic = aic,
dev = dev)
dev = dev,
model = final_model)

class(out) <- "blr_step_p_backward"

Expand Down
10 changes: 9 additions & 1 deletion R/blr-stepwise-forward-regression.R
Expand Up @@ -18,6 +18,7 @@
#' An object of class \code{"blr_step_p_forward"} is a list containing the
#' following components:
#'
#' \item{model}{model with the least AIC; an object of class \code{glm}}
#' \item{steps}{number of steps}
#' \item{predictors}{variables added to the model}
#' \item{aic}{akaike information criteria}
Expand All @@ -44,6 +45,10 @@
#' family = binomial(link = 'logit'))
#' k <- blr_step_p_forward(model)
#' plot(k)
#'
#' # final model
#' k$model
#'
#' }
#'
#' @importFrom stats qt
Expand Down Expand Up @@ -231,13 +236,16 @@ blr_step_p_forward.default <- function(model, penter = 0.3, details = FALSE, ...
)
print(fi)

final_model <- glm(paste(response, "~", paste(preds, collapse = " + ")),
data = l, family = binomial(link = 'logit'))

out <- list(predictors = preds,
indvar = cterms,
steps = step,
bic = bic,
aic = aic,
dev = dev)
dev = dev,
model = final_model)

class(out) <- "blr_step_p_forward"

Expand Down
11 changes: 10 additions & 1 deletion R/blr-stepwise-regression.R
Expand Up @@ -19,6 +19,7 @@
#' An object of class \code{"blr_step_p_both"} is a list containing the
#' following components:
#'
#' \item{model}{final model; an object of class \code{glm}}
#' \item{orders}{candidate predictor variables according to the order by which they were added or removed from the model}
#' \item{method}{addition/deletion}
#' \item{steps}{total number of steps}
Expand All @@ -41,6 +42,10 @@
#' model <- glm(y ~ ., data = stepwise)
#' k <- blr_step_p_both(model)
#' plot(k)
#'
#' # final model
#' k$model
#'
#' }
#'
#' @family variable selection_procedures
Expand Down Expand Up @@ -329,6 +334,9 @@ blr_step_p_both.default <- function(model, pent = 0.1, prem = 0.3, details = FAL
)
print(fi)

final_model <- glm(paste(response, "~", paste(preds, collapse = " + ")),
data = l, family = binomial(link = 'logit'))

out <- list(
orders = var_index,
method = method,
Expand All @@ -337,7 +345,8 @@ blr_step_p_both.default <- function(model, pent = 0.1, prem = 0.3, details = FAL
aic = aic,
bic = bic,
dev = dev,
indvar = cterms
indvar = cterms,
model = final_model
)

class(out) <- "blr_step_p_both"
Expand Down
12 changes: 11 additions & 1 deletion R/blr-stepwise-selection.R
Expand Up @@ -16,6 +16,7 @@
#' An object of class \code{"blr_step_aic_both"} is a list containing the
#' following components:
#'
#' \item{model}{model with the least AIC; an object of class \code{glm}}
#' \item{candidates}{candidate predictor variables}
#' \item{predictors}{variables added/removed from the model}
#' \item{method}{addition/deletion}
Expand All @@ -39,6 +40,11 @@
#'
#' # plot
#' plot(blr_step_aic_both(model))
#'
#' # final model
#' k <- blr_step_aic_both(model)
#' k$model
#'
#' }
#'
#' @family variable selection procedures
Expand Down Expand Up @@ -286,14 +292,18 @@ blr_step_aic_both.default <- function(model, details = FALSE, ...) {
print(fi)
}

final_model <- glm(paste(response, "~", paste(preds, collapse = " + ")),
data = l, family = binomial(link = 'logit'))

out <- list(
candidates = nam,
predictors = var_index,
method = method,
aic = laic,
bic = lbic,
dev = ldev,
steps = all_step
steps = all_step,
model = final_model
)

class(out) <- "blr_step_aic_both"
Expand Down
11 changes: 10 additions & 1 deletion docs/reference/blr_step_aic_backward.html

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

11 changes: 10 additions & 1 deletion docs/reference/blr_step_aic_both.html

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

11 changes: 10 additions & 1 deletion docs/reference/blr_step_aic_forward.html

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

10 changes: 9 additions & 1 deletion docs/reference/blr_step_p_backward.html

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

0 comments on commit 1878f69

Please sign in to comment.