Package reghelper. April 8, 2017

Similar documents
Package glmnetutils. August 1, 2017

Intro to R for Epidemiologists

Package sqlscore. April 29, 2018

Package interplot. R topics documented: June 30, 2018

Package vinereg. August 10, 2018

Package colf. October 9, 2017

Package vip. June 15, 2018

Package svalues. July 15, 2018

Package gggenes. R topics documented: November 7, Title Draw Gene Arrow Maps in 'ggplot2' Version 0.3.2

Package quickreg. R topics documented:

Package citools. October 20, 2018

Package modmarg. R topics documented:

Package palmtree. January 16, 2018

Package ECctmc. May 1, 2018

Package TVsMiss. April 5, 2018

Package rfsa. R topics documented: January 10, Type Package

Package rpst. June 6, 2017

Package cattonum. R topics documented: May 2, Type Package Version Title Encode Categorical Features

Package lcc. November 16, 2018

Package gppm. July 5, 2018

Package simr. April 30, 2018

Package embed. November 19, 2018

Package PCADSC. April 19, 2017

Package fastdummies. January 8, 2018

Package MOST. November 9, 2017

Package tidylpa. March 28, 2018

Package glinternet. June 15, 2018

Package naivebayes. R topics documented: January 3, Type Package. Title High Performance Implementation of the Naive Bayes Algorithm

Package epitab. July 4, 2018

Package arulescba. April 24, 2018

Package ggmosaic. February 9, 2017

Package mason. July 5, 2018

Package BiDimRegression

Package intccr. September 12, 2017

Creating publication-ready Word tables in R

Package fitplc. March 2, 2017

Package breakdown. June 14, 2018

Package areaplot. October 18, 2017

Package optimus. March 24, 2017

Package ClusterBootstrap

Package dalmatian. January 29, 2018

Package milr. June 8, 2017

Package basictrendline

Package FWDselect. December 19, 2015

Package Cubist. December 2, 2017

Package lucid. August 24, 2018

Package psda. September 5, 2017

Package FSelectorRcpp

Package misclassglm. September 3, 2016

Package tidyimpute. March 5, 2018

Package QCAtools. January 3, 2017

Package glue. March 12, 2019

Package pwrab. R topics documented: June 6, Type Package Title Power Analysis for AB Testing Version 0.1.0

Package datasets.load

Package RLRsim. November 4, 2016

Package clipr. June 23, 2018

Package bife. May 7, 2017

Package CompGLM. April 29, 2018

Package DTRreg. August 30, 2017

Package sure. September 19, 2017

Package apastyle. March 29, 2017

Package dotwhisker. R topics documented: June 28, Type Package

Package OLScurve. August 29, 2016

Package ArCo. November 5, 2017

Package PrivateLR. March 20, 2018

Package caretensemble

Package linear.tools

Package spark. July 21, 2017

Package balance. October 12, 2018

Package RAMP. May 25, 2017

Package CuCubes. December 9, 2016

Package ggrepel. September 30, 2017

Package VWPre. March 20, 2018

Package oaxaca. January 3, Index 11

Package assertr. R topics documented: February 23, Type Package

Package sizemat. October 19, 2018

Package bayesdp. July 10, 2018

Package climber. R topics documented:

Package ecotox. June 28, 2018

Package bigreadr. R topics documented: August 13, Version Date Title Read Large Text Files

Package robets. March 6, Type Package

Package superheat. February 4, 2017

Package sparsereg. R topics documented: March 10, Type Package

Package PSTR. September 25, 2017

Package ggimage. R topics documented: December 5, Title Use Image in 'ggplot2' Version 0.1.0

Package docxtools. July 6, 2018

Package TPD. June 14, 2018

Package ggloop. October 20, 2016

Package shinyaframe. November 26, 2017

Package bisect. April 16, 2018

Package gtrendsr. August 4, 2018

Package simglm. July 25, 2018

Package ezsummary. August 29, 2016

Package catdap. R topics documented: March 20, 2018

Package bayescl. April 14, 2017

Package desplot. R topics documented: April 3, 2018

Package ggseas. June 12, 2018

Package blandr. July 29, 2017

Package TANDEM. R topics documented: June 15, Type Package

Package maxnet. R topics documented: February 11, Type Package

Transcription:

Type Package Title Helper Functions for Regression Analysis Version 0.3.3 Date 2017-04-07 Package reghelper April 8, 2017 A set of functions used to automate commonly used methods in regression analysis. This includes plotting interactions, calculating simple slopes, calculating standardized coefficients, etc. See the reghelper documentation for more information, documentation, and examples. License GPL-3 URL Depends R (>= 3.1.0) LazyData true Imports ggplot2 (>= 1.0.0), stats, nlme, lme4, utils Suggests testthat (>= 0.8.1) RoxygenNote 5.0.1 NeedsCompilation no Author Jeffrey Hughes [aut, cre] Maintainer Jeffrey Hughes <jeff.hughes@gmail.com> Repository CRAN Date/Publication 2017-04-07 22:53:04 UTC R topics documented: beta............................................. 3 beta.glm........................................... 3 beta.lm........................................... 4 beta.lme........................................... 5 beta.mermod........................................ 6 build_......................................... 7 build q....................................... 8 1

