Description Usage Arguments Value See Also Examples
This is a method for the as.dendrogram
generic function
1 2 | ## S3 method for class 'vlmc'
as.dendrogram(object, ...)
|
object |
a |
... |
further arguments passed to and from methods. |
An object of class dendrogram
, i.e. a nested list
described on that page.
as.dendrogram
, plot.dendrogram
.
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 | data(presidents)
dpr <- factor(cut(presidents, c(0,45,70,100)), exclude=NULL)# NA = 4th level
(vlmc.pres <- vlmc(dpr))
draw(vlmc.pres)
(dv.dpr <- as.dendrogram(vlmc.pres))
str(dv.dpr)
str(unclass(dv.dpr))
plot(dv.dpr, type ="tr", nodePar = list(pch=c(1,16), cex = 1.5))
## Artificial example
f1 <- c(1,0,0,0) ; f2 <- rep(1:0, 2)
(dt1 <- c(f1,f1,f2,f1,f2,f2,f1))
(vlmc.dt1c01 <- vlmc(dts = dt1, cutoff.prune = 0.1))
(dvlmc <- as.dendrogram(vlmc.dt1c01))
str(dvlmc)
## not so useful:
plot(dvlmc, nodePar= list(pch=c(1,16)))
## complete disaster:
plot(dvlmc, type ="tr", nodePar= list(pch=c(1,16)))
## but this is not (yet) so much better (want the same angles to left
## and right!!
plot(dvlmc, type ="tr", nodePar = list(pch=c(1,16)), center=TRUE,
main = format(vlmc.dt1c01$call))
mtext(paste("dt1 =", gsub(" ","",deparse(dt1,width=100))))
|
'vlmc' a Variable Length Markov Chain;
alphabet '0123', |alphabet| = 4, n = 120.
Call: vlmc(dts = dpr); default cutoff =3.907
-> extensions (= $size ) :
ord.MC context nr.leaves total
2 5 3 42
AIC = 227.6
Warning message:
In vlmc(dpr) : alphabet with >1-letter strings; trying to abbreviate
[x]-( 28 60 26 5| 119)
+--[0]-( 18 7 0 2| 27) <15.22>-T
+--[1]-( 9 39 11 1| 60) <3.00>
| '--[2]-( 0 6 6 0| 12) <4.45>-T
'--[2]-( 0 12 14 0| 26) <11.57>-T
'dendrogram' with 3 branches and 3 members total, at height 2
--[dendrogram w/ 3 branches and 3 members at h = 2]
|--leaf 27 (h= 1 count = c("18", " 7", " 0", " 2"), edgetext = 0 )
|--[dendrogram w/ 1 branches and 1 members at h = 1]
| `--leaf 12 ( count = c("0", "6", "6", "0"), edgetext = 2 )
`--leaf 26 (h= 1 count = c(" 0", "12", "14", " 0"), edgetext = 2 )
List of 3
$ 0: atomic [1:1] 27
..- attr(*, "members")= int 1
..- attr(*, "leaf")= logi TRUE
..- attr(*, "height")= int 1
..- attr(*, "count")= int [1:4] 18 7 0 2
..- attr(*, "edgetext")= chr "0"
$ 1:List of 1
..$ 2: atomic [1:1] 12
.. ..- attr(*, "members")= int 1
.. ..- attr(*, "leaf")= logi TRUE
.. ..- attr(*, "height")= int 0
.. ..- attr(*, "count")= int [1:4] 0 6 6 0
.. ..- attr(*, "edgetext")= chr "2"
..- attr(*, "0-kids")= int [1:3] 0 1 3
..- attr(*, "members")= int 1
..- attr(*, "height")= int 1
..- attr(*, "count")= int [1:4] 9 33 5 1
..- attr(*, "edgetext")= chr "1"
$ 2: atomic [1:1] 26
..- attr(*, "members")= int 1
..- attr(*, "leaf")= logi TRUE
..- attr(*, "height")= int 1
..- attr(*, "count")= int [1:4] 0 12 14 0
..- attr(*, "edgetext")= chr "2"
- attr(*, "0-kids")= int 3
- attr(*, "members")= int 3
- attr(*, "height")= int 2
- attr(*, "count")= int [1:4] 1 2 1 2
[1] 1 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 0 0
'vlmc' a Variable Length Markov Chain;
alphabet '01', |alphabet| = 2, n = 28.
Call: vlmc(dts = dt1, cutoff.prune = 0.1); cutoff =0.1
-> extensions (= $size ) :
ord.MC context nr.leaves total
7 11 6 66
AIC = 27.55
'dendrogram' with 2 branches and 6 members total, at height 7
--[dendrogram w/ 2 branches and 6 members at h = 7]
|--[dendrogram w/ 2 branches and 5 members at h = 6]
| |--[dendrogram w/ 2 branches and 2 members at h = 5]
| | |--leaf 3 (h= 4 count = c("0", "3"), edgetext = 0 )
| | `--leaf 4 (h= 4 count = c("4", "0"), edgetext = 1 )
| `--[dendrogram w/ 1 branches and 3 members at h = 5]
| `--[dendrogram w/ 2 branches and 3 members at h = 4]
| |--[dendrogram w/ 1 branches and 1 members at h = 3]
| | `--[dendrogram w/ 1 branches and 1 members at h = 2]
| | `--[dendrogram w/ 1 branches and 1 members at h = 1]
| | `--leaf 2 ( count = c("0", "2"), edgetext = 0 )
| `--[dendrogram w/ 1 branches and 2 members at h = 3]
| `--[dendrogram w/ 2 branches and 2 members at h = 2]
| |--leaf 2 (h= 1 count = c("0", "2"), edgetext = 0 )
| `--leaf 4 (h= 1 count = c("2", "2"), edgetext = 1 )
`--leaf 10 (h= 6 count = c("10", " 0"), edgetext = 1 )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.