robR2w:

Usage Arguments Examples

Usage

1
robR2w(rob.obj, correc = 1.2076)

Arguments

rob.obj
correc

Examples

 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
##---- 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 (rob.obj, correc = 1.2076) 
{
    wt.bisquare = function(u, c = 4.685) {
        U <- abs(u/c)
        w <- ((1 + U) * (1 - U))^2
        w[U > 1] <- 0
        w
    }
    weight.rob = function(rob.obj) {
        resid.rob = rob.obj$resid
        scale.rob = (rob.obj$scale) * rob.obj$df.residual/length(resid.rob)
        resid.rob = resid.rob/scale.rob
        weight = wt.bisquare(resid.rob)
    }
    if (attr(rob.obj, "class") != "lmRob") 
        stop("This function works only on lmRob objects")
    pred = rob.obj$fitted.values
    resid = rob.obj$resid
    resp = resid + pred
    wgt = weight.rob(rob.obj)
    scale.rob = rob.obj$scale
    resp.mean = sum(wgt * resp)/sum(wgt)
    pred.mean = sum(wgt * pred)/sum(wgt)
    yMy = sum(wgt * (resp - resp.mean)^2)
    rMr = sum(wgt * resid^2)
    r2 = (yMy - rMr)/yMy
    r2correc = (yMy - rMr)/(yMy - rMr + rMr * correc)
    r2adjcor = 1 - (1 - r2correc) * (length(resid) - 1)/(length(resid) - 
        length(rob.obj$coefficients) - 1)
    return(list(robR2w.NoCorrection = r2, robR2w.WithCorrection = r2correc, 
        robR2w.AdjustedWithCorrection = r2adjcor))
  }

musto101/wilcox_R documentation built on May 23, 2019, 10:52 a.m.