[R] finding interpolated values along an empirical parametric curve

Michael Friendly friendly at yorku.ca
Mon Dec 5 15:16:25 CET 2011

```Given the following data, I am plotting log.det ~ norm.beta, where the
points depend on a parameter, lambda
(but there is no functional form).
I want to find the (x,y) positions along this curve corresponding to two
special values of lambda

lambda.HKB <- 0.004275357
lambda.LW <- 0.03229531

and draw reference lines at ~ -45 degrees (or normal to the curve) thru
these points.
How can I do this?  A complete example is below

> pd
lambda   log.det norm.beta
0.000  0.000 -12.92710  3.806801
0.005  0.005 -14.41144  2.819460
0.010  0.010 -15.41069  2.423197
0.020  0.020 -16.82581  2.010924
0.040  0.040 -18.69819  1.611304
0.080  0.080 -21.05065  1.283928
>

pd <-
structure(list(lambda = c(0, 0.005, 0.01, 0.02, 0.04, 0.08),
log.det = c(-12.9270978142337, -14.411442487768, -15.4106886674014,
-16.8258120792945, -18.6981870228698, -21.050646106925),
norm.beta = c(3.8068008759562, 2.81945995964196, 2.42319655878575,
2.01092421747594, 1.6113040561427, 1.28392804825009)), .Names =
c("lambda",
"log.det", "norm.beta"), class = "data.frame", row.names = c("0.000",
"0.005", "0.010", "0.020", "0.040", "0.080"))

clr <- c("black", rainbow(5, start=.6, end=.1))
lambdaf <- c(expression(~widehat(beta)^OLS), ".005", ".01", ".02",
".04", ".08")
op <- par(mar=c(4, 4, 1, 1) + 0.2, xpd=TRUE)
with(pd, {plot(norm.beta, log.det, type="b",
cex.lab=1.25, pch=16, cex=1.5, col=clr,
xlab='shrinkage: ||b||',
ylab='variance: log |(Var(b)|)')
text(norm.beta, log.det, lambdaf, cex=1.25, pos=2)
text(min(norm.beta), max(log.det), "Variance vs. Shrinkage",
cex=1.5, pos=4)
})

# How to find the (x,y) positions for these values of lambda along the
curve of log.det ~ norm.beta ?
lambda.HKB <- 0.004275357
lambda.LW <- 0.03229531

--
Michael Friendly     Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street    Web:   http://www.datavis.ca