[R] confidence interval or error of x intercept of a linear

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Tue Mar 24 17:16:41 CET 2009


(Ted Harding) wrote:
> On 24-Mar-09 03:31:32, Kevin J Emerson wrote:
...
> When I have time for it (not today) I'll see if I can implement
> this neatly in R. It's basically a question of solving
> 
>   (N-2)*(1 - R(X0))/R(X0) = qf(P,1,(N-1))
> 
> for X0 (two solutions, maybe one, if any exist). 
<etc.>

A quick and probably not-too-dirty way is to rewrite it as a nonlinear
model:

x <- 1:10
Y <- 2*x - 3 + rnorm(10, sd=.1)
cf <- coef(lm(Y~x))
confint(nls(Y~beta*(x-x0), start=c(beta=cf[[2]],x0=-cf[[1]]/cf[[2]])))




-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907




More information about the R-help mailing list