2 R topics documented: cell_means......................................... 10 cell_means.glm....................................... 10 cell_means.lm........................................ 11 cell_means_q.glm...................................... 13 cell_means_q.lm...................................... 14 coef.block_aov....................................... 15 coef.block_glm....................................... 16 coef.block_glm_summary................................. 17 coef.block_lm........................................ 18 coef.block_lm_summary.................................. 19 fitted.block_aov....................................... 19 fitted.block_glm....................................... 20 fitted.block_lm....................................... 21 graph_........................................ 22 graph_.glm...................................... 23 graph_.lm....................................... 24 graph_.lme...................................... 26 graph_.mermod................................... 27 graph q....................................... 29 graph q.glm..................................... 30 graph q.lm..................................... 31 graph q.lme..................................... 33 graph q.mermod.................................. 34 ICC............................................. 36 ICC.lme........................................... 37 ICC.merMod........................................ 38 print.block_aov_summary................................. 39 print.block_glm_summary................................. 39 print.block_lm_summary.................................. 40 print.simple_slopes..................................... 41 print.simple_slopes_lme4.................................. 42 reghelper.......................................... 42 residuals.block_aov..................................... 43 residuals.block_glm..................................... 44 residuals.block_glm_summary............................... 45 residuals.block_lm..................................... 46 residuals.block_lm_summary................................ 47 sig_regions......................................... 48 sig_regions.lm........................................ 48 simple_slopes........................................ 50 simple_slopes.glm..................................... 50 simple_slopes.lm...................................... 52 simple_slopes.lme...................................... 53 simple_slopes.mermod................................... 54 summary.block_aov..................................... 55 summary.block_glm..................................... 56 summary.block_lm..................................... 57 Index 59

beta 3 beta Standardized coeffients of a. beta is a generic function for producing standardized coefficients from regression s. beta(,...) A fitted linear of type lm, glm or aov.... Additional arguments to be passed to the particular method for the given. The form of the value returned by beta depends on the class of its argument. See the documentation of the particular methods for details of what is produced by that method. beta.lm, beta.glm, beta.aov # iris data 1 <- lm(sepal.length ~ Petal.Length + Petal.Width, iris) beta(1) # all three variables standardized 2 <- lm(sepal.width ~ Petal.Width + Species, iris) beta(2, skip='species') # all variables except Species standardized beta.glm Standardized coeffients of a. beta.glm returns the summary of a linear where all variables have been standardized. ## S3 method for class 'glm' beta(, x = TRUE, y = FALSE, skip = NULL,...)

4 beta.lm A fitted generalized linear of type glm. x Logical. Whether or not to standardize predictor variables. y Logical. Whether or not to standardize criterion variables. skip A string vector indicating any variables you do not wish to be standarized.... Not currently implemented; used to ensure consistency with S3 generic. Details This function takes a generalized linear regression and standardizes the variables, in order to produce standardized (i.e., beta) coefficients rather than unstandardized (i.e., B) coefficients. Note: Unlike beta.lm, the y parameter is set to FALSE by default, to avoid issues with some family functions (e.g., binomial). Returns the summary of a generalized linear, with the output showing the beta coefficients, standard error, t-values, and p-values for each predictor. beta.glm # mtcars data 1 <- glm(vs ~ wt + hp, data=mtcars, family='binomial') beta(1) # wt and hp standardized, vs is not by default beta.lm Standardized coeffients of a. beta.lm returns the summary of a linear where all variables have been standardized. ## S3 method for class 'lm' beta(, x = TRUE, y = TRUE, skip = NULL,...) ## S3 method for class 'aov' beta(, x = TRUE, y = TRUE, skip = NULL,...)

beta.lme 5 A fitted linear of type lm. x Logical. Whether or not to standardize predictor variables. y Logical. Whether or not to standardize criterion variables. skip A string vector indicating any variables you do not wish to be standarized.... Not currently implemented; used to ensure consistency with S3 generic. Details This function takes a linear regression and standardizes the variables, in order to produce standardized (i.e., beta) coefficients rather than unstandardized (i.e., B) coefficients. Unlike similar functions, this function properly calculates standardized estimates for interaction terms (by first standardizing each of the individual predictor variables). Returns the summary of a linear, with the output showing the beta coefficients, standard error, t-values, and p-values for each predictor. beta.glm # iris data 1 <- lm(sepal.length ~ Petal.Length + Petal.Width, iris) beta(1) # all three variables standardized 2 <- lm(sepal.width ~ Petal.Width + Species, iris) beta(2, skip='species') # all variables except Species standardized beta.lme Standardized coeffients of a. beta.lme returns the summary of a linear where all variables have been standardized. ## S3 method for class 'lme' beta(, x = TRUE, y = TRUE, skip = NULL,...)

6 beta.mermod A fitted linear of type lme. x Logical. Whether or not to standardize predictor variables. y Logical. Whether or not to standardize criterion variables. skip A string vector indicating any variables you do not wish to be standarized.... Not currently implemented; used to ensure consistency with S3 generic. Details This function takes a multi-level and standardizes the variables, in order to produce standardized (i.e., beta) coefficients rather than unstandardized (i.e., B) coefficients. Unlike similar functions, this function properly calculates standardized estimates for interaction terms (by first standardizing each of the individual predictor variables). Returns the summary of a multi-level linear, with the output showing the beta coefficients, standard error, t-values, and p-values for each predictor. beta.lm, beta.glm, beta.mermod # iris data if (require(nlme, quietly=true)) { <- lme(sepal.width ~ Sepal.Length + Petal.Length, random=~1 Species, data=iris) beta() # all three variables standardized } beta(, skip='petal.length') # all variables except Petal.Length standardized beta.mermod Standardized coeffients of a. beta.mermod returns the summary of a linear where all variables have been standardized. ## S3 method for class 'mermod' beta(, x = TRUE, y = TRUE, skip = NULL,...)

build_ 7 A fitted linear of type mermod (from the lme4 package). x Logical. Whether or not to standardize predictor variables. y Logical. Whether or not to standardize criterion variables. skip A string vector indicating any variables you do not wish to be standarized.... Not currently implemented; used to ensure consistency with S3 generic. Details This function takes a multi-level and standardizes the variables, in order to produce standardized (i.e., beta) coefficients rather than unstandardized (i.e., B) coefficients. Unlike similar functions, this function properly calculates standardized estimates for interaction terms (by first standardizing each of the individual predictor variables). Returns the summary of a multi-level linear, with the output showing the beta coefficients, standard error, t-values, and p-values for each predictor. beta.lm, beta.glm, beta.lme # iris data if (require(lme4, quietly=true)) { <- lmer(sepal.width ~ Sepal.Length + Petal.Length + (1 Species), data=iris) beta() # all variables standardized } beta(, skip='petal.length') # all variables except Petal.Length standardized build_ Incremental block ling. build_ allows you to incrementally add terms to a linear regression. build_(dv,..., data = NULL, opts = NULL, = "lm")

