Description Usage Arguments Examples
Function which computes the weights for the iteratively reweighted LS estimate of the HBR fit.
1 | hbrwfit2(xmat, y, numstp = 10, epcchk = 1e-04, B = 101, scores = wscores)
|
xmat |
|
y |
|
numstp |
|
epcchk |
|
B |
|
scores |
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 | ##---- 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 (xmat, y, numstp = 10, epcchk = 1e-04, B = 101, scores = wscores)
{
x <- centerx(xmat)
pchk <- length(x[1, ])
plim <- (pchk + 1) * (numstp + 1)
matbeta <- matrix(rep(0, plim), ncol = (numstp + 1))
matwts <- c()
ehatk <- c()
wts2 <- c()
chks <- 1
k <- 1
while (chks > 0) {
if (k == 1) {
firstfit <- kstephbr(y, x, ehatk, 1, wts2, B, scores)
robdis2 <- firstfit$robdis2
ehatlts <- firstfit$ehatlts
betak <- firstfit$fitkp1$coef
wts2 <- firstfit$wts2
matwts <- cbind(matwts, firstfit$pwts)
matbeta[, k] <- betak
ehatk <- firstfit$fitkp1$resid
k <- k + 1
}
else {
kp1fit <- kstephbr(y, x, ehatk, k, wts2, B, scores)
betakp1 <- kp1fit$fitkp1$coef
matwts <- cbind(matwts, kp1fit$pwts)
matbeta[, k] <- betakp1
delta <- betakp1 - betak
chkdel <- sum(delta^2)/(epcchk + sum(betak^2))
if (chkdel < epcchk) {
chks <- -1
}
else {
k <- k + 1
ehatk <- kp1fit$fitkp1$resid
betak <- betakp1
}
}
if (k > numstp) {
chks <- -1
}
}
findim <- dim(matwts)[2]
finwts <- cbind(wts2, matwts[, findim])
if (k == 1) {
coef <- matbeta[, 1]
}
else {
coef <- matbeta[, k]
}
fitted.values <- kp1fit$fitkp1$fitted.values
residuals <- kp1fit$fitkp1$residuals
list(coef = coef, fitted.values = fitted.values, residuals = residuals,
kp1fit = kp1fit, matbeta = matbeta, finwts = finwts,
robdis2 = robdis2, ehatlts = ehatlts)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.