Description Usage Arguments Value Examples
Given the true starting point, number of points, and the shortest Hamiltonian path, this function returns the change-point estimation based on the ratio cut.
1 | CpBeeCell(ni,n1,n2,re.path)
|
ni |
true starting point |
n1 |
always 1 |
n2 |
number of points |
re.path |
the shortest Hamiltonian path returned from the function Hpath |
the change-point estimate based on the ratio cut
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | data(Data_cell,Data_bee_A1,Data_bee_B1,package="GraphCpClust")
# Example in Shi, Wu and Rao (2017)
Lnorm_cell = function(x) sqrt(sum(t(x)*x))# Euclidean distance, but reader can define different distance such as max(abs(x)) and sum(abs(x))
Transf_cell = function(x) sqrt(x) #sqrt(x) log(1+x) # for cell images, squareroot transformation or log transformation
# Note: Have the data in an image folder in your working directory and in the .png package subfolder img.
# for whole sequence of data
data.trans=Distance.data_cell_bee(Data_cell,1,285,Lnorm_cell)
HD=data.trans$hd
SHP=CpBeeCell(1,1,285,Hpath_cell_bee(1,285,HD))
# cp1 = first change-point estimate
# cp1 should be equal to SHP$Ratio.cut which is ratio cut change-point estiamte
cp1=SHP$Ratio.cp
# subsequence from from first node to cp1 (the first change-point estiamte)
# repeat procdure to the change-point estimate
data.trans=Distance.data_cell_bee(Data_cell,1,cp1,Lnorm_cell)
HD=data.trans$hd
SHP=CpBeeCell(1,1,cp1,Hpath_cell_bee(1,cp1,HD))
SHP$Sn # statistic - value shows whether our change-point test is signficant or not based on a comparison to the critical value from a table.
cp2=SHP$Ratio.cp
# subsequence fro cp1+1 to last node
# repeat procdure to the change-point estimate
data.trans=Distance.data_cell_bee(Data_cell,cp1+1,285,Lnorm_cell)
HD=data.trans$hd
SHP=CpBeeCell(cp1+1,1,285-cp1,Hpath_cell_bee(1,285-cp1,HD)) # first number is the true initial starting point location after the first change-point estimate
cp3=SHP$Ratio.cp
# input data must be a data list
data.trans=Distance.data_cell_bee(Data_cell,1,285,Lnorm_cell)
HD=data.trans$hd
SHP=CpBeeCell(1,1,285,Hpath_cell_bee(1,285,HD))
print(cp1)
print(cp2)
print(cp3)
# Example in Shi, Wu and Rao (2018)
#####################################################start
# fig4A
Lnorm_bee = function(x) abs(sum(x)) #sqrt(sum(t(x)*x))# sqrt(sum(t(x)*x))#sqrt(sum(t(x)*x)) max(abs(x)) #sum(abs(x))
Transf_bee = function(x) sqrt(x) #sqrt(x) log(1+x)
nb=1;ne=49;
nl=ne-nb+1
theta=0#thresheld
data.trans=Distance.data_cell_bee(Data_bee_A1,1,ne,Lnorm_bee)
HD=data.trans$hd
SHP1=CpBeeCell(1,1,ne,Hpath_cell_bee(1,ne,HD))
par(mar=c(4,5,1,1)+0.1,fig=c(0,1,0,1))
plot(x=c(1:(ne-1)),y=SHP1$Ratio.cut,ylab=expression(italic(C[t]^{'SHP(w*)'}/(t(N-t)))),xlab=expression(italic(t)), type="b", lwd=1.5,lty=3, pch=20)
abline(v=which.min(SHP1$Ratio.cut[1:20]),lty=5)
abline(v=which.min(SHP1$Ratio.cut[20:ne])+19,lty=5)
#####################################################end
#####################################################start
# fig4B
Lnorm_bee = function(x) abs(sum(x)) #sqrt(sum(t(x)*x))# sqrt(sum(t(x)*x))#sqrt(sum(t(x)*x)) max(abs(x)) #sum(abs(x))
Transf_bee = function(x) sqrt(x) #sqrt(x) log(1+x)
nb=5;ne=49;
nl=ne-nb+1
theta=0#thresheld
data.trans=Distance.data_cell_bee(Data_bee_B1,1,45,Lnorm_bee)
HD=data.trans$hd
SHP2=CpBeeCell(1,1,45,Hpath_cell_bee(1,45,HD))
par(mar=c(4,5,1,1)+0.1,fig=c(0,1,0,1) )
plot(x=c(1:(45-1)),y=SHP2$Ratio.cut,ylab=expression(italic(C[t]^{'SHP(w*)'}/(t(N-t)))),xlab=expression(italic(t)), type="b", lwd=1.5,lty=3, pch=20)
abline(v=which.min(SHP2$Ratio.cut[1:45]),lty=5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.