8 build q dv The variable name to be used as the dependent variable.... Pass through variable names (or interaction terms) to add for each block. To add one term to a block, just pass it through directly; to add multiple terms, pass it through in a vector or list. Blocks will be added in the order they are passed to the function, and variables from previous blocks will be included with each subsequent block. data opts Details An optional data frame containing the variables in the. If not found in data, the variables are taken from the environment from which the function is called. List of arguments to be passed to the function. The type of to use; only supports lm at this time. Given a list of names of variables at each step, this function will run a series of s, adding the terms for each block incrementally. Note: Cases with missing data are dropped based on the final that includes all the relevant terms. This ensures that all the s are tested on the same number of cases. A named list with the following elements: formulas s A list of the regression formulas used for each block. A list of all regression s. # 2 blocks: Petal.Length; Petal.Length + Petal.Width 1 <- build_(sepal.length, Petal.Length, Petal.Width, data=iris, ='lm') summary(1) coef(1) # 2 blocks: Species; Species + Petal.Length + Petal.Width + Petal.Length:Petal.Width 2 <- build_(sepal.length, Species, c(petal.length * Petal.Width), data=iris, ='lm') summary(2) coef(2) build q Incremental block ling. build q allows you to incrementally add terms to a linear regression.

build q 9 build q(dv, blocks = NULL, data = NULL, opts = NULL, = "lm") dv blocks data opts String of the variable name to be used as the dependent variable. List of variable names (or interaction terms) to add for each block. Each list element should be a single string with terms for that block. Variables from previous blocks will be included with each subsequent block. An optional data frame containing the variables in the. If not found in data, the variables are taken from the environment from which the function is called. List of arguments to be passed to the function. The type of to use; only supports lm at this time. Details Given a list of names of variables at each step, this function will run a series of s, adding the terms for each block incrementally. Note that in most cases it is easier to use build_ and pass variable names in directly instead of strings of variable names. build q uses standard evaluation in cases where such evaluation is easier. Note: Cases with missing data are dropped based on the final that includes all the relevant terms. This ensures that all the s are tested on the same number of cases. A named list with the following elements: formulas s A list of the regression formulas used for each block. A list of all regression s. build_ # 2 blocks: Petal.Length; Petal.Length + Petal.Width 1 <- build q('sepal.length', list('petal.length + Petal.Width'), data=iris, ='lm') summary(1) coef(1) # 2 blocks: Species; Species + Petal.Length + Petal.Width + Petal.Length:Petal.Width 2 <- build q('sepal.length', list('species', 'Species + Petal.Length * Petal.Width'), data=iris, ='lm') summary(2)

10 cell_means.glm coef(2) cell_means Estimated means. cell_means is a generic function for calculating the estimated means of a linear. cell_means(,...) A fitted linear of type lm or aov.... Additional arguments to be passed to the particular method for the given. The form of the value returned by cell_means depends on the class of its argument. See the documentation of the particular methods for details of what is produced by that method. cell_means.lm, cell_means.aov # iris data <- lm(sepal.length ~ Petal.Length + Petal.Width, iris) summary() cell_means(, Petal.Length) cell_means.glm Estimated values of a general linear. cell_means.glm calculates the predicted values at specific points, given a fitted general linear. ## S3 method for class 'glm' cell_means(,..., levels = NULL, type = c("link", "response"))

cell_means.lm 11 A fitted linear of type glm.... Pass through variable names to add them to the table. levels type A list with element names corresponding to some or all of the variables in the. Each list element should be a vector with the names of factor levels (for categorical variables) or numeric points (for continuous variables) at which to test that variable. The type of prediction required. The default link is on the scale of the linear predictors; the alternative response is on the scale of the response variable. For more information, see predict.glm. Details By default, this function will provide means at -1SD, the mean, and +1SD for continuous variables, and at each levele of categorical variables. This can be overridden with the levels parameter. If there are additional covariates in the other than what are selected in the function call, these variables will be set to their respective means. In the case of a categorical covariate, the results will be averaged across all its levels. A data frame with a row for each predicted value. The first few columns identify the level at which each variable in your was set. After columns for each variable, the data frame has columns for the predicted value, the standard error of the predicted mean, and the 95 confidence interval. cell_means.lm # iris data <- lm(sepal.length ~ Petal.Length + Petal.Width, iris) summary() cell_means(, Petal.Length) cell_means.lm Estimated values of a linear. cell_means.lm calculates the predicted values at specific points, given a fitted regression.

12 cell_means.lm ## S3 method for class 'lm' cell_means(,..., levels = NULL) ## S3 method for class 'aov' cell_means(,..., levels = NULL) A fitted linear of type lm.... Pass through variable names to add them to the table. levels A list with element names corresponding to some or all of the variables in the. Each list element should be a vector with the names of factor levels (for categorical variables) or numeric points (for continuous variables) at which to test that variable. Details By default, this function will provide means at -1SD, the mean, and +1SD for continuous variables, and at each levele of categorical variables. This can be overridden with the levels parameter. If there are additional covariates in the other than what are selected in the function call, these variables will be set to their respective means. In the case of a categorical covariate, the results will be averaged across all its levels. A data frame with a row for each predicted value. The first few columns identify the level at which each variable in your was set. After columns for each variable, the data frame has columns for the predicted value, the standard error of the predicted mean, and the 95 confidence interval. cell_means # iris data <- lm(sepal.length ~ Petal.Length + Petal.Width, iris) summary() cell_means(, Petal.Length)

