1 | bireg(x, y, iter = 20, bend = 1.28)
|
x |
|
y |
|
iter |
|
bend |
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 | ##---- 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 (x, y, iter = 20, bend = 1.28)
{
x <- as.matrix(x)
ma <- matrix(0, ncol(x), 1)
m <- matrix(0, ncol(x), ncol(x))
mvals <- apply(x, 2, mest, bend)
for (i in 1:ncol(x)) {
ma[i, 1] <- bicov(x[, i], y)
for (j in 1:ncol(x)) m[i, j] <- bicov(x[, i], x[, j])
}
slope <- solve(m, ma)
b0 <- mest(y, bend) - sum(slope %*% mvals)
for (it in 1:iter) {
res <- y - x %*% slope - b0
for (i in 1:ncol(x)) ma[i, 1] <- bicov(x[, i], res)
slopeadd <- solve(m, ma)
b0add <- mest(res, bend) - sum(slopeadd %*% mvals)
if (max(abs(slopeadd), abs(b0add)) < 1e-04)
break
slope <- slope + slopeadd
b0 <- b0 + b0add
}
if (max(abs(slopeadd), abs(b0add)) >= 1e-04)
paste("failed to converge in", iter, "iterations")
list(coef = c(b0, slope), residuals = res)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.