hyper3
objects in the
hyper2
packagevignettes/hyper3_creation.Rmd
hyper3_creation.Rmd
To cite the hyper2
package in publications, please use
Hankin (2017). In this vignette I give
self-contained short examples of each function that creates or modifies
hyper3
objects.
hyper3() # default creation, returns a uniform support function
## log( )
## log( (a=1.2)^3 * (a=1.2, b=1)^-7 * (b=1)^4)
hyper3(B=list("a",c("a","b"),"b"),W=list(1.2,c(1.2,1),1),powers=c(3,4,-7)) # dispatches to hyper3_bw()
## log( (a=1.2)^3 * (a=1.2, b=1)^4 * (b=1)^-7)
## a b c
## [1,] 5 2 1
## [2,] 2 5 2
## [3,] 2 6 1
## [4,] 3 4 4
## [5,] 5 3 2
## log( (a=2, b=5, c=2)^3 * (a=2, b=6, c=1)^-1 * (a=3, b=4, c=4)^-5 *
## (a=5, b=2, c=1)^2 * (a=5, b=3, c=2)^1)
H <- hyper3()
H[c(p1=1.3)] <- 5 # terms not present are created
H[c(p2=1 )] <- 2
H[c(p1=1.3,p2=1)] <- -7
H
## log( (p1=1.3)^5 * (p1=1.3, p2=1)^-7 * (p2=1)^2)
H <- hyper3(list(c(a=1.2),c(b=1),c(a=1.2,b=1)),powers=c(3,4,-7))
H[c(a=1.2)] <- 100 # terms present may be modified...
H[c(a=1.2,x=1)] %<>% dec(97) # or incremented
H
## log( (a=1.2)^100 * (a=1.2, b=1)^-7 * (a=1.2, x=1)^-97 * (b=1)^4)
ordervec2supp3(c("a","a","b","c","a","b","c"))
## log( (a=1)^3 * (a=1, b=1, c=1)^-1 * (a=1, b=1, c=2)^-1 * (a=1, b=2,
## c=2)^-1 * (a=2, b=2, c=2)^-1 * (a=3, b=2, c=2)^-1 * (b=1)^2 * (b=1,
## c=1)^-1 * (c=1)^1)
ordervec2supp3(c("a","b"),nonfinishers=c("a","b")) # a > b >> {a,b}
## log( (a=1)^1 * (a=1, b=2)^-1 * (a=2, b=2)^-1 * (b=1)^1)
(jj <- data.frame(throw1=c(a=8,b=2,c=1),throw2=c(5,"X",3)))
## throw1 throw2
## a 8 5
## b 2 X
## c 1 3
## log( (a=1)^2 * (a=1, b=2, c=2)^-1 * (a=2, b=2, c=2)^-1 * (b=1)^1 *
## (b=1, c=1)^-1 * (b=2, c=1)^-1 * (b=2, c=2)^-1 * (c=1)^2)
dirichlet3(c(x=6,y=2,z=2),lambda=1.8)
## log( (x=1.8)^6 * (x=1.8, y=1, z=1)^-10 * (y=1)^2 * (z=1)^2)
(H <- rankvec_likelihood(letters[1:5]))
## log( a * (a + b + c + d + e)^-1 * b * (b + c + d + e)^-1 * c * (c + d +
## e)^-1 * d * (d + e)^-1)
H["b"] <- as.weight(1.88)
H
## log( (a=1)^1 * (a=1, b=1.88, c=1, d=1, e=1)^-1 * (b=1.88)^1 * (b=1.88,
## c=1, d=1, e=1)^-1 * (c=1)^1 * (c=1, d=1, e=1)^-1 * (d=1)^1 * (d=1,
## e=1)^-1)
setweight(H,"c",1000)
## log( (a=1)^1 * (a=1, b=1.88, c=1000, d=1, e=1)^-1 * (b=1.88)^1 *
## (b=1.88, c=1000, d=1, e=1)^-1 * (c=1000)^1 * (c=1000, d=1, e=1)^-1 *
## (d=1)^1 * (d=1, e=1)^-1)
(o <- constructor_2020_table[1:6,1:4])
## Constructor AUT STY HUN
## 1 Merc 1 1 1
## 2 Merc 4 2 3
## 3 RBRH 13 3 2
## 4 RBRH Ret 4 5
## 5 MR 3 5 9
## 6 MR 5 9 13
## log( (MR=1)^3 * (MR=1, Merc=1, RBRH=2)^-1 * (MR=1, RBRH=2)^-1 *
## (MR=2)^-1 * (MR=2, Merc=1, RBRH=2)^-2 * (MR=2, Merc=2, RBRH=2)^-2 *
## (MR=2, RBRH=1)^-1 * (MR=2, RBRH=2)^-1 * (Merc=1)^4 * (RBRH=1)^3 *
## (RBRH=2)^-1)
M <- matrix(c(NA,9+2i,7+2i,6+5i,NA,2+4i,2+2i,9+3i,NA),3,3)
teams <- letters[1:3]
dimnames(M) <- list("@home" = teams,"@away"=teams)
M
## @away
## @home a b c
## a NA 6+5i 2+2i
## b 9+2i NA 9+3i
## c 7+2i 2+4i NA
home_away3(M,lambda=1.88)
## log( (a=1)^4 * (a=1, b=1.88)^-11 * (a=1, c=1.88)^-9 * (a=1.88)^8 *
## (a=1.88, b=1)^-11 * (a=1.88, c=1)^-4 * (b=1)^9 * (b=1, c=1.88)^-6 *
## (b=1.88)^18 * (b=1.88, c=1)^-12 * (c=1)^5 * (c=1.88)^9)
## log( (a=1.2)^3 * (a=1.2, b=1)^-7 * (b=1)^4)
## log( (a=1.2)^9 * (a=1.2, b=1)^-21 * (b=1)^12)