cell_means_q.glm 13 cell_means_q.glm Estimated values of a general linear. cell_means_q.glm calculates the predicted values at specific points, given a fitted general linear. cell_means_q.glm(, vars = NULL, levels = NULL, type = c("link", "response")) vars levels type A fitted linear of type glm. A vector or list with variable names to be added to the table. A list with element names corresponding to some or all of the variables in the. Each list element should be a vector with the names of factor levels (for categorical variables) or numeric points (for continuous variables) at which to test that variable. The type of prediction required. The default link is on the scale of the linear predictors; the alternative response is on the scale of the response variable. For more information, see predict.glm. Details By default, this function will provide means at -1SD, the mean, and +1SD for continuous variables, and at each levele of categorical variables. This can be overridden with the levels parameter. If there are additional covariates in the other than what are selected in the function call, these variables will be set to their respective means. In the case of a categorical covariate, the results will be averaged across all its levels. Note that in most cases it is easier to use cell_means.glm and pass variable names in directly instead of strings of variable names. cell_means_q.glm uses standard evaluation in cases where such evaluation is easier. A data frame with a row for each predicted value. The first few columns identify the level at which each variable in your was set. After columns for each variable, the data frame has columns for the predicted value, the standard error of the predicted mean, and the 95 confidence interval. cell_means.glm, cell_means_q.lm

14 cell_means_q.lm # iris data <- lm(sepal.length ~ Petal.Length + Petal.Width, iris) summary() cell_means_q.lm(, 'Petal.Length') cell_means_q.lm Estimated values of a linear. cell_means_q.lm calculates the predicted values at specific points, given a fitted regression. cell_means_q.lm(, vars = NULL, levels = NULL) vars levels A fitted linear of type lm. A vector or list with variable names to be added to the table. A list with element names corresponding to some or all of the variables in the. Each list element should be a vector with the names of factor levels (for categorical variables) or numeric points (for continuous variables) at which to test that variable. Details By default, this function will provide means at -1SD, the mean, and +1SD for continuous variables, and at each levele of categorical variables. This can be overridden with the levels parameter. If there are additional covariates in the other than what are selected in the function call, these variables will be set to their respective means. In the case of a categorical covariate, the results will be averaged across all its levels. Note that in most cases it is easier to use cell_means.lm and pass variable names in directly instead of strings of variable names. cell_means_q.lm uses standard evaluation in cases where such evaluation is easier. A data frame with a row for each predicted value. The first few columns identify the level at which each variable in your was set. After columns for each variable, the data frame has columns for the predicted value, the standard error of the predicted mean, and the 95 confidence interval. cell_means.lm

coef.block_aov 15 # iris data <- lm(sepal.length ~ Petal.Length + Petal.Width, iris) summary() cell_means_q.lm(, 'Petal.Length') coef.block_aov Extract coefficients. coef method for class "block_aov". ## S3 method for class 'block_aov' coef(object, num = NULL,...) object An object of class "block_aov", usually, a result of a call to build_. num Numeric vector with the index of (s) from which to return the coefficients.... Further arguments passed to or from other methods. The coefficients of block(s) num, or if num is NULL, a list of coefficients from all blocks. build_, fitted.block_aov, residuals.block_aov # 2 blocks: Petal.Length; Petal.Length + Petal.Width 1 <- build_(sepal.length, Petal.Length, Petal.Width, data=iris, ='lm') summary(1) coef(1) # returns both blocks 1 and 2 # 2 blocks: Species; Species + Petal.Length + Petal.Width + Petal.Length:Petal.Width 2 <- build_(sepal.length, Species, c(petal.length * Petal.Width), data=iris, ='lm') summary(2) coef(2, num=2) # returns second block

16 coef.block_glm coef.block_glm Extract coefficients. coef method for class "block_glm". ## S3 method for class 'block_glm' coef(object, num = NULL,...) object num An object of class "block_glm", usually, a result of a call to build_. Numeric vector with the index of (s) from which to return the coefficients.... Further arguments passed to or from other methods. The coefficients of block(s) num, or if num is NULL, a list of coefficients from all blocks. build_, coef.block_glm_summary, fitted.block_glm, residuals.block_glm # 2 blocks: Petal.Length; Petal.Length + Petal.Width 1 <- build_(sepal.length, Petal.Length, Petal.Width, data=iris, ='lm') summary(1) coef(1) # returns both blocks 1 and 2 # 2 blocks: Species; Species + Petal.Length + Petal.Width + Petal.Length:Petal.Width 2 <- build_(sepal.length, Species, c(petal.length * Petal.Width), data=iris, ='lm') summary(2) coef(2, num=2) # returns second block

coef.block_glm_summary 17 coef.block_glm_summary Extract coefficients. coef method for class "block_glm_summary". ## S3 method for class 'block_glm_summary' coef(object, num = NULL,...) object num An object of class "block_glm_summary", usually, a result of a call to summary.block_glm. Numeric vector with the index of (s) from which to return the coefficients.... Further arguments passed to or from other methods. The coefficients of block(s) num, or if num is NULL, a list of coefficients from all blocks. summary.block_glm, coef.block_glm, residuals.block_glm_summary # 2 blocks: Petal.Length; Petal.Length + Petal.Width 1 <- build_(sepal.length, Petal.Length, Petal.Width, data=iris, ='lm') coef(summary(1)) # returns both blocks 1 and 2 # 2 blocks: Species; Species + Petal.Length + Petal.Width + Petal.Length:Petal.Width 2 <- build_(sepal.length, Species, c(petal.length * Petal.Width), data=iris, ='lm') coef(summary(2), num=2) # returns second block

