Description Usage Arguments Value Note Author(s) References Examples
Fits four linear models ("A", "B", "C", and "D") for the two-group, straight-line ANCOVA problem. (A) Model "A", the full model - fits two intercepts and two slopes (separate intercepts and slopes for each group); (B) Model "B", a reduced model - fits single intercept and single slope to all the data (ignoring group designation); (C) Model "C", a reduced model - fits two different intercepts and a single, common slope; (D) Model "D", a reduced model - fits a single, common intercept and two different slopes.
1 2 3 4 5 6 7 8 9 |
facxy |
a data frame with three columns in specific order: (1) factor (Group) variable, (2) numeric x-axis predictor, regressor (or independent) variable, and (3) numeric y-axis criterion (or dependent) variable. |
x |
an object of class |
object |
an object of class |
modelType2Plot |
a character letter, "A", "B", "C", or "D", to indicate which model, with its associated fitted lines (abline), to plot. |
... |
not used. |
Returns an object of class "sla", which is a list containing the following components:
Call |
model call |
INPUT.df |
input data frame |
Summary of Input Data Frame |
produced from the generic function summary(). |
Mod.A |
an object of class "lm" for the fit of Model A. |
Mod.B |
an object of class "lm" for the fit of Model B. |
Mod.C |
an object of class "lm" for the fit of Model C. |
Mod.D |
an object of class "lm" for the fit of Model D. |
Fit.Table |
a data frame containing a description of the fit, number of parameters estimated, residual degrees of freedom, residual sum of squares, and residual mean square for each model "lm" fit, i.e., for models A, B, C and D. |
Test.Table |
a data frame containing a description of three tests of (reduced) models B, C, and D vs. the (full) model A, the degrees of freedom associated with the anova() comparison of the reduced and full models [note: always 2, 1, and 1], the difference between the residual sums of squares between the reduced and full models, the F statistic associated with the test, and the probability associated with the corresponding F statistic for the test. |
Fit.Table.Pretty |
a data frame containing essentially the same information as in Fit.Table but displayed in a prettier format. |
Test.Table.Pretty |
a data frame containing essentially the same information as in Test.Table but displayed in a prettier format. |
(1) The hellung data frame with conc and diameter raw values is available in the ISwR library from Dalgaard P (2002) Introductory Statistics with R. Springer.
(2) Simulated data sets (without setting the seed) using the code provided in the examples yield the desired outcomes 95 percent of the time.
W Greg Alvord
Dalgaard P (2002) Introductory Statistics with R. Springer.
Draper NR and Smith H (1998) Applied Regression Analysis. 3rd ed. Wiley.
Fox J (2008) Applied Regression Analysis and General Linear Models, 2nd ed. Sage.
Fox J and Weisberg S (2011) An R Companion to Applied Regression, 2nd ed. Sage.
Searle SR (1971) Linear Models, Wiley.
Venables WN and Ripley BD (2002) Modern Applied Statistics with S. 4th ed. Springer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | data(eqslo)
eqsloObj <- sla(eqslo)
eqsloObj
summary(eqsloObj)
attributes(eqsloObj)
eqsloObj$Mod.C # best fitting reduced model, equivalent slopes, different intercepts
summary(eqsloObj$Mod.C) # lm summary of Model C
plot(eqsloObj, mod = 'C') # plot of data eqslo, fitted lines with equal slopes, different intercepts
##
data(eqint)
eqintObj <- sla(eqint)
eqintObj
summary(eqintObj)
attributes(eqintObj)
eqintObj$Mod.D # best fitting reduced model, equivalent intercepts, different slopes
summary(eqintObj$Mod.D) # lm summary of Model D
plot(eqintObj, mod = 'D') # plot of data eqint, fitted lines with equal intercepts, different slopes
##
## See MASS, 4th ed., pp 139-144 for ANCOVA of whiteside data
##
library(MASS)
data(whiteside)
whitesideObj <- sla(whiteside)
summary(whitesideObj) # See MASS, 4th ed., pp 139-144 for ANCOVA of whiteside data
par(mfrow = c(2,2))
plot(whitesideObj, "A") # different intercepts and different slopes
plot(whitesideObj, "B") # common intercept and common slope
plot(whitesideObj, "C") # different intercepts, common slope
plot(whitesideObj, "D") # different slopes, common intercept
##
## See Dalgaard, pp. 172-182 for ANCOVA of (log10) hellung data
##
data(hellunglog)
hellunglogObj <- sla(hellunglog)
hellunglogObj
summary(hellunglogObj) # See Dalgaard, pp. 172-182 for ANCOVA of (log10) hellung data
par(mfrow = c(2,2))
plot(hellunglogObj, "A") # different intercepts and different slopes
plot(hellunglogObj, "B") # common intercept and common slope
plot(hellunglogObj, "C") # different intercepts, common slope
plot(hellunglogObj, "D") # different slopes, common intercept
##
## Simulate data for common slope, different intercepts
##
group <- c(rep('A', 50), rep('B', 50))
x <- rep(1:50, 2)
set.seed(50) #
y1 <- rnorm(50) + 4*.05*x[1:50]
set.seed(100)
y2 <- rnorm(50) + 7 + y1
y <- c(y1, y2)
esdf <- data.frame(group, x, y)
esdfObj <- sla(esdf)
esdfObj
summary(esdfObj)
par(mfrow = c(2,2))
plot(esdfObj, mod = 'A')
plot(esdfObj, mod = 'B')
plot(esdfObj, mod = 'C')
plot(esdfObj, mod = 'D')
##
## Simulate data for common intercept, different slopes
##
group <- c(rep('A', 50), rep('B', 50))
x <- rep(1:50, 2)
set.seed(49) #
y1 <- rnorm(50) + 1*.03*x[1:50]
set.seed(99) #
y2 <- rnorm(50) + 1*.25*x[51:100]
y <- c(y1, y2)
eidf <- data.frame(group, x, y)
eidfObj <- sla(eidf)
eidfObj
summary(eidfObj)
par(mfrow = c(2,2))
plot(eidfObj, mod = 'A')
plot(eidfObj, mod = 'B')
plot(eidfObj, mod = 'C')
plot(eidfObj, mod = 'D')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.