Displaying 3 results from an estimated 3 matches for "diffctk".
2006 Jun 02
1
doubt with integrate ()
...t;)
fctk1<-function(x)
{density(tdon11, bandwidth=h[i], kernel="gaussian")$y}
for (j in (i+1):nbcol)
{tdon2<-tdon[,j]
tdon21<-subset(tdon2,tdon2!="NA")
fctk2<-function(x)
{density(tdon21,bandwidth=h[j],kernel="gaussian")$y}
diffctk<-function(x)
{abs(fctk1(x)-fctk2(x))}
}}
integrate(diffctk,-Inf,Inf,subdivisions=100)$integral ,
where:
h <- 1.06*ect*(nlc^-0.2); ect <- apply (data,2,sd); nlc <-length of each
column in data, excluding NA's.
The result gives the error:
"Error in int...
2006 May 17
0
script S-plus -> R
...tdon1[tdon1!="NA"]
fctk1<-function(x)
{ksmooth(tdon11,kernel="normal",bandwidth=h[i],x.points=x)$y}
for (j in (i+1):nbcol)
{tdon2<-tdon[,j]
tdon21<-tdon2[tdon2!="NA"]
fctk2<-function(x)
{ksmooth(tdon21,kernel="normal",bandwidth=h[j],x.points=x)$y}
diffctk<-function(x)
{abs(fctk1(x)-fctk2(x))}
intctk<-integrate(diffctk,-Inf,+Inf,subdivisions=100)$integral
overlap<-1-0.5*intctk
cpt<-cpt+1
Results[cpt,]<-c(name.cols(tdon[i]),name.cols(tdon[j]),round(overlap,3))
}}
## tdont is an application example:
tdont <- data.frame(sp.1=c (2 ,3...
2006 Jul 11
0
script problem to obtain pairs of overlap values
...ot;NA")
fctk1<-function(x)
{density (tdon11, bw=h[i], kernel="gaussian")$y}
for (j in (i+1):nbcol)
{tdon2<-tdon[,j]
tdon21<- subset(tdon2,tdon2!="NA")
fctk2<-function(x)
{density (tdon21, bw=h[j], kernel="gaussian")$y}
diffctk<-function(x)
{abs(fctk1(x)-fctk2(x))}
intctk<- approxfun (diffctk(x), rule=2)
int<- integrate(diffctk,-Inf,Inf)$value
overlap<- 1 - 0.5* int
}
}
The use of "approxfun" to integrate the difference in the...