18 coef.block_lm coef.block_lm Extract coefficients. coef method for class "block_lm". ## S3 method for class 'block_lm' coef(object, num = NULL,...) object num An object of class "block_lm", usually, a result of a call to build_. Numeric vector with the index of (s) from which to return the coefficients.... Further arguments passed to or from other methods. The coefficients of block(s) num, or if num is NULL, a list of coefficients from all blocks. build_, coef.block_lm_summary, fitted.block_lm, residuals.block_lm # 2 blocks: Petal.Length; Petal.Length + Petal.Width 1 <- build_(sepal.length, Petal.Length, Petal.Width, data=iris, ='lm') summary(1) coef(1) # returns both blocks 1 and 2 # 2 blocks: Species; Species + Petal.Length + Petal.Width + Petal.Length:Petal.Width 2 <- build_(sepal.length, Species, c(petal.length * Petal.Width), data=iris, ='lm') summary(2) coef(2, num=2) # returns second block

coef.block_lm_summary 19 coef.block_lm_summary Extract coefficients. coef method for class "block_lm_summary". ## S3 method for class 'block_lm_summary' coef(object, num = NULL,...) object num An object of class "block_lm_summary", usually, a result of a call to summary.block_lm. Numeric vector with the index of (s) from which to return the coefficients.... Further arguments passed to or from other methods. The coefficients of block(s) num, or if num is NULL, a list of coefficients from all blocks. summary.block_lm, coef.block_lm, residuals.block_lm_summary # 2 blocks: Petal.Length; Petal.Length + Petal.Width 1 <- build_(sepal.length, Petal.Length, Petal.Width, data=iris, ='lm') coef(summary(1)) # returns both blocks 1 and 2 # 2 blocks: Species; Species + Petal.Length + Petal.Width + Petal.Length:Petal.Width 2 <- build_(sepal.length, Species, c(petal.length * Petal.Width), data=iris, ='lm') coef(summary(2), num=2) # returns second block fitted.block_aov Extract fitted values. fitted method for class "block_aov". ## S3 method for class 'block_aov' fitted(object, num = NULL,...)

20 fitted.block_glm object num An object of class "block_aov", usually, a result of a call to build_. Numeric vector with the index of (s) from which to return the fitted values.... Further arguments passed to or from other methods. The fitted values of block(s) num, or if num is NULL, a list of fitted values from all blocks. build_, coef.block_aov, residuals.block_aov # 2 blocks: Petal.Length; Petal.Length + Petal.Width 1 <- build_(sepal.length, Petal.Length, Petal.Width, data=iris, ='lm') summary(1) fitted(1) # returns both blocks 1 and 2 # 2 blocks: Species; Species + Petal.Length + Petal.Width + Petal.Length:Petal.Width 2 <- build_(sepal.length, Species, c(petal.length * Petal.Width), data=iris, ='lm') summary(2) fitted(2, num=2) # returns second block fitted.block_glm Extract fitted values. fitted method for class "block_glm". ## S3 method for class 'block_glm' fitted(object, num = NULL,...) object num An object of class "block_glm", usually, a result of a call to build_. Numeric vector with the index of (s) from which to return the fitted values.... Further arguments passed to or from other methods. The fitted values of block(s) num, or if num is NULL, a list of fitted values from all blocks.

fitted.block_lm 21 build_, coef.block_glm, residuals.block_glm # 2 blocks: Petal.Length; Petal.Length + Petal.Width 1 <- build_(sepal.length, Petal.Length, Petal.Width, data=iris, ='lm') summary(1) fitted(1) # returns both blocks 1 and 2 # 2 blocks: Species; Species + Petal.Length + Petal.Width + Petal.Length:Petal.Width 2 <- build_(sepal.length, Species, c(petal.length * Petal.Width), data=iris, ='lm') summary(2) fitted(2, num=2) # returns second block fitted.block_lm Extract fitted values. fitted method for class "block_lm". ## S3 method for class 'block_lm' fitted(object, num = NULL,...) object An object of class "block_lm", usually, a result of a call to build_. num Numeric vector with the index of (s) from which to return the fitted values.... Further arguments passed to or from other methods. The fitted values of block(s) num, or if num is NULL, a list of fitted values from all blocks. build_, coef.block_lm, residuals.block_lm

22 graph_ # 2 blocks: Petal.Length; Petal.Length + Petal.Width 1 <- build_(sepal.length, Petal.Length, Petal.Width, data=iris, ='lm') summary(1) fitted(1) # returns both blocks 1 and 2 # 2 blocks: Species; Species + Petal.Length + Petal.Width + Petal.Length:Petal.Width 2 <- build_(sepal.length, Species, c(petal.length * Petal.Width), data=iris, ='lm') summary(2) fitted(2, num=2) # returns second block graph_ Graph fitted interactions. graph_ provides an easy way to graph interactions in fitted s. Selected variables will be graphed at +/- 1 SD (if continuous) or at each level of the factor (if categorical). graph_(,...) A fitted linear of type lm, glm, lme, or mermod.... Additional arguments to be passed to the particular method for the given. A ggplot2 graph of the plotted variables in the. graph_.lm, graph_.glm # iris data <- lm(sepal.width ~ Sepal.Length * Species, data=iris) graph_(, y=sepal.width, x=sepal.length, lines=species)

graph_.glm 23 graph_.glm Graph general linear interactions. graph_.glm provides an easy way to graph interactions in general linear s. Selected variables will be graphed at +/- 1 SD (if continuous) or at each level of the factor (if categorical). ## S3 method for class 'glm' graph_(, y, x, lines = NULL, split = NULL, type = c("link", "response"), errorbars = c("ci", "SE", "none"), ymin = NULL, ymax = NULL, labels = NULL, bargraph = FALSE, draw.legend = TRUE, dodge = 0, exp = FALSE,...) y x lines split type errorbars ymin ymax labels bargraph draw.legend dodge A fitted linear of type glm. The variable to be plotted on the y-axis. This variable is required for the graph. The variable to be plotted on the x-axis. This variable is required for the graph. The variable to be plotted using separate lines (optional). The variable to be split among separate graphs (optional). The type of prediction required. The default link is on the scale of the linear predictors; the alternative response is on the scale of the response variable. For more information, see predict.glm. A string indicating what kind of error bars to show. Acceptable values are "CI" (95 error of the predicted means), or "none". Number indicating the minimum value for the y-axis scale. Default NULL value will adjust position to the lowest y value. Number indicating the maximum value for the y-axis scale. Default NULL value will adjust position to the highest y value. A named list with strings for the various plot labels: title will set the graph title, y sets the y-axis label, x sets the x-axis label, lines sets the legend label, and split sets the label for the facet. If any label is not set, the names of the variables will be used. Setting a label explicitly to NA will set an empty label. Logical. TRUE will draw a bar graph of the results; FALSE will draw a line graph of the results. Logical. Whether or not to draw legend on the graph. A numeric value indicating the amount each point on the graph should be shifted left or right, which can help for readability when points are close together. Default value is 0, with.1 or.2 probably sufficient in most cases.

