Learn R Programming

granova (version 1.4)

granova.contr: Graphic Display of Contrast Effect of ANOVA

Description

Provides graphic displays that shows data and effects for a priori contrasts in ANOVA contexts; also corresponding numerical results.

Usage

granova.contr(resp, con, ngrp = nrow(con), 
     npg = length(resp)/ngrp, jj = 1)

Arguments

Value

Two sets of numerical results are presented: Weighted cell means for positive and negative coefficients for each a priori contrast, and summary results from lm.summary.lmSummary results for a linear model analysis based on the R function lm (When effects are simple, as in an equal n's power of 2 design, mean differences will generally correspond to the linear regression coefficients as seen in the lm summary results.)means.pos.neg.coefftable showing the (weighted) means for positive and negative coefficients for each (row) contrast, and for each row, the difference between these means in the final columnmeans.pos.neg.coeffTable showing the (weighted) means for positive and negative coefficients for each (row) contrast, and for each row, the difference between these means, and the standardized effect size in the final column.contrastsContrast matrix used.group.means.sdsGroup means and standard deviations.dataInput data in matrix form.

Details

Function provides graphic displays of contrast effects for so-called a priori contrasts in anova. Data points are displayed as relevant for each contrast based on comparing groups according to the positive and negative contrast coefficients for each contrast on the horizontal axis, against response values on the vertical axis. Data points corresponding to groups not being compared in any contrast (coefficients of zero) are ignored. For each contrast (generally as part of a 2 x 2 panel) a line segment is given that compares the (weighted) mean of the response variable for the negative coefficients versus the positive coefficients. Standardized contrasts are used, wherein the sum of (magnitudes) of negative coefficients is unity; and the same for positive coefficients. If a line is `notably' different from horizontal (i.e. slope of zero), a `notable' effect has been identified; however, the question of statistical significance generally depends on a sound context-based estimate of standard error for the corresponding effect. This means that while summary aov numerical results and test statistics are presented (see below), the appropriateness of the default standard error generally requires the analyst's judgment. The response values are to be input in (a stacked) form, i.e. as a vector, for all cells (cf. arg. resp). The matrix of contrast vectors con should have G rows (the number of groups), and a number of columns equal to the number of a priori contrasts, at most G-1. If the number of columns of con is G-1, then the number per group, or cell size, is taken to be length(resp)/G, where G = nrow(con). If the number of columns of con is less than G-1 then the user must stipulate npg, the number in each group or cell. The function is designed for the case when all cell sizes are the same, and may be most helpful when the a priori contrasts are mutually orthogonal (e.g., in power of 2 designs, or their fractional counterparts; also when specific row or column comparisons, or their interactions (see the example below based on rat weight gain data)). It is not essential that contrasts be mutually orthogonal; but mutual linear independence is required. (When factor levels correspond to some underlying continuum a standard application might use con = contr.poly(G), for G the number of groups; consider also contr.helmert(G).) The final plot in each application shows the data for all groups or cells in the design, where groups are simply numbered from 1:G, for G the number of groups, on the horizontal axis, versus the response values on the vertical axis.

See Also

granova.1w, granova.2w, granova.ds

Examples

Run this code
data(rat)
dat6 <- matrix(c(1, 1, 1, -1, -1, -1, -1, 1, 0, -1, 1, 0, 1, 1, -2, 
    1, 1, -2, -1, 1, 0, 1, -1, 0, 1, 1, -2, -1, -1, 2), ncol = 5)
granova.contr(rat[,1], con = dat6)

#Polynomial Contrasts 
granova.contr(rat[,1],con = contr.poly(6))

#based on random data (not run)
resp <- rt(64, 5)
granova.contr(resp, con = contr.helmert(8))

Run the code above in your browser using DataLab