[R] Confidence intervals nls

FishR tomworthington at talk21.com
Mon Feb 15 20:01:25 CET 2010


Dear All

I am quite new to R and would appreciate some help fitting 95% confidence
intervals to a nls function. I have the data

DOY       CET
90	5.9
91	8
92	8.4
93	7.7
95	6.6
96	6.8
97	7.1
98	9.7
99	12.3
100	12.8
102	11
103	9.3
104	9.8
105	9.9
107	7.7
110	6.2
111	5.9
112	5.9
113	3.4
114	3.5
116	3.3
117	5.4
118	6.3
119	9.7
120	11.2
121	7.3
124	7.8
etc  

I am trying to use some code that has been previously posted on the help
boards but keep getting an error message "dim(X) must have a positive
length"

plot(DOY, CET)
model<-nls(CET~a+(b*sin(((2*pi)/365)*(DOY+t))),start=list(a=9.5, b=-6.5,
t=65))
summary(model)
days<-seq(0,365,1)
predict(model,list(DOY=days))

se.fit <- sqrt(apply(attr(predict(model,list(DOY = days)),"gradient"),1, 
                  function(x) sum(vcov(fm)*outer(x,x)))) 
matplot(days, predict(model,list(DOY = days))+ 
               outer(se.fit,qnorm(c(.5, .025,.975))),type="l") 

Any help would be greatly appreciated 

Best wishes

Tom 

-- 
View this message in context: http://n4.nabble.com/Confidence-intervals-nls-tp1556487p1556487.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list