| robRatio | R Documentation |
This function integrates 4 functions (RrT.aad, RrT.mad,
RrH.aad and RrH.mad) for estimating generalized ratio model. Please note
that the values for the tuning parameter tp allowed in this function
is standardized. See the vignette for the detail.
robRatio(
x1,
y1,
gm = "b",
wf = "T",
scale = "AAD",
rt = 1,
tp = 8,
rp.max = 100,
cg.rt = 0.01
)
x1 |
single explanatory variable (a vector) |
y1 |
objective variable to be imputed (a vector) |
gm |
indication of gamma value as follows: |
wf |
weight function (wf=T : Tukey, wf=H : Huber) |
scale |
scale for residuals. "AAD"(default) or "MAD". |
rt |
sample weight (default 1) |
tp |
standardized tuning parameter. choose 4, 6 or 8. Smaller figure is more robust (default tp=8). See details. |
rp.max |
maximum number of iteration (default: rp.max=50) |
cg.rt |
convergence condition to stop iteration (default: cg1=0.001) |
a list with the following elements
condWeight function, scale, and other arguments choosed
parrobustly estimated ratio of y1 to x1 (beta)
reshomoscedastic quasi-residuals
wtrobust weights
rptotal number of iteration
s1changes of the scale (AAD or MAD)
efgerror flag. 1: acalculia (all weights become zero) 0: successful termination
require(robRatio)
x1 <- seq(1, 10, by=0.1)
#e <- rnorm(length(x1))
e <- rt(length(x1), df=3) # error term following t distribution
b <- 2 # true value of slope
y1 <- b*x1 + x1*e # example 1: gamma=1
y2 <- b*x1 + sqrt(x1)*e # example 2: gamma=1/2
o1 <- robRatio(x1, y1, gm="a")
o2 <- robRatio(x1, y2, gm="b")
o1$par; o2$par # estimated slope
cols = RColorBrewer::brewer.pal(11, "PiYG")
cl1 <- round((o1$wt)*10+1)
cl2 <- round((o2$wt)*10+1)
oldpar <- par(mfrow=c(1,2))
plot(x1, y1, col=cols[cl1], pch=20)
plot(x1, y2, col=cols[cl2], pch=20)
par(oldpar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.