Title: | Exploratory Regression 'Shiny' App |
---|---|
Description: | Constructs a 'shiny' app function with interactive displays for summary and analysis of variance regression tables, and parallel coordinate plots of data and residuals. |
Authors: | Catherine B. Hurley |
Maintainer: | Catherine B. Hurley <[email protected]> |
License: | GPL (>= 2.0) |
Version: | 0.1.4 |
Built: | 2025-02-11 03:12:06 UTC |
Source: | https://github.com/cran/ERSA |
Constructs a list of fits by adding predictors sequentially
add1_models(model, preds, data = NULL)
add1_models(model, preds, data = NULL)
model |
A linear model |
preds |
Predictors to be added sequentially |
data |
The dataset (optional) |
A list of linear fits
A function which returns a shiny server for Exploratory Regression
createERServer( ERfit, ERdata = NULL, ERbarcols = RColorBrewer::brewer.pal(4, "Set2"), ERnpcpCols = 4, pvalOrder = F )
createERServer( ERfit, ERdata = NULL, ERbarcols = RColorBrewer::brewer.pal(4, "Set2"), ERnpcpCols = 4, pvalOrder = F )
ERfit |
the lm fit to be explored |
ERdata |
the data used to fit the model. If NULL, attempts to extract from ERfit. |
ERbarcols |
a vector of colours, one per term in lm. Will be expanded via colorRampPalette if not the correct length. |
ERnpcpCols |
number of colours for the PCP |
pvalOrder |
if TRUE, re-arranges predictors in order of p-value |
a function
Constructs UI for Exploratory Regression app
createERUI(tablesOnly = F, gadget = TRUE)
createERUI(tablesOnly = F, gadget = TRUE)
tablesOnly |
if TRUE, shows Plots 1-3 only. |
gadget |
If TRUE, constructs a gadget, otherwise a shinyApp |
the UI
Constructs a list of fits by dropping predictors from the supplied model
drop1_models(model, preds, data = NULL)
drop1_models(model, preds, data = NULL)
model |
A linear model |
preds |
Predictors to be dropped |
data |
The dataset (optional) |
A list of linear fits
The Exploratory Regression Shiny App (ERSA) package consists of a collection of functions for displaying the results of a regression calculation, which are then packaged together as a shiny app function.
A function to launch the Exploratory Regression Shiny App
exploreReg( ERmfull, ERdata = NULL, ERbarcols = RColorBrewer::brewer.pal(4, "Set2"), npcpCols = 4, pvalOrder = F, tablesOnly = F, displayHeight = NULL, gadget = TRUE, viewer = "dialogViewer" )
exploreReg( ERmfull, ERdata = NULL, ERbarcols = RColorBrewer::brewer.pal(4, "Set2"), npcpCols = 4, pvalOrder = F, tablesOnly = F, displayHeight = NULL, gadget = TRUE, viewer = "dialogViewer" )
ERmfull |
the lm fit to be explored |
ERdata |
the data used to fit the model. If NULL, attempts to extract from ERmfull. |
ERbarcols |
a vector of colours, one per term in lm. Will be expanded via colorRampPalette if not the correct length. |
npcpCols |
number of colours for the PCP |
pvalOrder |
if TRUE, re-arranges predictors in order of p-value |
tablesOnly |
if TRUE, shows Plots 1-3 only. |
displayHeight |
supply a value for the display height |
gadget |
If TRUE, constructs a gadget, otherwise a shinyApp. |
viewer |
For gadget, defaults to "dialogViewer". May be "paneViewer" or "browserViewer" |
the result
f <- lm(mpg ~ hp+wt+disp, data=mtcars) ## Not run: exploreReg(f)
f <- lm(mpg ~ hp+wt+disp, data=mtcars) ## Not run: exploreReg(f)
A PCP plot of the data, residuals or hat values from regression fits
pcpPlot( data, fit, type = "Variables", npcpCols = 4, resDiff = F, absResid = F, sequential = F, selnum = NULL )
pcpPlot( data, fit, type = "Variables", npcpCols = 4, resDiff = F, absResid = F, sequential = F, selnum = NULL )
data |
a data frame |
fit |
a lm for the data frame |
type |
one of "Variables", "Residuals", "Hatvalues" |
npcpCols |
number of colours |
resDiff |
difference residuals, TRUE or FALSE |
absResid |
absolute residuals, TRUE or FALSE |
sequential |
use sequential fits (TRUE) or drop1 fits (FALSE) |
selnum |
row numbers of cases to be highlighted |
ggplot
f <- lm(mpg ~ wt+hp+disp, data=mtcars) pcpPlot(mtcars, f, type="Residuals")
f <- lm(mpg ~ wt+hp+disp, data=mtcars) pcpPlot(mtcars, f, type="Residuals")
Plots barcharts of sequential sums of squares of lm
plotSeqSS(fits, barcols = NULL, legend = F)
plotSeqSS(fits, barcols = NULL, legend = F)
fits |
list of lm objects |
barcols |
a vector of colours, one per term in lms |
legend |
TRUE or FALSE |
a ggplot
plotSeqSS(list(fit1= lm(mpg ~ wt+hp+disp, data=mtcars), fit2=lm(mpg ~ wt*hp*disp, data=mtcars)))
plotSeqSS(list(fit1= lm(mpg ~ wt+hp+disp, data=mtcars), fit2=lm(mpg ~ wt*hp*disp, data=mtcars)))
Plots of model summaries
plotAnovaStats( fit0, barcols = NULL, preds = NULL, alpha = 0.05, type = "SS", width = 0.3 ) plottStats(fit0, barcols = NULL, preds = NULL, alpha = 0.05, width = 0.3) plotCIStats( fit0, barcols = NULL, preds = NULL, alpha = 0.05, stdunits = FALSE, width = 0.3 )
plotAnovaStats( fit0, barcols = NULL, preds = NULL, alpha = 0.05, type = "SS", width = 0.3 ) plottStats(fit0, barcols = NULL, preds = NULL, alpha = 0.05, width = 0.3) plotCIStats( fit0, barcols = NULL, preds = NULL, alpha = 0.05, stdunits = FALSE, width = 0.3 )
fit0 |
is an lm object |
barcols |
a vector of colours, one per term in lm |
preds |
terms to include in plot |
alpha |
significance level |
type |
"SS" or "F", from type 3 Anova |
width |
bar width |
stdunits |
TRUE or FALSE. If TRUE, coefficients refer to standardised predictor units. |
a ggplot
plotAnovaStats()
: Plots barchart of F or SS from lm
plottStats()
: Plots barchart of t stats from lm
plotCIStats()
: Plots confidence intervals from lm
plotAnovaStats(lm(mpg ~ wt+hp+disp, data=mtcars)) plottStats(lm(mpg ~ wt+hp+disp, data=mtcars)) plotCIStats(lm(mpg ~ wt+hp+disp, data=mtcars))
plotAnovaStats(lm(mpg ~ wt+hp+disp, data=mtcars)) plottStats(lm(mpg ~ wt+hp+disp, data=mtcars)) plotCIStats(lm(mpg ~ wt+hp+disp, data=mtcars))
Re-order model terms
pvalOrder(m, d = NULL, refit = TRUE) bselOrder(m, d = NULL, refit = TRUE, maxNPred = NULL) fselOrder(m, d = NULL, refit = TRUE, maxNPred = NULL) revPredOrder(m, d = NULL, refit = TRUE) randomPredOrder(m, d = NULL, refit = TRUE) regsubsetsOrder(m, d = NULL, refit = TRUE, collapse = TRUE)
pvalOrder(m, d = NULL, refit = TRUE) bselOrder(m, d = NULL, refit = TRUE, maxNPred = NULL) fselOrder(m, d = NULL, refit = TRUE, maxNPred = NULL) revPredOrder(m, d = NULL, refit = TRUE) randomPredOrder(m, d = NULL, refit = TRUE) regsubsetsOrder(m, d = NULL, refit = TRUE, collapse = TRUE)
m |
an lm objecct |
d |
the data frame. If NULL, attempts to extract from m. |
refit |
TRUE or FALSE |
maxNPred |
maximum number of predictors to use, defaults to all. |
collapse |
TRUE or FALSE |
a vector of terms in order last to first, or an lm if refit=TRUE. regsubsetsOrder returns a list of predictor vectors, or a list of fits
pvalOrder()
: Arranges model terms in order of increasing p-value
bselOrder()
: Arranges model terms using backwards selection
fselOrder()
: Forwards selection
revPredOrder()
: Reverses order of terms in a fit
randomPredOrder()
: Reorders terms in a fit randomly
regsubsetsOrder()
: Best subsets regression.
bselOrder(lm(mpg~wt+hp+disp, data=mtcars)) fselOrder(lm(mpg~wt+hp+disp, data=mtcars)) revPredOrder(lm(mpg~wt+hp+disp, data=mtcars)) randomPredOrder(lm(mpg~wt+hp+disp, data=mtcars)) regsubsetsOrder(lm(mpg~wt+hp+disp, data=mtcars))
bselOrder(lm(mpg~wt+hp+disp, data=mtcars)) fselOrder(lm(mpg~wt+hp+disp, data=mtcars)) revPredOrder(lm(mpg~wt+hp+disp, data=mtcars)) randomPredOrder(lm(mpg~wt+hp+disp, data=mtcars)) regsubsetsOrder(lm(mpg~wt+hp+disp, data=mtcars))
Constructs colour vector for model terms
termColours(f, pal = RColorBrewer::brewer.pal(4, "Set2"))
termColours(f, pal = RColorBrewer::brewer.pal(4, "Set2"))
f |
a model fit with term labels |
pal |
use this palette |
a vector of colours. Residuals are given a grey color
termColours(lm(mpg ~ wt+hp, data=mtcars))
termColours(lm(mpg ~ wt+hp, data=mtcars))