robRatio: Robust estimator for ratio models

View source: R/robRatio.r

robRatioR Documentation

Robust estimator for ratio models

Description

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.

Usage

robRatio(
  x1,
  y1,
  gm = "b",
  wf = "T",
  scale = "AAD",
  rt = 1,
  tp = 8,
  rp.max = 100,
  cg.rt = 0.01
)

Arguments

x1

single explanatory variable (a vector)

y1

objective variable to be imputed (a vector)

gm

indication of gamma value as follows:
gm="a": gamma=1
gm="b": gamma=1/2 (conventional ratio model)
gm="c"; gamma=0 (regression model without intercept)

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)

Value

a list with the following elements

cond

Weight function, scale, and other arguments choosed

par

robustly estimated ratio of y1 to x1 (beta)

res

homoscedastic quasi-residuals

wt

robust weights

rp

total number of iteration

s1

changes of the scale (AAD or MAD)

efg

error flag. 1: acalculia (all weights become zero) 0: successful termination

Examples

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)


robRatio documentation built on Nov. 5, 2025, 5:25 p.m.