1 | Mreglde.sub(x, B)
|
x |
|
B |
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, B)
{
n = x[1]
ncx = x[2]
ncy = x[3]
nxx = n * ncx
nyy = n * ncy
ncx1 = ncx + 1
B = matrix(B, nrow = ncx1, ncol = ncy)
iu = nxx + 3
xm = matrix(x[4:iu], ncol = ncx)
il = iu + 1
ym = matrix(x[il:length(x)], ncol = ncy)
ainit = B[1:ncy]
il = ncy + 1
Binit = matrix(B[il:length(B)], nrow = ncx, ncol = ncy)
yhat = matrix(0, nrow = n, ncol = ncy)
for (i in 1:n) {
z = as.matrix(xm[i, ])
yhat[i, ] = t(Binit) %*% z
}
yhat = t(t(yhat) + ainit)
res = ym - yhat
res = sum(sqrt(apply(res^2, 1, sum)))
res
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.