Table of Contents
Contents of Library    pda

all.covars	determine names of all factors, covariates, predictors (factors & covariates)

all.factors	determine names of all factors, covariates, predictors (factors & covariates)

all.predictors	determine names of all factors, covariates, predictors (factors & covariates)

box.fig	draw boxplot figure at specified position

branch

burst

char	Multiple Plots (Points, Lines) by Group

ci.plot	Interaction Plots of Response with Interval Bars

ci.width	utility functions for ci.plot

circle	draw circles and ellipses

cor.coef	correlation, covariance, or standard errors of model coefficients

cov.coef	correlation, covariance, or standard errors of model coefficients

df.resid	residual degrees of freedom

dotna	reinterpret "." as NA in dataframe

effect.fit	Get fit effects and plot beside residuals.

effect.plot	Get fit effects and plot beside residuals.

ellipse	draw circles and ellipses

enscript	UNIX interfaces to printers

factor.labels	determine labels for all factors used in model fit

get.levels	get elements of data with names in factors

get.list	get elements of data with names in factors

ghostview	UNIX interfaces to printers

harmonic.mean	harmonic mean of numeric vector

int.plot	Interaction Plots of Response with Interval Bars

lpq	UNIX interfaces to printers

lpr	UNIX interfaces to printers

lsd.bar	Standard Error and Fisher's LSD Bars for Interaction Plots

lsd.plot	Interaction Plots of Response with Interval Bars

lsmean	Least Squares Means

mandel.plot	Tukey/Mandel Interaction Plots of Response for Pairs of Factors

margin.plot	Margin Plots of Response for Pairs of Factors

margin.plot.lm	Margin Plots of Response for Pairs of Factors in Linear Model

mlines	Multiple Plots (Points, Lines) by Group

model.response	determine names of all factors, covariates, predictors (factors & covariates)

mplot	Multiple Plots (Points, Lines) by Group

mpoints	Multiple Plots (Points, Lines) by Group

mqqnorm	Multiple Q-Q Normal and Half-Normal Plots by Group

nested	nested weighted means for experimental units

nested.tree	draw nested tree

norm.ellipse	draw circles and ellipses

plotter	graphics device selection based on environment variables

precision	round value to precision

ps	UNIX interfaces to printers

sample.size	compute sample size by group

se.bar	Standard Error and Fisher's LSD Bars for Interaction Plots

se.coef	correlation, covariance, or standard errors of model coefficients

split.plot	~function to do ???

std.dev	standard deviation of object

trans.plot	Diagnostic plot to find power transform to remove interaction.

tukey.plot	Tukey/Mandel Interaction Plots of Response for Pairs of Factors

uncollide	spread out values to avoid collision in plotting

unfactor	unclass factor (but keep numeric level)


determine names of all factors, covariates, predictors (factors & covariates)
all.factors    determine names of all factors, covariates, predictors (factors & covariates)

or response used in model fit

USAGE

all.factors(object, data)

all.covars(object, data)

all.predictors(object, data)

model.response(object, data)

object	object from linear model fit

data	data frame in which to interpret the variables named in the full and reduced objects (determined from reduced fit if omitted)

VALUE

list of names of factors, covariates or predictors (factors & covariates) or response used in model fit

SEE ALSO

all.names.

EXAMPLES

fit <- lm(y~x+a*b,data)

# return c("a","b")

all.factors(fit)

# return "x"

all.covars(fit)

# return c("x","a","b")

all.predictors(fit)

# return "y"

model.response(fit)


draw boxplot figure at specified position
box.fig    draw boxplot figure at specified position

USAGE

box.fig(fit, xpos=1, width=0.2, jitter=width)

fit	linear model (lm) fit

xpos	horizontal (x) position of boxplot

width	width of boxplot

jitter	uniform jitter of outliers, if any

VALUE

list as returned from boxplot(fit,plot=F)

SEE ALSO

boxplot, effect.plot.

EXAMPLES

pred <- fitted(fit)

plot(pred,resid(fit),xlim=range(pred)*c(1,1.1))

box.fig(fit,max(pred)*1.1)


branch

USAGE

branch(root, limb, pos=1:2, flip=F)

root	~Describe root here

limb	~Describe limb here

pos	~Describe pos here

flip	~Describe flip here

VALUE

~Describe the value returned

EXAMPLES

