[R] Cross validation for nls function
mael
henriksson.anna at live.se
Wed Aug 1 09:03:31 CEST 2012
Hi,
I've written a logistic function using nls and I'd like to do cross
validation for this. Is there a package for that? Below is an example of my
data and the function. N terms are presence/absence data and the response is
succesful/failed data.
y1<-sample(0:1,100,replace=T)
N1<-sample(0:1,100,replace=T)
N2<-sample(0:1,100,replace=T)
N3<-sample(0:1,100,replace=T)
N4<-sample(0:1,100,replace=T)
Sw<- function(y1, N1,N2,N3,N4) {
SA <- nls(y1~exp(c+(a1*N1)+(a2*N2)+(a3*N3)+(a4*N4)
)/
(1+exp(c+(a1*N1)+(a2*N2)+(a3*N3)+(a4*N4)))
,start=list(a1=-0.2,a2=-0.2,a3=-0.2,a4=-0.2,c=0.2))
SA
}
model<- Sw(y1, N1,N2,N3,N4)
summary(model)
Thanks for any help!
/Anna
--
View this message in context: http://r.789695.n4.nabble.com/Cross-validation-for-nls-function-tp4638630.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list