Chapter 10: Density classes
Figure 1
func<-"prod"
# frame 1
marginal<-"polyno"
s<-10
N<-c(40,40)
yla<-1
ala<--yla
support<-c(ala,yla,ala,yla)
ef<-pcf.func(func,N,support=support,marginal=marginal,g=s)
dp<-draw.pcf(ef)
contour(dp$x,dp$y,dp$z) #,drawlabels=FALSE,col="black")
# frame 2
marginal<-"polyno"
s<-2
N<-c(32,32)
yla<-1
ala<--yla
support<-c(ala,yla,ala,yla)
ef<-pcf.func(func,N,support=support,marginal=marginal,g=s)
dp<-draw.pcf(ef)
contour(dp$x,dp$y,dp$z) #,nlevels=30)
# frame 3
marginal<-"polyno"
s<-1
N<-c(100,100)
yla<-1
ala<--yla
support<-c(ala,yla,ala,yla)
ef<-pcf.func(func,N,support=support,marginal=marginal,g=s)
dp<-draw.pcf(ef)
contour(dp$x,dp$y,dp$z,nlevels=20)
# frame 4
marginal<-"polyno"
s<-0.5
N<-c(100,100)
yla<-1
ala<--yla
support<-c(ala,yla,ala,yla)
ef<-pcf.func(func,N,support=support,marginal=marginal,g=s)
dp<-draw.pcf(ef)
contour(dp$x,dp$y,dp$z,nlevels=20)
# frame 5
marginal<-"double"
N<-c(100,100)
yla<-4
ala<--yla
support<-c(ala,yla,ala,yla)
ef<-pcf.func(func,N,support=support,marginal=marginal)
dp<-draw.pcf(ef)
contour(dp$x,dp$y,dp$z,nlevels=20,xlim=c(-3.5,3.5),ylim=c(-3.5,3.5))
# frame 6
marginal<-"student"
N<-c(100,100)
t<-3
yla<-4
ala<--yla
support<-c(ala,yla,ala,yla)
ef<-pcf.func(func,N,g=t,support=support,marginal=marginal)
dp<-draw.pcf(ef)
contour(dp$x,dp$y,dp$z,nlevels=30,xlim=c(-4,4),ylim=c(-4,4))
# frame 7
marginal<-"student"
N<-c(100,100)
t<-1
yla<-5
ala<--yla
support<-c(ala,yla,ala,yla)
ef<-pcf.func(func,N,g=t,support=support,marginal=marginal)
dp<-draw.pcf(ef)
contour(dp$x,dp$y,dp$z,nlevels=30,xlim=c(-5,5),ylim=c(-5,5))
# frame 8
marginal<-"student"
N<-c(140,140)
t<-0.5
yla<-10
ala<--yla
support<-c(ala,yla,ala,yla)
ef<-pcf.func(func,N,g=t,support=support,marginal=marginal)
dp<-draw.pcf(ef)
contour(dp$x,dp$y,dp$z,nlevels=30,xlim=c(-8,8),ylim=c(-8,8))
Figure 2
func<-"gauss"
marginal<-"unif"
corona<-3
rho<-c(0.1,0.4,0.8)
# frames 1-3
N<-c(100,100)
rho<-c(0.1,0.4,0.8)
for (i in 1:length(rho)){
r<-rho[i]
ef<-pcf.func(func,N,marginal=marginal,r=r)
dp<-draw.pcf(ef)
contour(dp$x,dp$y,dp$z,nlevels=50,xlim=c(0,1),ylim=c(0,1))
}
# frames 4-6
N<-c(32,32)
for (i in 1:length(rho)){
r<-rho[i]
ef<-pcf.func(func,N,marginal=marginal,r=r)
dp<-draw.pcf(ef,corona=corona)
persp(dp$x,dp$y,dp$z,theta=-25,phi=40,ticktype="detailed",
xlab="",ylab="",zlab="")
}
Figure 3
func<-"gauss"
N<-c(100,100)
marginal<-"student"
yla<-6
ala<--yla
support<-c(ala,yla,ala,yla)
r<-0.8
teet<-c(1,2,4)
# frames 1-3
for (i in 1:length(teet)){
t<-rep(teet[i],2)
pcf<-pcf.func(func,N,t=t,support=support,marginal=marginal,r=r)
dp<-draw.pcf(pcf)
contour(dp$x,dp$y,dp$z,nlevel=100,xlim=c(-6,6),ylim=c(-6,6))
}
Figure 4
func<-"gauss"
marginal<-"student"
r<-0.8
teet<-c(1,2,4)
yla<-6
ala<--yla
support<-c(ala,yla,ala,yla)
cova<-matrix(1,2,2)
cova[1,2]<-r
cova[2,1]<-r
t<-rep(teet[3],2)
N<-c(120,120)
pcf<-pcf.func(func,N,t=t,support=support,marginal=marginal,r=r)
dp<-draw.pcf(pcf)
propor<-0.005 #lev<-0.005*max(pcf$value)
st.big<-leafsfirst(pcf,propor=propor,refe=c(0,0))
st<-treedisc(st.big,pcf,ngrid=100)
st2<-prunemodes(st,modenum=2)
st22<-prunemodes(st.big,modenum=2)
paletti<-c("red","blue","green",
"orange","navy","darkgreen",
"orchid","aquamarine","turquoise",
"pink","violet","magenta","chocolate","cyan",
colors()[50:657],colors()[50:657])
ts<-tree.segme(st22,pcf=pcf,paletti=paletti)
# frame 1
draw.levset(pcf,propor=propor,col=ts)
text(-4.5,-4.5,"M2")
text(4.5,4.5,"M1")
# frame 2
plotvolu(st2,colo=TRUE,ptext=0.3,proba=TRUE,modelabel=TRUE)
# frame 3
plotbary(st2,modelabel=TRUE,ptext=0.3)
# frame 4
plotbary(st2,modelabel=TRUE,coordi=2,ptext=0.3)
Figure 5
r<-0.8
teet<-c(1,2,4)
cova<-matrix(1,2,2)
cova[1,2]<-r
cova[2,1]<-r
t<-rep(teet[3],2)
seed<-4
n<-1000
dendat<-sim.data(n=n,cova=cova,type="gauss",marginal="student",t=t,seed=seed)
rl<-min(dendat)
ru<-max(dendat)
rho<-1.4
tt<-leafsfirst(dendat=dendat,rho=rho)
paletti<-c("red","blue","green",
"orange","navy","darkgreen",
"orchid","aquamarine","turquoise",
"pink","violet","magenta","chocolate","cyan",
colors()[50:657],colors()[50:657])
ts<-tree.segme(tt,paletti=paletti)
# frame 1
plot(dendat,col=ts,xlim=c(rl,ru),ylim=c(rl,ru),
xlab="coordinate 1",ylab="coordinate 2")
text(4.5,5.5,"A")
text(-5,-5,"B")
# frame 2
plotvolu(tt,modelabel=FALSE,colo=TRUE)
text(450,7,"A")
text(550,9,"B")
# frame 3
plotbary(tt,coordi=1,modelabel=FALSE)
text(4,8,"A")
text(-4,8,"B")
# frame 4
plotbary(tt,coordi=2,modelabel=FALSE)
text(4,8,"A")
text(-3,9,"B")
Figure 6
func<-"gauss"
marginal<-"student"
r<-0.8
teet<-c(1,2,4)
yla<-8
ala<--yla
support<-c(ala,yla,ala,yla)
cova<-matrix(1,2,2)
cova[1,2]<-r
cova[2,1]<-r
t<-rep(teet[1],2)
N<-c(120,120)
pcf<-pcf.func(func,N,t=t,support=support,marginal=marginal,r=r)
dp<-draw.pcf(pcf)
propor<-0.005 #lev<-0.005*max(pcf$value)
st.big<-leafsfirst(pcf,propor=propor,refe=c(0,0))
modenum<-4
st22<-prunemodes(st.big,modenum=modenum)
st.pro<-leafsfirst(pcf,propor=propor,refe=c(0,0),levmet="proba")
stpro22<-prunemodes(st.pro,modenum=modenum)
paletti<-c("red","blue","green",
"orange","navy","darkgreen",
"orchid","aquamarine","turquoise",
"pink","violet","magenta","chocolate","cyan",
colors()[50:657],colors()[50:657])
ts<-tree.segme(st22,pcf=pcf,paletti=paletti)
# frame 1
draw.levset(pcf,propor=propor,col=ts)
# frame 2
# Warning: the calculation can take a long time
plotvolu(st22,colo=TRUE)
# frame 3
# Warning: the calculation can take a long time
plotvolu(st22,colo=TRUE,ptext=0.3,proba=TRUE)
# frame 4
# Warning: the calculation can take a long time
plotvolu(stpro22,colo=TRUE,ptext=0.003)
Figure 7
func<-"student"
marginal<-"unif"
rho<-c(0.1,0.4,0.8)
df<-4
# frames 1-3
N<-c(100,100)
for (i in 1:length(rho)){
r<-rho[i]
ef<-pcf.func(func,N,marginal=marginal,r=r,df=df)
dp<-draw.pcf(ef)
contour(dp$x,dp$y,dp$z,nlevels=50,xlab="",ylab="")
}
# frames 4-6
N<-c(35,35)
for (i in 1:length(rho)){
r<-rho[i]
ef<-pcf.func(func,N,marginal=marginal,r=r,df=df)
dp<-draw.pcf(ef,pnum=c(30,30))
persp(dp$x,dp$y,dp$z,theta=-25,phi=40,ticktype="detailed",
xlab="",ylab="",zlab="")
}
Figure 8
func<-"student"
N<-c(100,100)
marginal<-"normal"
yla<-4
ala<--yla
support<-c(ala,yla,ala,yla)
r<-0.6
teet<-c(1,2,4)
# frames 1-3
for (i in 1:length(teet)){
df<-teet[i]
pcf<-pcf.func(func,N,support=support,marginal=marginal,r=r,df=df)
dp<-draw.pcf(pcf)
contour(dp$x,dp$y,dp$z,nlevel=50)
}
Figure 9
func<-"student"
marginal<-"normal"
yla<-4
ala<--yla
support<-c(ala,yla,ala,yla)
r<-0.6
teet<-c(1,2,4)
N<-c(140,140)
df<-teet[1]
cova<-matrix(1,2,2)
cova[1,2]<-r
cova[2,1]<-r
pcf<-pcf.func(func,N,support=support,marginal=marginal,r=r,df=df)
dp<-draw.pcf(pcf)
propor<-0.005 #lev<-0.005*max(pcf$value)
st.big<-leafsfirst(pcf,propor=propor,refe=c(0,0))
st<-treedisc(st.big,pcf,ngrid=100)
modenum<-4
st22<-prunemodes(st.big,modenum=modenum)
paletti<-c("red","blue","green",
"orange","navy","darkgreen",
"orchid","aquamarine","turquoise",
"pink","violet","magenta","chocolate","cyan",
colors()[50:657],colors()[50:657])
paletti<-c("red","blue","green",
"orange","orange","green",
"red","aquamarine","navy",
"blue","violet","magenta","chocolate","cyan")
ts<-tree.segme(st.big,pcf=pcf,paletti=paletti)
# frame 1
draw.levset(pcf,propor=propor,col=ts)
text(-3.8,-3.8,"M1")
text(3.3,-3.3,"M2")
text(-3.3,3.3,"M3")
text(3.8,3.8,"M4")
# frame 2
plotvolu(st,colo=TRUE,ptext=0.3,proba=TRUE,modelabel=TRUE)
# frame 3
plotbary(st,modelabel=TRUE,ptext=0.3)
# frame 4
plotbary(st,modelabel=TRUE,coordi=2,ptext=0.3)
Figure 10
r<-0.6
teet<-c(1,2,4)
cova<-matrix(1,2,2)
cova[1,2]<-r
cova[2,1]<-r
df<-teet[1]
seed<-4
n<-1000
dendat<-sim.data(n=n,cova=cova,type="student",marginal="gauss",df=df,seed=seed)
rl<-min(dendat)
ru<-max(dendat)
rho<-1
tt<-leafsfirst(dendat=dendat,rho=rho)
paletti<-c("red","blue","green",
"orange","navy","darkgreen",
"orchid","aquamarine","turquoise",
"pink","violet","magenta","chocolate","cyan",
colors()[50:657],colors()[50:657])
ts<-tree.segme(tt,paletti=paletti)
# frame 1
plot(dendat,col=ts,xlim=c(rl,ru),ylim=c(rl,ru),
xlab="coordinate 1",ylab="coordinate 2")
text(-3,-3,"M2")
text(3,-3,"M1")
text(-3,3,"M4")
text(3,3,"M3")
# frame 2
plotvolu(tt,modelabel=TRUE,colo=TRUE,ptext=0.2)
# frame 3
plotbary(tt,coordi=1,modelabel=TRUE,ptext=0.2)
# frame 4
plotbary(tt,coordi=2,modelabel=TRUE,ptext=0.2)
Figure 11
func<-"student"
marginal<-"normal"
r<-0.6
teet<-c(1,2,4)
yla<-6
ala<--yla
support<-c(ala,yla,ala,yla)
cova<-matrix(1,2,2)
cova[1,2]<-r
cova[2,1]<-r
df<-teet[2]
N<-c(120,120)
pcf<-pcf.func(func,N,support=support,marginal=marginal,r=r,df=df)
dp<-draw.pcf(pcf)
propor<-0.005 #lev<-0.005*max(pcf$value)
st.big<-leafsfirst(pcf,propor=propor,refe=c(0,0))
st.pro<-leafsfirst(pcf,propor=propor,refe=c(0,0),levmet="proba")
modenum<-4
st22<-prunemodes(st.big,modenum=modenum)
stpro22<-prunemodes(st.pro,modenum=modenum)
paletti<-c("red","blue","green",
"orange","navy","darkgreen",
"orchid","aquamarine","turquoise",
"pink","violet","magenta","chocolate","cyan",
colors()[50:657],colors()[50:657])
ts<-tree.segme(st22,pcf=pcf,paletti=paletti)
# frame 1
draw.levset(pcf,propor=propor,col=ts,bound=c(-4.5,4.5,-4.5,4.5))
# frame 2
plotvolu(st22,colo=TRUE)
# frame 3
plotvolu(st22,colo=TRUE,ptext=0.3,proba=TRUE,paletti=paletti)
# frame 4
plotvolu(stpro22,colo=TRUE,ptext=0.003)
Figure 12
func<-"gumbel"
marginal<-"unif"
geet<-c(1.5,2,4)
# frames 1-3
N<-c(70,70)
for (i in 1:length(geet)){
g<-geet[i]
ef<-pcf.func(func,N,marginal=marginal,g=g)
dp<-draw.pcf(ef)
contour(dp$x,dp$y,dp$z,nlevels=70,xlab="",ylab="")
}
# frames 4-6
N<-c(40,40)
for (i in 1:length(geet)){
g<-geet[i]
ef<-pcf.func(func,N,marginal=marginal,g=g)
dp<-draw.pcf(ef)
persp(dp$x,dp$y,dp$z,theta=-25,phi=40,ticktype="detailed",
xlab="",ylab="",zlab="")
}
Figure 13
func<-"gumbel"
N<-c(100,100)
marginal<-"gauss"
yla<-3
ala<--yla
support<-c(ala,yla,ala,yla)
geet<-c(1.5,2,4)
# frames 1-3
for (i in 1:length(geet)){
g<-geet[i]
pcf<-pcf.func(func,N,support=support,marginal=marginal,g=g)
dp<-draw.pcf(pcf)
contour(dp$x,dp$y,dp$z,nlevel=50)
}
Figure 14
func<-"gumbel"
marginal<-"normal"
yla<-4
ala<--yla
support<-c(ala,yla,ala,yla)
g<-4
N<-c(120,120)
pcf<-pcf.func(func,N,support=support,marginal=marginal,g=g)
dp<-draw.pcf(pcf)
propor<-0.005 #lev<-0.005*max(pcf$value)
st.big<-leafsfirst(pcf,propor=propor,refe=c(0,0))
modenum<-2
st22<-prunemodes(st.big,modenum=modenum)
paletti<-c("red","blue","green",
"orange","navy","darkgreen",
"orchid","aquamarine","turquoise",
"pink","violet","magenta","chocolate","cyan",
colors()[50:657],colors()[50:657])
paletti<-c("red","blue","green")
ts<-tree.segme(st22,pcf=pcf,paletti=paletti)
# frame 1
draw.levset(pcf,propor=propor,col=ts)
text(-3.5,-3.5,"M2")
text(3.9,3.9,"M1")
# frame 2
plotvolu(st22,colo=TRUE,ptext=0.3,proba=TRUE,modelabel=TRUE)
# frame 3
plotbary(st22,modelabel=TRUE,ptext=0.3)
# frame 4
plotbary(st22,modelabel=TRUE,coordi=2,ptext=0.3)
Figure 15
g<-4
seed<-2
n<-1000
library(copula)
family="gumbel"
c.cop<-archmCopula(family, param=g, dim=2)
set.seed(seed)
dendat<-rcopula(c.cop, n=n)
dendat<-qnorm(dendat)
rl<-min(dendat)
ru<-max(dendat)
rho<-1
tt<-leafsfirst(dendat=dendat,rho=rho)
paletti<-c("red","blue","green",
"orange","navy","darkgreen",
"orchid","aquamarine","turquoise",
"pink","violet","magenta","chocolate","cyan",
colors()[50:657],colors()[50:657])
ts<-tree.segme(tt,paletti=paletti)
# frame 1
plot(dendat,col=ts,xlim=c(rl,ru),ylim=c(rl,ru),
xlab="coordinate 1",ylab="coordinate 2")
text(-3.2,-3,"M2")
text(3,3.3,"M1")
# frame 2
plotvolu(tt,modelabel=TRUE,colo=TRUE,ptext=0.2)
# frame 3
plotbary(tt,coordi=1,modelabel=TRUE,ptext=0.2)
# frame 4
plotbary(tt,coordi=2,modelabel=TRUE,ptext=0.2)
Figure 16
func<-"gumbel"
marginal<-"normal"
yla<-4
ala<--yla
support<-c(ala,yla,ala,yla)
g<-2
N<-c(120,120)
pcf<-pcf.func(func,N,support=support,marginal=marginal,g=g)
dp<-draw.pcf(pcf)
propor<-0.005 #lev<-0.005*max(pcf$value)
st.big<-leafsfirst(pcf,propor=propor,refe=c(0,0))
modenum<-2
st22<-prunemodes(st.big,modenum=modenum)
st.pro<-leafsfirst(pcf,propor=propor,refe=c(0,0),levmet="proba")
st.pro.22<-prunemodes(st.pro,modenum=modenum)
paletti<-c("red","blue","green")
ts<-tree.segme(st22,pcf=pcf,paletti=paletti)
# frame 1
draw.levset(pcf,propor=propor,col=ts)
text(-3.5,-3.5,"M2")
text(3.9,3.9,"M1")
# frame 2
plotvolu(st22,colo=TRUE,ptext=0.3,modelabel=TRUE)
# frame 3
plotvolu(st22,colo=TRUE,ptext=0.3,proba=TRUE,modelabel=TRUE)
# frame 4
plotvolu(st.pro.22,colo=TRUE,ptext=0.003,modelabel=TRUE)
Figure 17
func<-"clayton"
marginal<-"unif"
geet<-c(1,2,4)
# frames 1-3
N<-c(70,70)
for (i in 1:length(geet)){
g<-geet[i]
ef<-pcf.func(func,N,marginal=marginal,g=g)
dp<-draw.pcf(ef)
contour(dp$x,dp$y,dp$z,nlevels=70,xlab="",ylab="")
}
# frames 4-6
N<-c(40,40)
for (i in 1:length(geet)){
g<-geet[i]
ef<-pcf.func(func,N,marginal=marginal,g=g)
dp<-draw.pcf(ef)
persp(dp$x,dp$y,dp$z,theta=-25,phi=40,ticktype="detailed",
xlab="",ylab="",zlab="")
}
Figure 18
func<-"clayton"
N<-c(100,100)
marginal<-"gauss"
yla<-3
ala<--yla
support<-c(ala,yla,ala,yla)
geet<-c(1,2,4)
# frames 1-3
for (i in 1:length(geet)){
g<-geet[i]
pcf<-pcf.func(func,N,support=support,marginal=marginal,g=g)
dp<-draw.pcf(pcf)
contour(dp$x,dp$y,dp$z,nlevel=50)
}
Figure 19
func<-"clayton"
marginal<-"normal"
yla<-4
ala<--yla
support<-c(ala,yla,ala,yla)
g<-4
N<-c(120,120)
pcf<-pcf.func(func,N,support=support,marginal=marginal,g=g)
dp<-draw.pcf(pcf)
propor<-0.005
st.big<-leafsfirst(pcf,propor=propor,refe=c(0,0))
modenum<-2
st22<-prunemodes(st.big,modenum=modenum)
paletti<-c("red","blue","green",
"orange","navy","darkgreen",
"orchid","aquamarine","turquoise",
"pink","violet","magenta","chocolate","cyan",
colors()[50:657],colors()[50:657])
paletti<-c("red","blue","green")
ts<-tree.segme(st22,pcf=pcf,paletti=paletti)
# frame 1
draw.levset(pcf,propor=propor,col=ts)
text(-3.9,-3.9,"M2")
text(3.1,3.1,"M1")
# frame 2
plotvolu(st22,colo=TRUE,ptext=0.3,proba=TRUE,modelabel=TRUE)
# frame 3
plotbary(st22,modelabel=TRUE,ptext=0.3)
# frame 4
plotbary(st22,modelabel=TRUE,coordi=2,ptext=0.3)
Figure 20
g<-4
seed<-2
n<-1000
library(copula)
family="clayton"
c.cop<-archmCopula(family, param=g, dim=2)
set.seed(seed)
dendat<-rcopula(c.cop, n=n)
dendat<-qnorm(dendat)
rl<-min(dendat)
ru<-max(dendat)
rho<-1
tt<-leafsfirst(dendat=dendat,rho=rho)
paletti<-c("red","blue","green",
"orange","navy","darkgreen",
"orchid","aquamarine","turquoise",
"pink","violet","magenta","chocolate","cyan",
colors()[50:657],colors()[50:657])
ts<-tree.segme(tt,paletti=paletti)
# frame 1
plot(dendat,col=ts,xlim=c(rl,ru),ylim=c(rl,ru),
xlab="coordinate 1",ylab="coordinate 2")
text(-3,-3.1,"M1")
text(2.8,2.9,"M2")
# frame 2
plotvolu(tt,modelabel=TRUE,colo=TRUE,ptext=0.2)
# frame 3
plotbary(tt,coordi=1,modelabel=TRUE,ptext=0.2)
# frame 4
plotbary(tt,coordi=2,modelabel=TRUE,ptext=0.2)
Figure 21
func<-"clayton"
marginal<-"normal"
yla<-4
ala<--yla
support<-c(ala,yla,ala,yla)
g<-2
N<-c(120,120)
pcf<-pcf.func(func,N,support=support,marginal=marginal,g=g)
dp<-draw.pcf(pcf)
propor<-0.005 #lev<-0.005*max(pcf$value)
st.big<-leafsfirst(pcf,propor=propor,refe=c(0,0))
modenum<-2
st22<-prunemodes(st.big,modenum=modenum)
st.pro<-leafsfirst(pcf,propor=propor,refe=c(0,0),levmet="proba")
st.pro.22<-prunemodes(st.pro,modenum=modenum)
paletti<-c("red","blue","green")
ts<-tree.segme(st22,pcf=pcf,paletti=paletti)
# frame 1
draw.levset(pcf,propor=propor,col=ts)
text(-3.9,-3.9,"M1")
text(3,3,"M2")
# frame 2
plotvolu(st22,colo=TRUE,ptext=0.3,modelabel=TRUE)
# frame 3
plotvolu(st22,colo=TRUE,ptext=0.3,proba=TRUE,modelabel=TRUE)
# frame 4
plotvolu(st.pro.22,colo=TRUE,ptext=0.003,modelabel=TRUE)
Figure 22
func<-"frank"
marginal<-"unif"
geet<-c(-1,3,5)
# frames 1-3
N<-c(70,70)
for (i in 1:length(geet)){
g<-geet[i]
ef<-pcf.func(func,N,marginal=marginal,g=g)
dp<-draw.pcf(ef)
contour(dp$x,dp$y,dp$z,nlevels=70,xlab="x",ylab="y")
}
# frames 4-6
N<-c(40,40)
for (i in 1:length(geet)){
g<-geet[i]
ef<-pcf.func(func,N,marginal=marginal,g=g)
dp<-draw.pcf(ef)
persp(dp$x,dp$y,dp$z,theta=-25,phi=40,ticktype="detailed",
xlab="",ylab="",zlab="")
}
Figure 23
func<-"frank"
N<-c(100,100) #c(32,32)
marginal<-"gauss"
yla<-3
ala<--yla
support<-c(ala,yla,ala,yla)
geet<-c(-1,3,5)
# frames 1-3
for (i in 1:length(geet)){
g<-geet[i]
pcf<-pcf.func(func,N,support=support,marginal=marginal,g=g)
dp<-draw.pcf(pcf)
contour(dp$x,dp$y,dp$z,nlevel=50,xlab="",ylab="")
}
Figure 24
func<-"frank"
marginal<-"normal"
yla<-3.5
ala<--yla
support<-c(ala,yla,ala,yla)
g<-5
N<-c(120,120)
pcf<-pcf.func(func,N,support=support,marginal=marginal,g=g)
dp<-draw.pcf(pcf)
propor<-0.005
st.big<-leafsfirst(pcf,propor=propor,refe=c(0,0))
modenum<-2
st22<-prunemodes(st.big,modenum=modenum)
paletti<-c("red","blue","green",
"orange","navy","darkgreen",
"orchid","aquamarine","turquoise",
"pink","violet","magenta","chocolate","cyan",
colors()[50:657],colors()[50:657])
paletti<-c("red","blue","green")
ts<-tree.segme(st22,pcf=pcf,paletti=paletti)
# frame 1
draw.levset(pcf,propor=propor,col=ts)
text(-3.1,-3.1,"M1")
text(3.1,3.1,"M2")
# frame 2
plotvolu(st22,colo=TRUE,ptext=0.3,proba=TRUE,modelabel=TRUE)
# frame 3
plotbary(st22,modelabel=TRUE,ptext=0.3)
# frame 4
plotbary(st22,modelabel=TRUE,coordi=2,ptext=0.3)
Figure 25
g<-5
seed<-3
n<-1000
library(copula)
family="frank"
c.cop<-archmCopula(family, param=g, dim=2)
set.seed(seed)
dendat<-rcopula(c.cop, n=n)
dendat<-qnorm(dendat)
rl<-min(dendat)
ru<-max(dendat)
rho<-1.3
tt<-leafsfirst(dendat=dendat,rho=rho)
paletti<-c("red","blue","green",
"orange","navy","darkgreen",
"orchid","aquamarine","turquoise",
"pink","violet","magenta","chocolate","cyan",
colors()[50:657],colors()[50:657])
ts<-tree.segme(tt,paletti=paletti)
# frame 1
plot(dendat,col=ts,xlim=c(rl,ru),ylim=c(rl,ru),
xlab="coordinate 1",ylab="coordinate 2")
text(-2.7,-2.7,"M1")
text(2.7,2.9,"M2")
# frame 2
plotvolu(tt,modelabel=TRUE,colo=TRUE,ptext=0.2)
# frame 3
plotbary(tt,coordi=1,modelabel=TRUE,ptext=0.2)
# frame 4
plotbary(tt,coordi=2,modelabel=TRUE,ptext=0.2)
Figure 26
func<-"frank"
marginal<-"normal"
yla<-3.5
ala<--yla
support<-c(ala,yla,ala,yla)
g<-2
N<-c(120,120)
pcf<-pcf.func(func,N,support=support,marginal=marginal,g=g)
dp<-draw.pcf(pcf)
propor<-0.005 #lev<-0.005*max(pcf$value)
st.big<-leafsfirst(pcf,propor=propor,refe=c(0,0))
modenum<-2
st22<-prunemodes(st.big,modenum=modenum)
st.pro<-leafsfirst(pcf,propor=propor,refe=c(0,0),levmet="proba")
st.pro.22<-prunemodes(st.pro,modenum=modenum)
paletti<-c("red","blue","green")
ts<-tree.segme(st22,pcf=pcf,paletti=paletti)
# frame 1
draw.levset(pcf,propor=propor,col=ts)
text(-3,-3,"M1")
text(3,3,"M2")
# frame 2
plotvolu(st22,colo=TRUE,ptext=0.3,modelabel=TRUE)
# frame 3
plotvolu(st22,colo=TRUE,ptext=0.3,proba=TRUE,modelabel=TRUE)
# frame 4
plotvolu(st.pro.22,colo=TRUE,ptext=0.003,modelabel=TRUE)