# The function is currently defined as

function(root, limb, pos = 1:2, flip = F)

{

if(flip)

for(i in limb)

lines(pos, c(root, i))

else for(i in limb)

lines(c(root, i), pos)

}


utility functions for ci.plot
ci.width    utility functions for ci.plot

USAGE

ci.width(fit, data, factors, size=sample.size(fit, data, factors),

  rdf=df.resid(fit), sd=std.dev(fit), level=0.05,

  crit=qt(1 - level/2, rdf), ...)

fit	fitted model object (optional unless response is omitted).

data	data frame in which to interpret the variables named in the fit object (taken from fit if omitted).

factors	Character string of length 2 with names of x.factor and trace.factor as found in fit and data (default is first 2 factors in fit).

size	sample size per 2 factor combination (single value OK for balanced data)

rdf	residual degrees of freedom

sd	standard deviation

level	significance level for confidence interval

crit	value from t distribution at level with rdf degrees of freedom by default

...	ignored

VALUE

Width of confidence interval at all levels of factor combinations, computed as (critical.value*sd/size).

SEE ALSO

ci.plot.


correlation, covariance, or standard errors of model coefficients
cor.coef    correlation, covariance, or standard errors of model coefficients

USAGE

cor.coef(object)

cov.coef(object)

se.coef(object)

object	object from linear model fit

VALUE

correlation, covariance, or standard errors of model coefficients

EXAMPLES

cor.coef(lm(y~a+b,data))

cov.coef(lm(y~a+b,data))

se.coef(lm(y~a+b,data))


residual degrees of freedom
df.resid    residual degrees of freedom

USAGE

df.resid(object, ...)

object	vector, list of vectors, or object from linear model fit

...	more vectors

VALUE

If a single vector is given, return its degrees of freedom corrected for the mean, length(object)-1. If a list of vectors is given (explicitly or implicitly), sum up df for each. If object is a linear model fit, extract its df.resid element or make appropriate guess based on model degrees of freedom if df.resid is missing.

EXAMPLES

df.resid(x)

df.resid(lm(y~a+b,data))


reinterpret "." as NA in dataframe
dotna    reinterpret "." as NA in dataframe

USAGE

dotna(data)

data	dataframe in matrix form, perhaps created by read.table

VALUE

dataframe reinterpreted by column.  This is useful for postprocessing datafiles which use "." for missing data (e.g. for SAS input) rather than NA. Columns with any "."s are interpreted by read.table as factors; replacing these by NA allows as.data.frame to perform properly.

SEE ALSO

unfactor, read.table, as.data.frame.

EXAMPLES

# read table

tomato <- read.table(tomato, header=T)

# reinterpret missing values

tomato <- dotna(tomato)

tomato$entry <- factor(tomato$entry)


Get fit effects and plot beside residuals.
effect.fit    Get fit effects and plot beside residuals.

See Emerson chapter in Hoaglin, Mosteller and Tukey (1991, ch. 8C) Fundamentals of Exploratory Analysis of Variance (Wiley).

USAGE

effect.fit(fit, adjust=T, influence=F)

effect.plot(fit, adjust=T, boxplot=10, jitter=0.2, width=jitter, ...)

fit	linear model (lm) fit

adjust	adjust effects so that the average of squared effects is the mean square for that term

influence	standardize residuals by sqrt(1-influence)

boxplot	use boxplot instead if more than this many values

jitter	uniform sideways jitter of plotted points (default=.1)

width	width of boxplot (default=jitter)

...	Plot parameters

VALUE

list of effects

SEE ALSO

effect.plot.

EXAMPLES