24 graph_.lm exp Details Logical. If TRUE, the exponential function exp() will be used to transform the y-axis (i.e., e to the power of y). Useful for logistic regressions or for converting log-transformed y-values to their original units.... Not currently implemented; used to ensure consistency with S3 generic. If there are additional covariates in the other than what is indicated to be graphed by the function, these variables will be plotted at their respective means. In the case of a categorical covariate, the results will be averaged across all its levels. A ggplot2 graph of the plotted variables in the. graph_.lm # iris data <- lm(sepal.width ~ Sepal.Length * Species, data=iris) graph_(, y=sepal.width, x=sepal.length, lines=species) graph_.lm Graph linear interactions. graph_.lm provides an easy way to graph interactions in linear s. Selected variables will be graphed at +/- 1 SD (if continuous) or at each level of the factor (if categorical). ## S3 method for class 'lm' graph_(, y, x, lines = NULL, split = NULL, errorbars = c("ci", "SE", "none"), ymin = NULL, ymax = NULL, labels = NULL, bargraph = FALSE, draw.legend = TRUE, dodge = 0, exp = FALSE,...) ## S3 method for class 'aov' graph_(, y, x, lines = NULL, split = NULL, errorbars = c("ci", "SE", "none"), ymin = NULL, ymax = NULL, labels = NULL, bargraph = FALSE, draw.legend = TRUE, dodge = 0, exp = FALSE,...)

graph_.lm 25 y x lines split errorbars ymin ymax labels bargraph draw.legend dodge exp Details A fitted linear of type lm. The variable to be plotted on the y-axis. This variable is required for the graph. The variable to be plotted on the x-axis. This variable is required for the graph. The variable to be plotted using separate lines (optional). The variable to be split among separate graphs (optional). A string indicating what kind of error bars to show. Acceptable values are "CI" (95 error of the predicted means), or "none". Number indicating the minimum value for the y-axis scale. Default NULL value will adjust position to the lowest y value. Number indicating the maximum value for the y-axis scale. Default NULL value will adjust position to the highest y value. A named list with strings for the various plot labels: title will set the graph title, y sets the y-axis label, x sets the x-axis label, lines sets the legend label, and split sets the label for the facet. If any label is not set, the names of the variables will be used. Setting a label explicitly to NA will set an empty label. Logical. TRUE will draw a bar graph of the results; FALSE will draw a line graph of the results. Logical. Whether or not to draw legend on the graph. A numeric value indicating the amount each point on the graph should be shifted left or right, which can help for readability when points are close together. Default value is 0, with.1 or.2 probably sufficient in most cases. Logical. If TRUE, the exponential function exp() will be used to transform the y-axis (i.e., e to the power of y). Useful for logistic regressions or for converting log-transformed y-values to their original units.... Not currently implemented; used to ensure consistency with S3 generic. If there are additional covariates in the other than what is indicated to be graphed by the function, these variables will be plotted at their respective means. In the case of a categorical covariate, the results will be averaged across all its levels. A ggplot2 graph of the plotted variables in the. # iris data <- lm(sepal.width ~ Sepal.Length * Species, data=iris) graph_(, y=sepal.width, x=sepal.length, lines=species)

26 graph_.lme graph_.lme Graph multi-level interactions. graph_.lme provides an easy way to graph interactions in multi-level s. Selected variables will be graphed at +/- 1 SD (if continuous) or at each level of the factor (if categorical). ## S3 method for class 'lme' graph_(, y, x, lines = NULL, split = NULL, errorbars = c("ci", "SE", "none"), ymin = NULL, ymax = NULL, labels = NULL, bargraph = FALSE, draw.legend = TRUE, dodge = 0, exp = FALSE,...) y x lines split errorbars ymin ymax labels bargraph draw.legend dodge exp A fitted linear of type lme. The variable to be plotted on the y-axis. This variable is required for the graph. The variable to be plotted on the x-axis. This variable is required for the graph. The variable to be plotted using separate lines (optional). The variable to be split among separate graphs (optional). A string indicating what kind of error bars to show. Acceptable values are "CI" (95 error of the predicted means), or "none". Number indicating the minimum value for the y-axis scale. Default NULL value will adjust position to the lowest y value. Number indicating the maximum value for the y-axis scale. Default NULL value will adjust position to the highest y value. A named list with strings for the various plot labels: title will set the graph title, y sets the y-axis label, x sets the x-axis label, lines sets the legend label, and split sets the label for the facet. If any label is not set, the names of the variables will be used. Setting a label explicitly to NA will set an empty label. Logical. TRUE will draw a bar graph of the results; FALSE will draw a line graph of the results. Logical. Whether or not to draw legend on the graph. A numeric value indicating the amount each point on the graph should be shifted left or right, which can help for readability when points are close together. Default value is 0, with.1 or.2 probably sufficient in most cases. Logical. If TRUE, the exponential function exp() will be used to transform the y-axis (i.e., e to the power of y). Useful for logistic regressions or for converting log-transformed y-values to their original units.... Not currently implemented; used to ensure consistency with S3 generic.

