[R] confidence interval or error of x intercept of a linear regression
Thomas Lumley
tlumley at u.washington.edu
Tue Mar 24 09:15:15 CET 2009
On Mon, 23 Mar 2009, Kevin J Emerson wrote:
> Now, it is simple enough to calculate the x-intercept itself ( - intercept /
> slope ), but it is a whole separate process to generate the confidence
> interval of it. I can't figure out how to propagate the error of the slope
> and intercept into the ratio of the two. The option option I have tried to
> figure out is to use the predict function to look for where the confidence
> intervals cross the axis but this hasn't been too fruitful either.
>
A few people have written code to do nonlinear transformations automatically.
There's one in my 'survey' package, and I think there's an example in Venables
& Ripley's "S Programming", and I'm sure there are others.
For example
> library(survey)
> m<-lm(Dev.Rate~Temperature, data=t)
> svycontrast(m, quote(-`(Intercept)`/Temperature))
nlcon SE
contrast 3.8061 0.1975
The `backquotes` are necessary because the coefficient name, (Intercept), isn't a legal variable name.
The svycontrast() function works on anything that has coef() and vcov() methods. The actual delta-method computations are in survey:::nlcon
-thomas
Thomas Lumley Assoc. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
More information about the R-help
mailing list