effect.plot(lm(Yield~Conc+Temp*Cat,catalyst)


draw circles and ellipses
circle    draw circles and ellipses

USAGE

circle(x=0, y=0, radius=1, ...)

ellipse(x=0, y=0, sx=1, sy=1, rho=0, fine=0.01, center=0.1, add=T, show=T, ...)

norm.ellipse(x, y, group, homosked=T, level=0.05,

   radius=sqrt(qchisq(1-level,2)), ...)

x,y	center of circle or ellipse

radius	length of radius (positive)

sx,sy,rho	standardizing units for x,y (positive) and correlation between x and y (between -1 and 1)

fine	fineness of arcs for drawing (between 0 and 1)

center	if positive, fraction of radius for main axes

show	plot ellipse or circle if TRUE

add	add to existing plot if TRUE

...	plot parameters (many are set if add=F)

VALUE

list of dataframes containing ellipse or circle arc(s)

EXAMPLES

# circle with unit radius

circle()

# return coordinates of arc for ellipse

ellipse(sx=2,sy=3,rho=.5,show=F)

# 95% contour for bivariate normal from data (x,y)

norm.ellipse(x,y)


determine labels for all factors used in model fit
factor.labels    determine labels for all factors used in model fit

USAGE

factor.labels(object, data)

object	object from linear model fit

data	data frame in which to interpret the variables named in the full and reduced objects (determined from reduced fit if omitted)

VALUE

list containing labels of factors used in model fit

SEE ALSO

lsd.plot, margin.plot.lm.

EXAMPLES

# return list of length 2 with labels for a and b

factor.labels(lm(y~a+b,data))


get elements of data with names in factors
get.list    get elements of data with names in factors

USAGE

get.list(data, factors)

get.levels(x, levels=get.list(data,factors), data, factors)

data	list or data frame

factors	vector of list identifiers (integers or characters)

x	vector of same length as nrow(data)

levels	data frame of factors from data

VALUE

get.list returns data frame with length(factors) elements; get.levels returns a vector of levels(x) if x is a factor or mean(x) if x is numeric for all unique combinations of levels of factors

EXAMPLES

> get.levels(forage$hc,get.list(forage,c("trt","hc")))


UNIX interfaces to printers
ps    UNIX interfaces to printers

USAGE

ghostview(file, background=T)

ps(file, width=4, height=2.5, pointsize=10, ...)

file	name of postscript file

background	run ghostview in background and return to S

width,height,pointsize	convenient postscript command option settings

EXAMPLES

> # convenient postscript() command settings

> postscript("myfile.ps")

FIX: ...

> graphics.off()

> # spawn ghostview to examine postscript plot

> ghostview("myfile.ps")

> # can use ghostview buttons to send plots to printer


harmonic mean of numeric vector
harmonic.mean    harmonic mean of numeric vector

USAGE

harmonic.mean(x)

x	numeric vector

VALUE

harmonic mean

EXAMPLES

# The function is currently defined as

function(x)

{

length(x)/sum(1/x)

}


Interaction Plots of Response with Interval Bars
lsd.plot    Interaction Plots of Response with Interval Bars

USAGE

lsd.plot(x.factor, response, group, ...)

ci.plot(x.factor, response, group, ...)

int.plot(x.factor, response, group, ..., bar.plot="lsd")

lsd.plot(fit, data, factors, ...)

ci.plot(fit, data, factors, ...)

int.plot(fit, data, factors, lsm=lsmean(fit,data,factors),

   sort.mean=F, ..., bar.plot=c("lsd","ci","test","none"))

x.factor	factor to be plotted on the x-axis.

response	numeric vector.

sort.mean	should x factor levels be sorted by mean value (default=F).

group	factor whose levels will be separate traces.

fit	fitted model object (optional unless response is omitted).

data	data frame in which to interpret the variables named in the fit object (taken from fit if omitted).

factors	Character string of length 2 with names of x.factor and trace.factor as found in fit and data (default is first 2 factors in fit).

lsm	Least squares means for plotting (default is fit from model).

...	optional specification of other parameters to be passed to plotting routines and/or to the bar-drawing routines lsd.bar and se.bar. There are some parameters, such as width and edge which can change to plotting area.

bar.plot	"lsd" (=default), "ci", "test" or "none". The "test" is a sqrt(2) contraction of confidence interval for approximate graphical comparisons of means.

NOTE: The arguments for the default calls agree in order with mplot but not interaction.plot. The routines lsd.plot and ci.plot simply call int.plot.

A plot will be created showing the requested function of responses for each level of the x.factor at each level of the group. By default, lines for each value of the group are drawn in different line styles ('lsd.plot' and 'int.plot') and with plot symbols as the first character of group so that they may be more easily distinguished.  This corresponds to plot option type="b", which can be overridden. A Fisher's LSD bar (lsd.plot) or confidence intervals (ci.plot) are added.

VALUE

list containing sd, rdf, level and sample size, and either lsd (lsd.plot) or width (ci.plot).

SEE ALSO

interaction.plot, margin.plot.lm, lsd.bar, ci.width, mplot.

EXAMPLES

> # the first use mimics interaction.plot

> attach(catalyst)

> lsd.plot(Conc, Yield, Cat)

> detach()

> # or you could get more fancy by using a model fit

> # here is an interaction plot averaged over Conc levels

> cat.fit <- aov(Yield~Conc+Cat*Temp,catalyst)

> lsd.plot(cat.fit,catalyst,factors=c("Temp","Cat"))

> # the following gives a plot only for one level of Conc

> cat.lsm <- lsmean(cat.fit)

> lsd.plot(cat.fit,catalyst,factors=c("Temp","Cat"),

     lsm=cat.lsm[cat.lsm$Conc==20,])

> # try these using ci.plot instead of lsd.plot


UNIX interfaces to printers
lpq    UNIX interfaces to printers

USAGE

lpq(printer=unix("printenv PRINTER"))

lpr(file, printer=unix("printenv PRINTER"))

enscript(file, options="-2r")

file	name of file to be examined or printed

printer	name of printer (usually PostScript compatible)

options	options for enscript command

EXAMPLES

# check printer queue

lpq()

# send file "xyz" to printer

lpr("xyz")

# use enscript instead to save paper!

enscript("xyz")


Least Squares Means
lsmean    Least Squares Means

USAGE

lsmean(y, ..., factors = , effects = F, se.fit = T, adjust.cov = T)

lsmean(fit, data, factors = , effects = F, se.fit = T, adjust.cov = T)

y	response vector.

...	factors and covariates (must be same length as y).

fit	model object (optional in first form of call).

data	data.frame in which to interpret variables (found from fit if missing).

factors	character vector containing names of x.factor and trace.factor as first two entries.  Must be in names(data) and labels(fit). Default is all factor names.

effects	drop intercept if T (only works properly with sum-to-zero contrasts).

se.fit	compute pointwise standard errors if T.

adjust.covar	adjust means to average covariate values if T; otherwise use covariate mean for each combination of factors.

VALUE

data frame containing unique factor levels of factors,  predicted response (pred) and standard errors (se). WARNING: lsmean may not function properly if there are empty cells.

SEE ALSO

predict.

EXAMPLES

> lsmean(y,x1,x2)

> # the following does the same thing

> fit <- lm(y~x1+x2)

> data <- data.frame(y,x1,x2)

> lsmean(fit,data,factors=c("x1","x2")


Margin Plots of Response for Pairs of Factors
margin.plot    Margin Plots of Response for Pairs of Factors

USAGE

margin.plot(x.factor, response, group, ...,

orient = "default", average = "full")

x.factor	factor whose margins are to be plotted on the x-axis. Factor levels are plotted below the marginal means or effects.

response	numeric vector.

group	factor whose levels will be separate traces.

...	optional specification of other parameters to be passed to plotting routines.

orient	"default" = default (as in interaction.plot), "switch" = switch plot orientation of x.factor and group, "both" = plot both ways.

average	"full" = use response, "reduced" = use predicted values from reduced (additive) model.

VALUE

a plot will be created showing the requested function of responses for each level of the x.factor at each level of the group. By default, lines for each value of the group are drawn in different styles so that they may be more easily distinguished.

SEE ALSO

tukey.plot, margin.plot.lm.

EXAMPLES

> attach(catalyst)

> margin.plot(Conc, Yield, Cat)

> detach()


Margin Plots of Response for Pairs of Factors in Linear Model
margin.plot.lm    Margin Plots of Response for Pairs of Factors in Linear Model

USAGE

margin.plot.lm(full, reduced, data, factors, lsm,

        margin, error = "full", bar = "lsd",...)

full	full model object from linear model fit

reduced	reduced model object, for computation of marginal means or effects (default=full)

data	data frame in which to interpret the variables named in the full and reduced objects (determined from reduced fit if omitted)

factors	Character string of length 2 with names of x.factor and trace.factor as found in fit and data (default is first 2 factors in fit).

lsm	Least squares means for plotting (default is fit from full model).

margin	Least squares marginal means for horizontal axis (default is fit from reduced model rounded to proper precision).

error	model to use for error calculation ("full" or "reduced").

bar	error bars: Fisher's LSD ("lsd"=default) or confidence intervals ("ci") or none ("none").

...	optional specification of other parameters to be passed to plotting routines.

VALUE

a plot will be created showing the requested function of responses for each level of the x.factor at each level of the trace.factor. By default, lines for each value of the trace.factor are drawn in different styles so that they may be more easily distinguished.

SEE ALSO

lsd.plot, margin.plot, tukey.plot.

EXAMPLES

> reduced <- lm(Yield ~ Conc + Cat,catalyst)

> full <- update(reduced,~.^2)

> margin.plot.lm(full,reduced,catalyst)


Multiple Plots (Points, Lines) by Group
mplot    Multiple Plots (Points, Lines) by Group

USAGE

mplot(x, y, group, type="p", ...)

mpoints(x, y, group, type="p", ...)

mlines(x, y, group, type="l", lty=1:length(unique(group)), fulltext=F, ...)

char(group)

x,y	Coordinates of points.

group	Group identifier (first digit or letter is used). Must be same length as x and y.

type	values of "p", "l", "b" produce points, lines or both.

lty	line type (see par()).

fulltext	if true, use full text of group for plotting; if false use first character of group for plot symbol.  mlines(x,y,group,fulltext=T) is equivalent to text(x,y,group).

...	Plot paramaters to be passed along, from mplot() to plot() and mlines(), and from mlines() to lines().

VALUE

char() returns a string consisting of the first character of each element in group.

SEE ALSO

lines, points, plot.

EXAMPLES

#

attach(iron)

mplot(Cactual,Resp,group=Clevel)

mlines(Cactual,predict(lm(Resp~Cactual,hwk3)),group=Clevel,lty=1)

detach(hwk3)


Multiple Q-Q Normal and Half-Normal Plots by Group
mqqnorm    Multiple Q-Q Normal and Half-Normal Plots by Group

USAGE

mqqnorm(x, group, ...)

x	Sample vector or aov object.  Passed directly to qqnorm()

group	Group identifier (first digit or letter is used). Must be same length as number of characters to be plotted. Default are labels returned by qqnorm().

...	Plot and/or qqnorm paramaters to be passed along to qqnorm() and mpoints().

VALUE

returns object from qqnorm.  If x is a vector, produces normal plot. If x is of class aov, produces a half-normal plot of effects.

SEE ALSO

mpoints, qqnorm, qqnorm.aov.

EXAMPLES

#

library(data)

mqqnorm(1:10,letters[1:10]

mqqnorm(lsfit(y~a*b,data))


nested weighted means for experimental units
nested    nested weighted means for experimental units

DESCRIPTION

This is under development.  It is a simple approximation to reduce measurements to a single value for each sized experimental unit.

USAGE

nested( fit, data, project = proj( fit ), ... )

nested( project, data, factors, response="y", nesting=c(1,ncol(ref)),

   ref = projref( project ), ... )

REQUIRED ARGUMENTS

fit	linear model fit object with Error() nesting

OPTIONAL ARGUMENTS

data	data frame used in fit

project	projection of data using fit

factors	vector of names of factors in fit

response	name of response

nesting	levels of nesting to be averaged (1=intercept, 2=whole plot, 3=sub-plot, etc.)

ref	data frame of reference values from projection

...	additional arguments for projwt

VALUE

Data frame with average response for unique factor combinations and additional column weight with counts of cases used in averages.

DETAILS

See nested.default and nested.aovprojlist for code details.

REFERENCES

~put references here, make other sections like NOTE and WARNING with .SH

SEE ALSO

projwt, projref.

EXAMPLES

nest.data <- nested( proj(fit), data, c("A","b"), "y", c(1,2))

aov(y~A*B, nest.data)


draw nested tree
nested.tree    draw nested tree

DESCRIPTION

draw nested tree based on model estimates/predictors

USAGE

nested.tree(data, nesting=names(means),

   means=nested.means(data, nesting[-1]), offset=0.05, small=0.02,

   estimate="estimate", bar="stderr", jitter=offset/2, ...)

REQUIRED ARGUMENTS

data	data frame

nesting	character vector of nesting names for means

means	list of means with names given by nesting

OPTIONAL ARGUMENTS

offset	offset for accuracy bar

small	smallest relative separation of names allowable (scalar, or vector with same length as nesting)

estimate	name of estimate or prediction column

bar	name of column for accuracy

jitter	jitter of names

...	plotting parameters

VALUE

DETAILS

Either (nesting and data) or means must be specified.

REFERENCES

SEE ALSO

nested.means.

EXAMPLES

nested.tree(means=wheatfix.means,bar="ci",small=c(0,0,.05))


graphics device selection based on environment variables
plotter    graphics device selection based on environment variables

USAGE

plotter(..., term=unix("echo $TERM"), host=unix("echo $SHOME"),

   height=24, las=1)

...	arguments to pass to graphics device

term	UNIX terminal type

host	UNIX hostname of S or Splus

height	height of printer graphics device (if not xterm)

las	rotate y axis labels

VALUE

graphics device as character string

EXAMPLES

plotter()


round value to precision
precision    round value to precision

USAGE

precision(value,se)

value	numeric vector

se	standard error(s) of value(s).

VALUE

value(s) rounded off to precision of 2 standard errors plus one extra digit.

EXAMPLES

precision(75.111,.12)


compute sample size by group
sample.size    compute sample size by group

USAGE

sample.size(x, ...)

sample.size(fit, data, factors)

x	vector or list of vectors

...	additional vectors in implicit list

fit	object from linear model fit

data	data frame in which to interpret the variables named in the full and reduced objects (determined from reduced fit if omitted)

factors	Character string of length 2 with names of x.factor and trace.factor as found in fit and data (default is first 2 factors in fit).

VALUE

In the case of a list of vectors, a vector of their lengths. For a linear model object, the sample size by factors.

EXAMPLES

sample.size(list(x1,x2,x3))

sample.size(x1,x2,x3)

sample.size(lm(y~a+b,data))


Standard Error and Fisher's LSD Bars for Interaction Plots
se.bar    Standard Error and Fisher's LSD Bars for Interaction Plots

USAGE

se.bar(xpos, ypos, bar, mod = "", cap = "SE", adj = 0, width = .01)

lsd.bar(x.factor, response, group, ...)

lsd.bar(fit, data, factors, xpos, ypos, ...,

size = sample.size(fit,data,factors), rdf = df.resid(fit),

sd = std.dev(fit), level = .05,

critical.value = sqrt(2) * qt(1-level/2,rdf),

cap = paste(100*level,"%\nLSD",sep=""))

xpos	x position(s) of bar(s).

ypos	y position(s) of bar(s).

bar	height(s) of bar(s).

mod	modifier to bar caption ("*" used in lsd.bar for unequal sample sizes)

cap	caption for each bar (omitted if "")

adj	0 = left adjust caption to right of bar, 1 = right adjust caption to left of bar.

width	relative width of bar ends (can be 0).

x.factor	factor to be plotted on the x-axis.

group	factor whose levels will be separate traces.

response	numeric vector.

fit	fitted model object (optional unless response is omitted).

data	data.frame in which to interpret the variables named in the fit object (taken from fit if omitted).

factors	Character string of length 2 with names of x.factor and trace.factor as found in fit and data (default is first 2 factors in fit).

size	sample size(s) at each bar position.

rdf	residual degrees of freedom.

sd	standard deviation.

level	significance level.

critical.value	2-sided tail value of t-distribution.

...	optional specification of other parameters to be passed to se.bar.

Standard error bars (se.bar) or an LSD bar (lsd.bar) are plotted at position(s) cbind(xpos,ypos).  Lsd.bar uses the S method, with the lsd.bar.default calling lsd.bar.lm after setting up the fit, data and factor.  Lsd.bar.lm in turn calls se.bar after determining the bar height using size, rdf, sd and level.  Confidence intervals or other multiple bars can be constructed ci.bar (see ci.plot).

VALUE

a list containg xpos, ypos, bar, mod, cap, adj, width.

SEE ALSO

lsd.plot, ci.plot.

EXAMPLES

> attach(catalyst)

> lsd.bar(Conc, Cat, Yield)

> detach()


~function to do ???
split.plot    ~function to do ???

USAGE

split.plot(response, nest.factors, covars, weights, data)

response	~Describe response here

nest.factors	~Describe nest.factors here

covars	~Describe covars here

weights	~Describe weights here

data	~Describe data here

VALUE

~Describe the value returned

EXAMPLES

# The function is currently defined as

function(response, nest.factors, covars, weights, data)

{

nest.int <- interaction(get.list(data, nest.factors), drop = T)

# need to check that nest.factors are factors

# how to add weighting to fit?

nest.fit <- lm(paste(response, "~", paste(nest.factors, sep = "*")),

data)	# whole plot

Within <- data

if(missing(weights))

weights <- "weights"

if(is.na(pmatch(weights, names(data))))

Within[[weights]] <- rep(1, nrow(data))

Within[[response]] <- resid(nest.fit)	# split plot

Between <- data.frame(data[!duplicated(nest.int),  ], row.names =

unique(nest.int))

Between[[response]] <- predict(nest.fit)[!duplicated(nest.int)]

Between[[weights]] <- tapply(Within[[weights]], nest.int, sum)

browser()	# covariates

if(!missing(covars)) {

covar.data <- data

for(i in covars) {

covar.data[[response]] <- data[[i]]

Within[[i]] <- resid(nest.fit, covar.data)

Between[[i]] <- predict(nest.fit, covar.data)

}

}

list(Between = Between, Within = Within)

}


standard deviation of object
std.dev    standard deviation of object

USAGE

std.dev(object)

object	vector or object from linear model fit

VALUE

standard deviation

EXAMPLES

std.dev(x)

std.dev(lm(y~a+b,data))


Diagnostic plot to find power transform to remove interaction.
trans.plot    Diagnostic plot to find power transform to remove interaction.

See Emerson chapter in Hoaglin, Mosteller and Tukey (1991, ch. 13E) Fundamentals of Exploratory Analysis of Variance (Wiley); or see Mosteller and Tukey (1977, ch. 9E,F) Exploratory Data Analysis (Addison-Wesley).

USAGE

trans.plot(fit, predictors=all.predictors(fit)[1:2],

   terms=predict(fit, type = "terms"), ...)

fit	linear model (lm) fit

factors	predictors to compare.  They must be in the model, as well as their interaction in the specified order.

terms	estimates of model terms

...	Plot parameters

VALUE

Power = 1 - slope estimate.  SE comes from simple linear regression and is at best advisory.  Consider tranformation y^p = exp(p*log(y)), or transform log(y) if p=0.  In practice, examine nearest half integer.

SEE ALSO

effect.plot.

EXAMPLES

# Bekk data from Hoaglin, Mosteller and Tukey (1991)

bekk.fit <- lm(smooth~lab*mat, bekk)

effect.plot(bekk.fit)

trans.plot(bekk.fit)

bekk.lfit <- lm(log(smooth)~lab*mat, bekk)

effect.plot(bekk.lfit)

trans.plot(bekk.lfit)


Tukey/Mandel Interaction Plots of Response for Pairs of Factors
tukey.plot    Tukey/Mandel Interaction Plots of Response for Pairs of Factors

USAGE

tukey.plot(x.factor, response, group, ..., orient = "default")

mandel.plot(x.factor, response, group, ..., orient = "default")

x.factor	factor whose margins are to be plotted on the x-axis. Factor levels are plotted below the marginal means or effects.

response	numeric vector.

group	factor whose levels will be separate traces.

...	optional specification of other parameters to be passed to plotting routines.

orient	"default" = default (as in interaction.plot), "switch" = switch plot orientation of x.factor and trace.factor, "both" = plot both ways.

VALUE

a plot will be created showing the requested function of responses for each level of the x.factor at each level of the trace.factor. By default, lines for each value of the trace.factor are drawn in different styles so that they may be more easily distinguished.

SEE ALSO

interaction.plot, margin.plot.lm.

EXAMPLES

> attach(catalyst)

> tukey.plot(Conc, Yield, Cat)

> mandel.plot(Conc, Yield, Cat)

> detach()


spread out values to avoid collision in plotting
uncollide    spread out values to avoid collision in plotting

USAGE

uncollide( x, small = 0.2 )

x	numeric vector

small	minimum separation of values

VALUE

vector of x's with slight adjustment

EXAMPLES

text( x, uncollide(y), state )


unclass factor (but keep numeric level)
unfactor    unclass factor (but keep numeric level)

USAGE

unfactor(x.factor, class="factor")

x.factor	element of class "factor" or "ordered"

class	usually "factor" or "ordered"

VALUE

vector of elements of x.factor

SEE ALSO

unclass, interaction.plot.

EXAMPLES

unfactor(a)