graph_.mermod 27 Details This function only deals with fixed effects of the, after the random effects have been accounted for. To look at the lower-level effects, consider using predict.lme to generate predicted values at the desired level. If there are additional covariates in the other than what is indicated to be graphed by the function, these variables will be plotted at their respective means. In the case of a categorical covariate, the results will be averaged across all its levels. A ggplot2 graph of the plotted variables in the. graph_.mermod, graph_.lm # Orthodont data if (require(nlme, quietly=true)) { <- lme(distance ~ age * Sex, data=orthodont, random=~1 Subject) graph_(, y=distance, x=age, lines=sex) } graph_.mermod Graph multi-level interactions. graph_.mermod provides an easy way to graph interactions in multi-level s. Selected variables will be graphed at +/- 1 SD (if continuous) or at each level of the factor (if categorical). ## S3 method for class 'mermod' graph_(, y, x, lines = NULL, split = NULL, errorbars = c("ci", "SE", "none"), ymin = NULL, ymax = NULL, labels = NULL, bargraph = FALSE, draw.legend = TRUE, dodge = 0, exp = FALSE,...) y x lines A fitted linear of type mermod (from the lme4 package). The variable to be plotted on the y-axis. This variable is required for the graph. The variable to be plotted on the x-axis. This variable is required for the graph. The variable to be plotted using separate lines (optional).

28 graph_.mermod split errorbars ymin ymax labels bargraph draw.legend dodge exp Details The variable to be split among separate graphs (optional). A string indicating what kind of error bars to show. Acceptable values are "CI" (95 error of the predicted means), or "none". Number indicating the minimum value for the y-axis scale. Default NULL value will adjust position to the lowest y value. Number indicating the maximum value for the y-axis scale. Default NULL value will adjust position to the highest y value. A named list with strings for the various plot labels: title will set the graph title, y sets the y-axis label, x sets the x-axis label, lines sets the legend label, and split sets the label for the facet. If any label is not set, the names of the variables will be used. Setting a label explicitly to NA will set an empty label. Logical. TRUE will draw a bar graph of the results; FALSE will draw a line graph of the results. Logical. Whether or not to draw legend on the graph. A numeric value indicating the amount each point on the graph should be shifted left or right, which can help for readability when points are close together. Default value is 0, with.1 or.2 probably sufficient in most cases. Logical. If TRUE, the exponential function exp() will be used to transform the y-axis (i.e., e to the power of y). Useful for logistic regressions or for converting log-transformed y-values to their original units.... Not currently implemented; used to ensure consistency with S3 generic. This function only deals with fixed effects of the, after the random effects have been accounted for. To look at the lower-level effects, consider using predict.mermod to generate predicted values at the desired level. If there are additional covariates in the other than what is indicated to be graphed by the function, these variables will be plotted at their respective means. In the case of a categorical covariate, the results will be averaged across all its levels. A ggplot2 graph of the plotted variables in the. graph_.lme, graph_.lm # Arabidopsis data if (require(lme4, quietly=true)) { <- lmer(total.fruits ~ nutrient * amd + rack + (1 gen), data=arabidopsis) graph_(, y=total.fruits, x=nutrient, lines=amd) }

graph q 29 graph q Graph fitted interactions. graph q provides an easy way to graph interactions in fitted s. Selected variables will be graphed at +/- 1 SD (if continuous) or at each level of the factor (if categorical). graph q(,...) A fitted linear of type lm, glm, lme, or mermod.... Additional arguments to be passed to the particular method for the given. Details Note that in most cases it is easier to use graph_ and pass variable names in directly instead of strings of variable names. graph q uses standard evaluation in cases where such evaluation is easier. A ggplot2 graph of the plotted variables in the. graph_.lm, graph_.glm # iris data <- lm(sepal.width ~ Sepal.Length * Species, data=iris) graph q(, y='sepal.width', x='sepal.length', lines='species')

30 graph q.glm graph q.glm Graph general linear interactions. graph q.glm provides an easy way to graph interactions in general linear s. Selected variables will be graphed at +/- 1 SD (if continuous) or at each level of the factor (if categorical). ## S3 method for class 'glm' graph q(, y, x, lines = NULL, split = NULL, type = c("link", "response"), errorbars = c("ci", "SE", "none"), ymin = NULL, ymax = NULL, labels = NULL, bargraph = FALSE, draw.legend = TRUE, dodge = 0, exp = FALSE,...) y x lines split type errorbars ymin ymax labels bargraph draw.legend dodge A fitted linear of type glm. The variable to be plotted on the y-axis. This variable is required for the graph. The variable to be plotted on the x-axis. This variable is required for the graph. The variable to be plotted using separate lines (optional). The variable to be split among separate graphs (optional). The type of prediction required. The default link is on the scale of the linear predictors; the alternative response is on the scale of the response variable. For more information, see predict.glm. A string indicating what kind of error bars to show. Acceptable values are "CI" (95 error of the predicted means), or "none". Number indicating the minimum value for the y-axis scale. Default NULL value will adjust position to the lowest y value. Number indicating the maximum value for the y-axis scale. Default NULL value will adjust position to the highest y value. A named list with strings for the various plot labels: title will set the graph title, y sets the y-axis label, x sets the x-axis label, lines sets the legend label, and split sets the label for the facet. If any label is not set, the names of the variables will be used. Setting a label explicitly to NA will set an empty label. Logical. TRUE will draw a bar graph of the results; FALSE will draw a line graph of the results. Logical. Whether or not to draw legend on the graph. A numeric value indicating the amount each point on the graph should be shifted left or right, which can help for readability when points are close together. Default value is 0, with.1 or.2 probably sufficient in most cases.

