1 |
x1 |
|
y1 |
|
x2 |
|
y2 |
|
xout |
|
outfun |
|
... |
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 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (x1, y1, x2, y2, xout = FALSE, outfun = out, ...)
{
x1 = as.matrix(x1)
if (ncol(x1) != 1)
stop("This function allows one covariate only")
if (xout) {
flag = outfun(x1, plotit = FALSE, ...)$keep
x1 = x1[flag]
y1 = y1[flag]
flag = outfun(x2, plotit = FALSE, ...)$keep
x2 = x2[flag]
y2 = y2[flag]
}
x = c(x1, x2)
y = c(y1, y2)
g = c(rep(1, length(y1)), rep(2, length(y2)))
model = lm(y ~ as.factor(g) * x)
res1 = summary.aov(model)
model = lm(y ~ as.factor(g) + x)
res2 = summary.aov(model)
list(slope.test = res1, ancova = res2)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.