fit.models/0000755000176200001440000000000013711546752012331 5ustar liggesusersfit.models/NAMESPACE0000644000176200001440000000402613711543251013541 0ustar liggesusers# Generated by roxygen2: do not edit by hand S3method(center,default) S3method(coef,glmfm) S3method(coef,lmfm) S3method(designMD,default) S3method(plot,covfm) S3method(plot,glmfm) S3method(plot,lmfm) S3method(print,covfm) S3method(print,glmfm) S3method(print,lmfm) S3method(print,summary.covfm) S3method(print,summary.glmfm) S3method(print,summary.lmfm) S3method(summary,covfm) S3method(summary,glmfm) S3method(summary,lmfm) S3method(vcor,default) S3method(vcov,default) export(center) export(ddPlot.covfm) export(designMD) export(distancePlot.covfm) export(ellipsesPlot.covfm) export(fit.models) export(fmclass.add.class) export(fmclass.register) export(overlaidKernelDensityPlot) export(overlaidQQPlot) export(overlaidSimpleRegressionPlot) export(screePlot.covfm) export(sideBySideIndexPlot) export(sideBySideKernelDensityPlot) export(sideBySideQQPlot) export(sideBySideScatterPlot) export(vcor) importFrom(graphics,legend) importFrom(graphics,lines) importFrom(graphics,par) importFrom(graphics,plot) importFrom(graphics,polygon) importFrom(graphics,strheight) importFrom(graphics,strwidth) importFrom(graphics,text) importFrom(lattice,densityplot) importFrom(lattice,llines) importFrom(lattice,panel.abline) importFrom(lattice,panel.densityplot) importFrom(lattice,panel.loess) importFrom(lattice,panel.rug) importFrom(lattice,panel.text) importFrom(lattice,panel.xyplot) importFrom(lattice,qqmath) importFrom(lattice,simpleKey) importFrom(lattice,strip.default) importFrom(lattice,xyplot) importFrom(stats,as.formula) importFrom(stats,coef) importFrom(stats,cov2cor) importFrom(stats,fitted) importFrom(stats,formula) importFrom(stats,mahalanobis) importFrom(stats,model.frame) importFrom(stats,model.matrix) importFrom(stats,model.response) importFrom(stats,predict) importFrom(stats,printCoefmat) importFrom(stats,qchisq) importFrom(stats,qnorm) importFrom(stats,qqnorm) importFrom(stats,quantile) importFrom(stats,residuals) importFrom(stats,rnorm) importFrom(stats,terms) importFrom(stats,var) importFrom(stats,vcov) importFrom(utils,menu) export(plot.glmfm) fit.models/man/0000755000176200001440000000000013710035571013073 5ustar liggesusersfit.models/man/overlaidSimpleRegressionPlot.Rd0000644000176200001440000000146113647572427021262 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/overlaidSimpleRegressionPlot.R \name{overlaidSimpleRegressionPlot} \alias{overlaidSimpleRegressionPlot} \title{Scatter Plot with Overlaid Fits} \usage{ overlaidSimpleRegressionPlot(x, lwd.reg, col.reg, ...) } \arguments{ \item{x}{a \code{fit.models} object.} \item{lwd.reg}{a vector with length equal to the number of models in \code{x} specifying the line widths used in the plot.} \item{col.reg}{a vector with length equal to the number of models in \code{x} specifying the line colors used in the plot.} \item{\dots}{additional arguments are passed to \code{\link[lattice]{xyplot}}.} } \value{ the \code{trellis} object is invisibly returned. } \description{ Produces a scatter plot of the data with overlaid fits. } \keyword{hplot} fit.models/man/fmclass.Rd0000644000176200001440000000211613647572427015031 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/fmclass.register.R \name{fmclass.register} \alias{fmclass.register} \alias{fmclass.add.class} \title{Register Comparable Functions} \usage{ fmclass.register(fmclass, classes, validation.function = NULL) fmclass.add.class(fmclass, class, warn = TRUE) } \arguments{ \item{fmclass}{a character string naming the fit.models class to be added.} \item{classes}{a character vector naming one or more classes that can be compared by the methods defined for the fit.models class in \code{fmclass}.} \item{validation.function}{a function returning \code{TRUE} when the models are comparable.} \item{class}{a character string specifying a class compatible with the methods of \code{fmclass}.} \item{warn}{a logical value. If TRUE, a warning is printed if \code{class} is already registered.} } \value{ a null value is invisibly returned. } \description{ The \code{fit.models} package maintains a list of comparable models. These functions provide an api to modify this list. } \details{ See the package vignette. } \keyword{misc} fit.models/man/overlaidQQPlot.Rd0000644000176200001440000000103613647572427016307 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/overlaidQQPlot.R \name{overlaidQQPlot} \alias{overlaidQQPlot} \title{Overlaid Normal QQ Plot} \usage{ overlaidQQPlot(x, fun, ...) } \arguments{ \item{x}{a \code{fit.models} object.} \item{fun}{a function to extract the desired quantity from \code{x}.} \item{\dots}{additional arguments are passed to \code{\link[lattice]{qqmath}}.} } \value{ the \code{trellis} object is invisibly returned. } \description{ Produces an overlaid normal QQ plot. } \keyword{hplot} fit.models/man/sideBySideKernelDensityPlot.Rd0000644000176200001440000000116213647572427020765 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/sideBySideKernelDensityPlot.R \name{sideBySideKernelDensityPlot} \alias{sideBySideKernelDensityPlot} \title{Comparison Kernel Density Estimate Plot} \usage{ sideBySideKernelDensityPlot(x, fun, ...) } \arguments{ \item{x}{a \code{fit.models} object.} \item{fun}{a function to extract the desired quantity from \code{x}.} \item{\dots}{additional arguments are passed to \code{\link[lattice]{xyplot}}.} } \value{ the \code{trellis} object is invisibly returned. } \description{ Produces side-by-side kernel density estimate plots. } \keyword{hplot} fit.models/man/summary.glmfm.Rd0000644000176200001440000000217713647572427016206 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/summary.glmfm.R \name{summary.glmfm} \alias{summary.glmfm} \title{Comparison Summaries for Generalized Linear Models} \usage{ \method{summary}{glmfm}(object, correlation = FALSE, ...) } \arguments{ \item{object}{a glmfm object.} \item{correlation}{a logical value. If \code{TRUE}, correlation matrices of the coefficient estimates are included in each summary.} \item{\dots}{additional arguments required by the generic \code{\link{summary}} function.} } \value{ a list with class summary.glmfm whose elements are summaries of each model in \code{object}. } \description{ Compute a summary of each model in a \code{glmfm} object. } \examples{ # From ?glm: # A Gamma example, from McCullagh & Nelder (1989, pp. 300-2) clotting <- data.frame( u = c(5,10,15,20,30,40,60,80,100), lot1 = c(118,58,42,35,27,25,21,19,18), lot2 = c(69,35,26,21,18,16,13,12,12)) lot1 <- glm(lot1 ~ log(u), data = clotting, family = Gamma) lot2 <- glm(lot2 ~ log(u), data = clotting, family = Gamma) fm <- fit.models(lot1, lot2) summary(fm) } \keyword{methods} \keyword{regression} fit.models/man/vcor.Rd0000644000176200001440000000120713701343510014326 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/covfm.R \name{vcor} \alias{vcor} \title{Calculate Correlation Matrix for a Fitted Model Object} \usage{ vcor(object, ...) } \arguments{ \item{object}{a fitted model object, typically. Sometimes also a \code{summary()} object of such a fitted model.} \item{\dots}{additional arguments for method functions.} } \description{ Retrieve a correlation matrix estimate from a fitted model object. The default method uses \code{\link[stats]{cov2cor}} to scale the covariance matrix returned by \code{\link[stats]{vcov}}. } fit.models/man/ddPlot.covfm.Rd0000644000176200001440000000204613647572427015742 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/ddPlot.covfm.R \name{ddPlot.covfm} \alias{ddPlot.covfm} \title{Distance - Distance Plot} \usage{ ddPlot.covfm(x, level = 0.95, strip = "", id.n = 3, ...) } \arguments{ \item{x}{a \code{"covfm"} object.} \item{level}{a single numeric value between 0 and 1 giving the chi-squared percent point used to compute the outlyingness threshold.} \item{strip}{a character string printed in the \dQuote{strip} at the top of the plot.} \item{id.n}{a single nonnegative integer specifying the number of extreme points to label in the plot.} \item{...}{additional arguments are passed to \code{xyplot}.} } \value{ if the models can be compared then the plotted \code{trellis} object is invisibly returned. Otherwise \code{x} is returned invisibly. } \description{ For a \code{covfm} object containing 2 models, this function plots the Mahalanobis distance from the first model on the y-axis and the Mahalanobis distance from the second model on the x-axis. } fit.models/man/designMD.Rd0000644000176200001440000000174213647572427015077 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/designMD.R \name{designMD} \alias{designMD} \alias{designMD.default} \title{Design Matrix Mahalanobis Distance} \usage{ designMD(object, ...) } \arguments{ \item{object}{a fitted model object with a \code{\link{model.matrix}} method.} \item{\dots}{additional arguments are ignored.} } \value{ a numeric vector containing the squared Mahalanobis distances. } \description{ Returns the squared Mahalanobis distance of all rows in the design (model) matrix \eqn{X} and the sample mean vector \eqn{\mu} of the columns of \eqn{X} with respect to the sample covariance matrix \eqn{\Sigma}. This is (for vector \eqn{x'} a row of \eqn{X}) defined as \deqn{d^{2} = (x - \mu)' \Sigma^{-1} (x - \mu)} where \deqn{\mu = colMeans(X)} and \deqn{\Sigma = cov(X).} } \examples{ stack.lm <- lm(stack.loss ~ ., data = stackloss) # Mahalanobis distance (not squared) sqrt(designMD(stack.lm)) } \keyword{methods} \keyword{regression} fit.models/man/summary.covfm.Rd0000644000176200001440000000104613710035564016173 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/summary.covfm.R \name{summary.covfm} \alias{summary.covfm} \title{Summary Method} \usage{ \method{summary}{covfm}(object, corr = FALSE, ...) } \arguments{ \item{object}{a \dQuote{covfm} object.} \item{corr}{a logical value passed as an attribute to the \code{print} method. When \code{TRUE}, correlations are compared in the textual output.} \item{\dots}{additional arguments for the summary method.} } \description{ Generic summary method for \dQuote{covfm} objects. } fit.models/man/summary.lmfm.Rd0000644000176200001440000000163713647572427016037 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/summary.lmfm.R \name{summary.lmfm} \alias{summary.lmfm} \title{Comparison Summaries for Linear Regression Models} \usage{ \method{summary}{lmfm}(object, correlation = FALSE, ...) } \arguments{ \item{object}{an \code{lmfm} object.} \item{correlation}{a logical value. If TRUE, the correlation matrices for the coefficients are included in the summaries.} \item{\dots}{additional arguments required by the generic \code{\link{summary}} function.} } \value{ a list with class summary.lmfm whose elements are summaries of each model in \code{object}. } \description{ Compute a summary of each model in an \code{lmfm} object. } \examples{ data(stackloss) m1 <- lm(stack.loss ~ ., data = stackloss) m2 <- lm(stack.loss ~ . - Acid.Conc., data = stackloss) fm <- fit.models(m1, m2) print(fm.sum <- summary(fm)) } \keyword{methods} \keyword{regression} fit.models/man/plot.covfm.Rd0000644000176200001440000000127213660763725015470 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/plot.covfm.R \name{plot.covfm} \alias{plot.covfm} \title{Plot Method} \usage{ \method{plot}{covfm}(x, which.plots = 1:4, ...) } \arguments{ \item{x}{a \code{covfm} object.} \item{which.plots}{either \code{"ask"} (character string) or an integer vector specifying which plots to draw. The plot options are (1) Mahalanobis Distance, (2) Ellipses Matrix, (3) Screeplot (Eigenvalues of Covariance Estimate), and (4) Distance - Distance Plot.} \item{...}{additional arguments are passed to the plot subfunctions.} } \value{ \code{x} is returned invisibly. } \description{ Generic plot method for \dQuote{covfm} objects. } fit.models/man/sideBySideScatterPlot.Rd0000644000176200001440000000111713647572427017612 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/sideBySideScatterPlot.R \name{sideBySideScatterPlot} \alias{sideBySideScatterPlot} \title{Comparison Scatter Plot} \usage{ sideBySideScatterPlot(object, x.fun, y.fun, ...) } \arguments{ \item{object}{a \code{fit.models} object.} \item{x.fun}{a function to extract the x-axis quantity.} \item{y.fun}{a function to extract the y-axis quantity.} \item{\dots}{additional arguments.} } \value{ the \code{trellis} object is invisibly returned. } \description{ Produces a side-by-side scatter plot. } \keyword{hplot} fit.models/man/ellipsesPlot.covfm.Rd0000644000176200001440000000174713647572427017202 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/ellipsesPlot.covfm.R \name{ellipsesPlot.covfm} \alias{ellipsesPlot.covfm} \title{Ellipses Plot - Visual Correlation Matrix Comparison} \usage{ ellipsesPlot.covfm(x, ...) } \arguments{ \item{x}{a \code{"covfm"} object.} \item{\dots}{additional arguments are ignored.} } \value{ x is invisibly returned. } \description{ When there are 3 or more variables in the data, this function produces a matrix with ellipses drawn in the upper triangle. The ellipse in cell \eqn{i,j} of the plot is drawn to be a contour of a standard bivariate normal with correlation \eqn{\rho_{ij}}. One ellipse is drawn in each cell for each model in the \code{covfm} object. When there are 2 variables in the data, this function produces a scatter plot of the data with an overlaid 95\% confidence ellipse for each model in the \code{covfm} object. } fit.models/man/sideBySideIndexPlot.Rd0000644000176200001440000000145713647572427017263 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/sideBySideIndexPlot.R \name{sideBySideIndexPlot} \alias{sideBySideIndexPlot} \title{Comparison Index (Time) Plot} \usage{ sideBySideIndexPlot(x, fun, level = 0.95, id.n = 3, ...) } \arguments{ \item{x}{a \code{fit.models} object.} \item{fun}{a function to extract the desired quantity from \code{x}.} \item{level}{a numeric value between 0 and 1 specifying the confidence level used to draw the threshold in the plot.} \item{id.n}{a non-negative integer value specifying the number of extreme points to identify.} \item{\dots}{any additional arguments are passed to \code{\link[lattice]{xyplot}}.} } \value{ the \code{trellis} object is invisibly returned. } \description{ Produces side-by-side index (time) plots. } \keyword{hplot} fit.models/man/plot.glmfm.Rd0000644000176200001440000000306113661227624015450 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/plot.glmfm.R \name{plot.glmfm} \alias{plot.glmfm} \title{Comparison Diagnostic Plots for Generalized Linear Models} \usage{ \method{plot}{glmfm}(x, which.plots = 1:6, ...) } \arguments{ \item{x}{a \code{glmfm} object.} \item{which.plots}{either \code{"ask"} (character string) or an integer vector specifying which plots to draw. In the later case, the plot numbers are given above.} \item{\dots}{other parameters to be passed through to plotting functions.} } \value{ \code{x} is invisibly returned. } \description{ Produces a set of comparison diagnostic plots. The plot options are \enumerate{ \item Deviance Residuals vs. Predicted Values, \item Response vs. Fitted Values, \item Normal QQ Plot of Pearson Residuals, \item Normal QQ Plot of Deviance Residuals, \item Pearson Residuals vs. Mahalanobis Distance, \item Sqrt Deviance Residuals vs. Predicted Values. } } \section{Side Effects}{ The selected plots are drawn on a graphics device. } \examples{ # From ?glm: # A Gamma example, from McCullagh & Nelder (1989, pp. 300-2) clotting <- data.frame( u = c(5,10,15,20,30,40,60,80,100), lot1 = c(118,58,42,35,27,25,21,19,18), lot2 = c(69,35,26,21,18,16,13,12,12)) lot1 <- glm(lot1 ~ log(u), data = clotting, family = Gamma) lot2 <- glm(lot2 ~ log(u), data = clotting, family = Gamma) fm <- fit.models(lot1, lot2) plot(fm) } \seealso{ \code{\link{sideBySideQQPlot}} for 4 and 5 and \code{\link{sideBySideScatterPlot}} for the others. } \keyword{hplot} \keyword{methods} fit.models/man/overlaidKernelDensityPlot.Rd0000644000176200001440000000112213647572427020542 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/overlaidKernelDensityPlot.R \name{overlaidKernelDensityPlot} \alias{overlaidKernelDensityPlot} \title{Overlaid Kernel Density Estimate Plot} \usage{ overlaidKernelDensityPlot(x, fun, ...) } \arguments{ \item{x}{a \code{fit.models} object.} \item{fun}{a function to extract the desired quantity from \code{x}.} \item{\dots}{additional arguments are passed to \code{densityplot}.} } \value{ the \code{trellis} object is invisibly returned. } \description{ Produces an overlaid kernel density plot. } \keyword{hplot} fit.models/man/sideBySideQQPlot.Rd0000644000176200001440000000250613647572427016531 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/sideBySideQQPlot.R \name{sideBySideQQPlot} \alias{sideBySideQQPlot} \title{Compaison QQ Plot} \usage{ sideBySideQQPlot( x, fun, envelope = TRUE, half.normal = FALSE, n.samples = 250, level = 0.95, id.n = 3, qqline = TRUE, ... ) } \arguments{ \item{x}{a \code{fit.models} object.} \item{fun}{a function to extract the desired quantity from \code{x}.} \item{envelope}{a logical value. If \code{TRUE} a \code{level} confidence envelope is simulated for each QQ plot.} \item{half.normal}{a logical value. If \code{TRUE} the plot is drawn using the absolute values.} \item{n.samples}{a positive integer value giving the number of samples to compute in the simulation of the confidence envelope.} \item{level}{a numeric value between 0 and 1 specifying the confidence level for the envelope.} \item{id.n}{a non-negative integer value specifying the number of extreme points to identify.} \item{qqline}{a logical value. If \code{TRUE}, a QQ line is included in the plot.} \item{\dots}{additional arguments are passed to \code{\link[lattice]{xyplot}}.} } \value{ the \code{trellis} object is invisibly returned. } \description{ Produces side-by-side QQ plots. An optional simulated confidence envelope can be included in each plot. } \keyword{hplot} fit.models/man/fit.models.Rd0000644000176200001440000000625113647572427015451 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/fit.models.R \name{fit.models} \alias{fit.models} \title{Fit dot Models} \usage{ fit.models(model.list, ...) } \arguments{ \item{model.list}{a list or a character vector containing names of modeling functions. Only required when \code{fit.models} is being used to fit models (rather than combine already fitted models into a \code{fit.models} object).} \item{\dots}{see details.} } \value{ The returned object is a list containing the fitted models. The class of the retuned object depends on the classes of the model objects it contains. } \description{ Fit a statistical model using different estimators (e.g., robust and least-squares) or combine fitted models into a single object. Generic methods then produce side-by-side comparisons of the parameter estimates and diagnostic plots. } \details{ There are two distinct ways the \code{fit.models} function can be used. The first is to fit the same model using different estimators. In this case, \code{model.list} should be a character vector or a list where each element is the name of a modeling function and the remaining arguments (in \dots) are the common arguments to the functions in \code{model.list}. For example, the following command fits robust and least squares linear models to Brownlee's Stack Loss Plant Data. \preformatted{ fit.models(c("rlm", "lm"), stack.loss ~ ., data = stackloss)} The resulting \code{fit.models} object is a list with the output of \preformatted{ rlm(stack.loss ~ ., data = stackloss)} in the first element and \preformatted{ lm(stack.loss ~ ., data = stackloss)} in the second. The class attribute of the returned list is set (in this case) to \code{"lmfm"} which is the \code{fit.models} class (fmclass) for comparing linear-model-like fits. The second use of fit.models is to combine fitted model objects. In this case, \code{fit.models} combines its arguments into a fit.models object (a list where element \eqn{i} is occupied by argument \eqn{i} and sets the class attribute to the appropriate \code{fit.models} class. } \examples{ # First, use fit.models to fit robust and least squares linear # regression models to Brownlee's Stack Loss Plant Data. # Step 1: rlm (robust linear model) is in the MASS package. library(MASS) # Step 2: tell fit.models rlm can be compared to lm fmclass.add.class("lmfm", "rlm") fm1 <- fit.models(c("rlm", "lm"), stack.loss ~ ., data = stackloss) summary(fm1) #rlm does not provide p-values or Multiple R-squared # Second, use fit.models to combine fitted models into a # fit.models object. lm.complete <- lm(stack.loss ~ ., data = stackloss) lm.clean <- lm(stack.loss ~ ., data = stackloss, subset = 5:20) fm2 <- fit.models(lm.clean, lm.complete) summary(fm2) plot(fm2) # Name the models in the fit.models object. fm3 <- fit.models(c(Robust = "rlm", "Least Squares" = "lm"), stack.loss ~ ., data = stackloss) fm4 <- fit.models(Clean = lm.clean, Complete = lm.complete) } \seealso{ \code{\link{fmclass.add.class}} for adding a class to an existing fit.models class and \code{\link{fmclass.register}} to create a new fit.models class. } \keyword{models} fit.models/man/screePlot.covfm.Rd0000644000176200001440000000121213647572427016446 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/screePlot.covfm.R \name{screePlot.covfm} \alias{screePlot.covfm} \title{Comparison Screeplot} \usage{ screePlot.covfm(x, npcs, strip = "", ...) } \arguments{ \item{x}{a \code{"covfm"} object.} \item{npcs}{a postive integer value specifying the number of components to be plotted.} \item{strip}{a character string printed in the \dQuote{strip} at the top of the plot.} \item{...}{additional arguments are passed to \code{xyplot}.} } \value{ the \code{trellis} object is invisibly returned. } \description{ Overlaid screeplot for the models in a \dQuote{covfm} object. } fit.models/man/plot.lmfm.Rd0000644000176200001440000000333213661230146015273 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/plot.lmfm.R \name{plot.lmfm} \alias{plot.lmfm} \title{Comparison Diagnostic Plots for Linear Regression Models} \usage{ \method{plot}{lmfm}(x, which.plots = 1:10, ...) } \arguments{ \item{x}{an \code{lmfm} object.} \item{which.plots}{either \code{"ask"} (character string) or an integer vector specifying which plots to draw. In the later case, the plot numbers are given above.} \item{\dots}{additional parameters are ignored.} } \value{ \code{x} is invisibly returned. } \description{ Produces a set of comparison diagnostic plots. The plot options are \enumerate{ \item Normal QQ Plot of Residuals, \item Kernel Density Estimate of Residuals, \item Residuals vs. Mahalanobis Distance, \item Residuals vs. Fitted Values, \item Sqrt Residuals vs. Fitted Values, \item Response vs. Fitted Values, \item Residuals vs. Index (Time), \item Overlaid Normal QQ Plot of Residuals, \item Overlaid Kernel Density Estimate of Residuals, \item Scatter Plot with Overlaid Fits (for simple linear regression models). } } \section{Side Effects}{ The selected plots are drawn on a graphics device. } \examples{ data(stackloss) stack.lm <- lm(stack.loss ~ ., data = stackloss) stack.clean <- lm(stack.loss ~ ., data = stackloss, subset = 5:20) fm <- fit.models(stack.clean, stack.lm) plot(fm) } \seealso{ See \code{\link{sideBySideQQPlot}} for 2, \code{\link{sideBySideKernelDensityPlot}} for 3, \code{\link{sideBySideIndexPlot}} for 8, \code{\link{overlaidQQPlot}} for 9, \code{\link{overlaidKernelDensityPlot}} for 10, \code{\link{overlaidSimpleRegressionPlot}} for 11, and \code{\link{sideBySideScatterPlot}} for the others. } \keyword{hplot} \keyword{methods} fit.models/man/distancePlot.covfm.Rd0000644000176200001440000000155713647572427017153 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/distancePlot.covfm.R \name{distancePlot.covfm} \alias{distancePlot.covfm} \title{Side-by-Side Mahalanobis Distance Plot} \usage{ distancePlot.covfm(x, level = 0.95, id.n = 3, ...) } \arguments{ \item{x}{a \code{"covfm"} object.} \item{level}{a single numeric value between 0 and 1 giving the chi-squared percent point used to compute the outlyingness threshold.} \item{id.n}{a single nonnegative integer specifying the number of extreme points to label in the plot.} \item{\dots}{additional arguments are passed to \code{xyplot}.} } \value{ the \code{trellis} object is invisibly returned. } \description{ Produces side-by-side plots of Mahalanobis distance computed using the location and covariance matrix estimates contained in each element of a \code{covfm} object. } fit.models/man/center.Rd0000644000176200001440000000077013701343510014641 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/covfm.R \name{center} \alias{center} \title{Calculate Location Estimate for a Fitted Model Object} \usage{ center(object, ...) } \arguments{ \item{object}{a fitted model object, typically. Sometimes also a \code{summary()} object of such a fitted model.} \item{\dots}{additional arguments for method functions.} } \description{ Returns the location estimated from a location/scatter-type fitted model object. } fit.models/DESCRIPTION0000644000176200001440000000200013711546752014027 0ustar liggesusersPackage: fit.models Version: 0.64 Date: 2020-08-02 Title: Compare Fitted Models Description: The fit.models function and its associated methods (coefficients, print, summary, plot, etc.) were originally provided in the robust package to compare robustly and classically fitted model objects. See chapters 2, 3, and 5 in Insightful (2002) 'Robust Library User's Guide' ). The aim of the fit.models package is to separate this fitted model object comparison functionality from the robust package and to extend it to support fitting methods (e.g., classical, robust, Bayesian, regularized, etc.) more generally. Authors@R: person("Kjell", "Konis", role = c("aut", "cre"), email = "kjellk@gmail.com") Author: Kjell Konis [aut, cre] Maintainer: Kjell Konis Imports: lattice, stats Suggests: MASS License: GPL RoxygenNote: 7.1.0 NeedsCompilation: no Packaged: 2020-08-02 13:59:06 UTC; kjellk Repository: CRAN Date/Publication: 2020-08-02 14:30:02 UTC fit.models/tests/0000755000176200001440000000000013711543252013463 5ustar liggesusersfit.models/tests/Examples/0000755000176200001440000000000013711543252015241 5ustar liggesusersfit.models/tests/Examples/fit.models-Ex.Rout.save0000644000176200001440000002455413647600655021512 0ustar liggesusers R Under development (unstable) (2020-04-18 r78249) -- "Unsuffered Consequences" Copyright (C) 2020 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin17.0 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > pkgname <- "fit.models" > source(file.path(R.home("share"), "R", "examples-header.R")) > options(warn = 1) > library('fit.models') > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv') > cleanEx() > nameEx("designMD") > ### * designMD > > flush(stderr()); flush(stdout()) > > ### Name: designMD > ### Title: Design Matrix Mahalanobis Distance > ### Aliases: designMD designMD.default > ### Keywords: methods regression > > ### ** Examples > > stack.lm <- lm(stack.loss ~ ., data = stackloss) > > # Mahalanobis distance (not squared) > sqrt(designMD(stack.lm)) 1 2 3 4 5 6 7 8 2.2536034 2.3247448 1.5937124 1.2718978 0.3033573 0.7728947 1.8526614 1.8526614 9 10 11 12 13 14 15 16 1.3606218 1.7459966 1.4657021 1.8415044 1.4826491 1.7787851 1.6902415 1.2919339 17 18 19 20 21 2.7000165 1.5031545 1.5932205 0.8070539 2.1767610 > > > > cleanEx() > nameEx("fit.models") > ### * fit.models > > flush(stderr()); flush(stdout()) > > ### Name: fit.models > ### Title: Fit dot Models > ### Aliases: fit.models > ### Keywords: models > > ### ** Examples > > # First, use fit.models to fit robust and least squares linear > # regression models to Brownlee's Stack Loss Plant Data. > > # Step 1: rlm (robust linear model) is in the MASS package. > library(MASS) > > # Step 2: tell fit.models rlm can be compared to lm > fmclass.add.class("lmfm", "rlm") rlm is already registered in the fit.models registry > > fm1 <- fit.models(c("rlm", "lm"), stack.loss ~ ., data = stackloss) > > summary(fm1) #rlm does not provide p-values or Multiple R-squared Calls: rlm: rlm(formula = stack.loss ~ ., data = stackloss) lm: lm(formula = stack.loss ~ ., data = stackloss) Residual Statistics: Min 1Q Median 3Q Max rlm: -8.918 -1.731 0.06187 1.543 6.502 lm: -7.238 -1.712 -0.45509 2.361 5.698 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept): rlm: -41.0265 9.8073 -4.183 lm: -39.9197 11.8960 -3.356 0.00375 ** Air.Flow: rlm: 0.8294 0.1112 7.460 lm: 0.7156 0.1349 5.307 5.8e-05 *** Water.Temp: rlm: 0.9261 0.3034 3.052 lm: 1.2953 0.3680 3.520 0.00263 ** Acid.Conc.: rlm: -0.1278 0.1289 -0.992 lm: -0.1521 0.1563 -0.973 0.34405 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual Scale Estimates: rlm: 2.441 on 17 degrees of freedom lm: 3.243 on 17 degrees of freedom Multiple R-squared: lm: 0.9136 > > > # Second, use fit.models to combine fitted models into a > # fit.models object. > > lm.complete <- lm(stack.loss ~ ., data = stackloss) > lm.clean <- lm(stack.loss ~ ., data = stackloss, subset = 5:20) > > fm2 <- fit.models(lm.clean, lm.complete) > > summary(fm2) Calls: lm.clean: lm(formula = stack.loss ~ ., data = stackloss, subset = 5:20) lm.complete: lm(formula = stack.loss ~ ., data = stackloss) Residual Statistics: Min 1Q Median 3Q Max lm.clean: -2.102 -0.5576 -0.04437 0.6418 2.135 lm.complete: -7.238 -1.7117 -0.45509 2.3614 5.698 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept): lm.clean: -35.48420 4.52650 -7.839 4.63e-06 *** lm.complete: -39.91967 11.89600 -3.356 0.00375 ** Air.Flow: lm.clean: 0.68609 0.08758 7.834 4.66e-06 *** lm.complete: 0.71564 0.13486 5.307 5.80e-05 *** Water.Temp: lm.clean: 0.56710 0.15321 3.702 0.00303 ** lm.complete: 1.29529 0.36802 3.520 0.00263 ** Acid.Conc.: lm.clean: -0.01725 0.06314 -0.273 0.78933 lm.complete: -0.15212 0.15629 -0.973 0.34405 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual Scale Estimates: lm.clean: 1.156 on 12 degrees of freedom lm.complete: 3.243 on 17 degrees of freedom Multiple R-squared: lm.clean: 0.9421 lm.complete: 0.9136 > plot(fm2) > > > # Name the models in the fit.models object. > > fm3 <- fit.models(c(Robust = "rlm", "Least Squares" = "lm"), + stack.loss ~ ., data = stackloss) > > fm4 <- fit.models(Clean = lm.clean, Complete = lm.complete) > > > > cleanEx() detaching ‘package:MASS’ > nameEx("plot.glmfm") > ### * plot.glmfm > > flush(stderr()); flush(stdout()) > > ### Name: plot.glmfm > ### Title: Comparison Diagnostic Plots for Generalized Linear Models > ### Aliases: plot.glmfm > ### Keywords: hplot methods > > ### ** Examples > > # From ?glm: > # A Gamma example, from McCullagh & Nelder (1989, pp. 300-2) > > clotting <- data.frame( + u = c(5,10,15,20,30,40,60,80,100), + lot1 = c(118,58,42,35,27,25,21,19,18), + lot2 = c(69,35,26,21,18,16,13,12,12)) > > lot1 <- glm(lot1 ~ log(u), data = clotting, family = Gamma) > lot2 <- glm(lot2 ~ log(u), data = clotting, family = Gamma) > > fm <- fit.models(lot1, lot2) > plot(fm) > > > > > cleanEx() > nameEx("plot.lmfm") > ### * plot.lmfm > > flush(stderr()); flush(stdout()) > > ### Name: plot.lmfm > ### Title: Comparison Diagnostic Plots for Linear Regression Models > ### Aliases: plot.lmfm > ### Keywords: hplot methods > > ### ** Examples > > data(stackloss) > stack.lm <- lm(stack.loss ~ ., data = stackloss) > stack.clean <- lm(stack.loss ~ ., data = stackloss, subset = 5:20) > fm <- fit.models(stack.clean, stack.lm) > plot(fm) > > > > cleanEx() > nameEx("summary.glmfm") > ### * summary.glmfm > > flush(stderr()); flush(stdout()) > > ### Name: summary.glmfm > ### Title: Comparison Summaries for Generalized Linear Models > ### Aliases: summary.glmfm > ### Keywords: methods regression > > ### ** Examples > > > # From ?glm: > # A Gamma example, from McCullagh & Nelder (1989, pp. 300-2) > > clotting <- data.frame( + u = c(5,10,15,20,30,40,60,80,100), + lot1 = c(118,58,42,35,27,25,21,19,18), + lot2 = c(69,35,26,21,18,16,13,12,12)) > > lot1 <- glm(lot1 ~ log(u), data = clotting, family = Gamma) > lot2 <- glm(lot2 ~ log(u), data = clotting, family = Gamma) > > fm <- fit.models(lot1, lot2) > summary(fm) Calls: lot1: glm(formula = lot1 ~ log(u), family = Gamma, data = clotting) lot2: glm(formula = lot2 ~ log(u), family = Gamma, data = clotting) Deviance Residuals: Min 1Q Median 3Q Max lot1: -0.04008 -0.03756 -0.02637 0.02905 0.08641 lot2: -0.05574 -0.02925 0.01030 0.01714 0.06372 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept): lot1: -0.0165544 0.0009275 -17.85 4.28e-07 *** lot2: -0.0239085 0.0013265 -18.02 4.00e-07 *** log(u): lot1: 0.0153431 0.0004150 36.98 2.75e-09 *** lot2: 0.0235992 0.0005768 40.91 1.36e-09 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Null deviance: lot1: 3.513 on 8 degrees of freedom lot2: 3.119 on 8 degrees of freedom Residual deviance: lot1: 0.01673 on 7 degrees of freedom lot2: 0.01267 on 7 degrees of freedom > > > > cleanEx() > nameEx("summary.lmfm") > ### * summary.lmfm > > flush(stderr()); flush(stdout()) > > ### Name: summary.lmfm > ### Title: Comparison Summaries for Linear Regression Models > ### Aliases: summary.lmfm > ### Keywords: methods regression > > ### ** Examples > > > data(stackloss) > m1 <- lm(stack.loss ~ ., data = stackloss) > m2 <- lm(stack.loss ~ . - Acid.Conc., data = stackloss) > > fm <- fit.models(m1, m2) > print(fm.sum <- summary(fm)) Calls: m1: lm(formula = stack.loss ~ ., data = stackloss) m2: lm(formula = stack.loss ~ . - Acid.Conc., data = stackloss) Residual Statistics: Min 1Q Median 3Q Max m1: -7.238 -1.712 -0.4551 2.361 5.698 m2: -7.529 -1.750 0.1894 2.116 5.659 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept): m1: -39.9197 11.8960 -3.356 0.00375 ** m2: -50.3588 5.1383 -9.801 1.22e-08 *** Air.Flow: m1: 0.7156 0.1349 5.307 5.80e-05 *** m2: 0.6712 0.1267 5.298 4.90e-05 *** Water.Temp: m1: 1.2953 0.3680 3.520 0.00263 ** m2: 1.2954 0.3675 3.525 0.00242 ** Acid.Conc.: m1: -0.1521 0.1563 -0.973 0.34405 m2: --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual Scale Estimates: m1: 3.243 on 17 degrees of freedom m2: 3.239 on 18 degrees of freedom Multiple R-squared: m1: 0.9136 m2: 0.9088 > > > > ### *