graph q.lm 31 exp Details Logical. If TRUE, the exponential function exp() will be used to transform the y-axis (i.e., e to the power of y). Useful for logistic regressions or for converting log-transformed y-values to their original units.... Not currently implemented; used to ensure consistency with S3 generic. If there are additional covariates in the other than what is indicated to be graphed by the function, these variables will be plotted at their respective means. In the case of a categorical covariate, the results will be averaged across all its levels. Note that in most cases it is easier to use graph_.glm and pass variable names in directly instead of strings of variable names. graph q.glm uses standard evaluation in cases where such evaluation is easier. A ggplot object of the plotted variables in the. graph_.glm, graph q.lm # iris data <- lm(sepal.width ~ Sepal.Length * Species, data=iris) graph q(, y='sepal.width', x='sepal.length', lines='species') graph q.lm Graph linear interactions. graph q.lm provides an easy way to graph interactions in linear s. Selected variables will be graphed at +/- 1 SD (if continuous) or at each level of the factor (if categorical). ## S3 method for class 'lm' graph q(, y, x, lines = NULL, split = NULL, errorbars = c("ci", "SE", "none"), ymin = NULL, ymax = NULL, labels = NULL, bargraph = FALSE, draw.legend = TRUE, dodge = 0, exp = FALSE,...) ## S3 method for class 'aov' graph q(, y, x, lines = NULL, split = NULL, errorbars = c("ci", "SE", "none"), ymin = NULL, ymax = NULL, labels = NULL, bargraph = FALSE, draw.legend = TRUE, dodge = 0, exp = FALSE,...)

32 graph q.lm y x lines split errorbars ymin ymax labels bargraph draw.legend dodge exp Details A fitted linear of type lm. The variable to be plotted on the y-axis. This variable is required for the graph. The variable to be plotted on the x-axis. This variable is required for the graph. The variable to be plotted using separate lines (optional). The variable to be split among separate graphs (optional). A string indicating what kind of error bars to show. Acceptable values are "CI" (95 error of the predicted means), or "none". Number indicating the minimum value for the y-axis scale. Default NULL value will adjust position to the lowest y value. Number indicating the maximum value for the y-axis scale. Default NULL value will adjust position to the highest y value. A named list with strings for the various plot labels: title will set the graph title, y sets the y-axis label, x sets the x-axis label, lines sets the legend label, and split sets the label for the facet. If any label is not set, the names of the variables will be used. Setting a label explicitly to NA will set an empty label. Logical. TRUE will draw a bar graph of the results; FALSE will draw a line graph of the results. Logical. Whether or not to draw legend on the graph. A numeric value indicating the amount each point on the graph should be shifted left or right, which can help for readability when points are close together. Default value is 0, with.1 or.2 probably sufficient in most cases. Logical. If TRUE, the exponential function exp() will be used to transform the y-axis (i.e., e to the power of y). Useful for logistic regressions or for converting log-transformed y-values to their original units.... Not currently implemented; used to ensure consistency with S3 generic. If there are additional covariates in the other than what is indicated to be graphed by the function, these variables will be plotted at their respective means. In the case of a categorical covariate, the results will be averaged across all its levels. Note that in most cases it is easier to use graph_.lm and pass variable names in directly instead of strings of variable names. graph q.lm uses standard evaluation in cases where such evaluation is easier. A ggplot object of the plotted variables in the. graph_.lm

graph q.lme 33 # iris data <- lm(sepal.width ~ Sepal.Length * Species, data=iris) graph q(, y='sepal.width', x='sepal.length', lines='species') graph q.lme Graph multi-level interactions. graph q.lme provides an easy way to graph interactions in multi-level s. Selected variables will be graphed at +/- 1 SD (if continuous) or at each level of the factor (if categorical). ## S3 method for class 'lme' graph q(, y, x, lines = NULL, split = NULL, errorbars = c("ci", "SE", "none"), ymin = NULL, ymax = NULL, labels = NULL, bargraph = FALSE, draw.legend = TRUE, dodge = 0, exp = FALSE,...) y x lines split errorbars ymin ymax labels bargraph draw.legend A fitted linear of type lme. The variable to be plotted on the y-axis. This variable is required for the graph. The variable to be plotted on the x-axis. This variable is required for the graph. The variable to be plotted using separate lines (optional). The variable to be split among separate graphs (optional). A string indicating what kind of error bars to show. Acceptable values are "CI" (95 error of the predicted means), or "none". Number indicating the minimum value for the y-axis scale. Default NULL value will adjust position to the lowest y value. Number indicating the maximum value for the y-axis scale. Default NULL value will adjust position to the highest y value. A named list with strings for the various plot labels: title will set the graph title, y sets the y-axis label, x sets the x-axis label, lines sets the legend label, and split sets the label for the facet. If any label is not set, the names of the variables will be used. Setting a label explicitly to NA will set an empty label. Logical. TRUE will draw a bar graph of the results; FALSE will draw a line graph of the results. Logical. Whether or not to draw legend on the graph.

34 graph q.mermod dodge exp A numeric value indicating the amount each point on the graph should be shifted left or right, which can help for readability when points are close together. Default value is 0, with.1 or.2 probably sufficient in most cases. Logical. If TRUE, the exponential function exp() will be used to transform the y-axis (i.e., e to the power of y). Useful for logistic regressions or for converting log-transformed y-values to their original units.... Not currently implemented; used to ensure consistency with S3 generic. Details This function only deals with fixed effects of the, after the random effects have been accounted for. To look at the lower-level effects, consider using predict.lme to generate predicted values at the desired level. If there are additional covariates in the other than what is indicated to be graphed by the function, these variables will be plotted at their respective means. In the case of a categorical covariate, the results will be averaged across all its levels. Note that in most cases it is easier to use graph_.lme and pass variable names in directly instead of strings of variable names. graph q.lme uses standard evaluation in cases where such evaluation is easier. A ggplot2 graph of the plotted variables in the. graph_.lme, graph q.mermod, graph q.lm # Orthodont data if (require(nlme, quietly=true)) { <- lme(distance ~ age * Sex, data=orthodont, random=~1 Subject) graph q(, y='distance', x='age', lines='sex') } graph q.mermod Graph multi-level interactions. graph q.mermod provides an easy way to graph interactions in multi-level s. Selected variables will be graphed at +/- 1 SD (if continuous) or at each level of the factor (if categorical).