HistogramTools package usage in R - r

I am generating two histograms based on the script below, they are not equal on the x axis and as I wish to compare them I can not do so. Therefore, what can I do to run the script properly, any ideas how to approach this issue?
Thanks
x<-c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 3,
2, 6, 5, 13, 12, 15, 27, 34, 37, 58, 85, 90, 111, 131, 161, 164,
191, 211, 267, 293, 288, 320, 364, 370, 379, 413, 429, 473, 546,
539, 551, 593, 614, 594, 644, 617, 599, 605, 531, 591, 524, 482,
470, 437, 446, 428, 384, 368, 331, 332, 320, 317, 295, 266, 286,
284, 342, 360, 394, 480, 502, 600, 547, 610, 524, 545, 497, 414,
381, 345, 351, 371, 326, 336, 341, 336, 324, 346, 360, 386, 368,
396, 428, 432, 434, 438, 513, 498, 452, 452, 403, 397, 407, 405,
460, 515, 541, 608, 522, 542, 514, 517, 551, 661, 669, 739, 805,
847, 921, 1031, 965, 973, 1030, 1043, 815, 818, 648, 520, 433,
338, 295, 162, 106, 70, 44, 15, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
y<-c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0,
1, 1, 6, 4, 11, 4, 9, 15, 12, 34, 40, 49, 75, 65, 107, 132, 136,
157, 178, 189, 217, 278, 276, 296, 323, 435, 464, 473, 581, 613,
705, 820, 925, 1025, 1061, 1080, 1176, 1236, 1166, 1075, 1027,
976, 935, 807, 697, 658, 593, 440, 408, 347, 312, 296, 242, 284,
260, 243, 254, 283, 291, 371, 444, 470, 607, 719, 676, 722, 644,
678, 650, 662, 666, 607, 621, 558, 623, 634, 634, 699, 756, 771,
790, 852, 893, 1011, 1048, 1010, 966, 936, 860, 791, 681, 686,
752, 850, 952, 1049, 1094, 1134, 1156, 1198, 1351, 1342, 1533,
1461, 1271, 1065, 865, 739, 534, 459, 359, 275, 169, 124, 108,
80, 74, 64, 69, 61, 59, 56, 60, 76, 113, 102, 132, 101, 79, 92,
55, 41, 26, 17, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0)
h1 <- hist(x)
h2 <- hist(y)
require(HistogramTools)
minkowski.dist(h1, h2, 1)
minkowski.dist(h1, h2, 2)
minkowski.dist(h1, h2, 3)
intersect.dist(h1, h2)
kl.divergence(h1, h2)
jeffrey.divergence(h1, h2)

Both vectors (x and y) have 256 observations. Are these observations paired, i.e., for each x there is a corresponding y, and they have the same unit of measurement?
If yes, you can subtract one vector from the other and just plot the histogram of their differences to compare each other. Something like below:
length(x) #check number os observations in x
length(y) #check number os observations in y
diff = x-y #difference between x and y
hist(diff, xlab="x-y", main="Difference of vectors x and y")
If the x and y cannot be paired, but they have the same unit of measument there is the option provided by Hav0k.
Set the axis on both histograms with the same length and breaks to visually compare each other.
par(mfrow=c(1,2)) #stacks hisotgrams in one row and two columns
hist(x, xlim=c(0,1600), ylim=c(0,200), breaks=seq(0,1600,100),main="")
hist(y, xlim=c(0,1600), ylim=c(0,200), breaks=seq(0,1600,100),main="")
It is also possible to calculate the dissimilarity metrics with these:
h1 = hist(x, xlim=c(0,1600), ylim=c(0,200), breaks=seq(0,1600,100),main="")
h2 = hist(y, xlim=c(0,1600), ylim=c(0,200), breaks=seq(0,1600,100),main="")
minkowski.dist(h1, h2, 1) #116
minkowski.dist(h1, h2, 2) #38.88
minkowski.dist(h1, h2, 3) #29.81
intersect.dist(h1, h2) #0.22
If x and y have different units of measurements there is the option of standardizing the data before computing the dissimilarities.
x_standardized = (x-mean(x))/(sd(x))
y_standardized = (y-mean(y))/(sd(y))
h1=hist(x_standardized)
h2=hist(y_standardized)
minkowski.dist(h1, h2, 1) #58
minkowski.dist(h1, h2, 2)#26.57
minkowski.dist(h1, h2, 3) #22.1
intersect.dist(h1, h2) # 0.11
kl.divergence(h1, h2) # 0.07
jeffrey.divergence(h1, h2) #0.03

Related

How to Bind Two Data Fames with Multiple Columns based on the Column Name in R

I am trying to bind two data frames which has more than 600 column and each of those 600 columns are unique names.
I want to add the two data frame one below the other based on the column names, I can do it when there are a few columns but I am not sure how to about with it with more than 600 columns as writing the 600 columns names for merge is quite difficult. Can someone help me out?
Attached is the simplified data of both data frame.
This is one of the data frame called pd:
structure(list(ds = c("2019-01-01", "2019-02-01", "2019-03-01",
"2019-04-01", "2019-05-01", "2019-06-01", "2019-07-01", "2019-08-01",
"2019-09-01", "2019-10-01", "2019-11-01", "2019-12-01", "2020-01-01",
"2020-02-01", "2020-03-01", "2020-04-01", "2020-05-01", "2020-06-01",
"2020-07-01", "2020-08-01", "2020-09-01", "2020-10-01", "2020-11-01",
"2020-12-01", "2021-01-01", "2021-02-01", "2021-03-01", "2021-04-01",
"2021-05-01", "2021-06-01", "2021-07-01", "2021-08-01", "2021-09-01",
"2021-10-01", "2021-11-01", "2021-12-01", "2022-01-01", "2022-02-01",
"2022-03-01", "2022-04-01", "2022-05-01", "2022-06-01", "2022-07-01",
"2022-08-01"), X1 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5,
85, 72, 111, 96, 50, 95, 48, 87, 75, 249, 173, 74, 86, 127, 209,
92, 137, 49, 84, 75, 73, 376, 196, 91, 107, 124, 177, 244, 275,
100, 176), X2 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 29, 243,
281, 262, 283, 0, 264, 104, 289, 41, 76), X3 = c(0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 157, 171, 377, 409, 375, 314, 253, 322,
130, 472, 115, 179)), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -44L))
This is the other data frame, pd1
structure(list(ds = structure(c(19236, 19266, 19297, 19327, 19358,
19389, 19417, 19448, 19478), class = "Date"), X1 = structure(c(103.045278486668,
103.045278486668, 103.045278486668, 103.045278486668, 103.045278486668,
103.045278486668, 103.045278486668, 103.045278486668, 103.045278486668
), tsp = c(2022.66666666667, 2023.33333333333, 12), class = "ts"),
X2 = structure(c(9.97152706820806, 9.97152706820806, 9.97152706820806,
9.97152706820806, 9.97152706820806, 9.97152706820806, 9.97152706820806,
9.97152706820806, 9.97152706820806), tsp = c(2022.66666666667,
2023.33333333333, 12), class = "ts"), X3 = structure(c(21.2001463509872,
21.2001463509872, 21.2001463509872, 21.2001463509872, 21.2001463509872,
21.2001463509872, 21.2001463509872, 21.2001463509872, 21.2001463509872
), tsp = c(2022.66666666667, 2023.33333333333, 12), class = "ts")), class = "data.frame", row.names = c(NA,
-9L))
If they have a similar structure, you can simply use rbind?
rbind(pd, pd1)
Courtesy of #jay.sf in the comments below: The rbind function will automatically combine the columns with corresponding names.

StatsPlots Boxplot decrease width of boxes

I have a boxplot in Julia, that I created using StatsPlots boxplot:
boxes = -0.002:0.0001:0.0012
boxed = [[sum([1 for tuple ∈ data if tuple.y > box-0.000125 && tuple.y ≤ box+0.000125]) for box ∈ boxes] for data in datas]
boxplot(repeat([box for box ∈ boxes], outer=size(boxed)[1]), [(boxed...)...]; outliers=false)
The current result looks like this:
which is obviously hideous. I need to reduce the width of the boxes to a ~20000th of what it currently is. I can achieve this by scaling the x axis accordingly:
boxplot(repeat([box*20000 for box ∈ boxes], outer=size(boxed)[1]), [(boxed...)...]; outliers=false)
but then the x-axis has wrong values.
The help of the boxplot command sadly doesn't specify such an option:
help?> boxplot
search: boxplot boxplot! groupedboxplot groupedboxplot!
boxplot(x, y)
boxplot!(x, y)
Make a box and whisker plot.
Keyword arguments
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
• notch: Bool. Notch the box plot? (false)
• range: Real. Values more than range*IQR below the first quartile or above the third quartile are shown as outliers (1.5)
• outliers: Bool. Show outliers? (true)
• whisker_width: Real or Symbol. Length of whiskers (:match)
Example
≡≡≡≡≡≡≡≡≡
julia> using StatsPlots
julia> boxplot(repeat([1,2,3],outer=100),randn(300))
and I've already tried reasonable options like boxwex, width or box_width, which all didn't help. The documentation sadly also is of no help at all.
How can I change the width of the boxes without changing the scale of the x axis?
If, for some reason, you're interested, here's the content of the boxed array:
[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 7, 26, 80, 170, 322, 486, 688, 817, 888, 849, 783, 732, 624, 500, 349, 232, 130, 49], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 28, 83, 181, 318, 491, 670, 761, 849, 843, 862, 799, 646, 481, 361, 225, 98, 50], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 8, 28, 80, 179, 322, 493, 660, 753, 803, 832, 823, 783, 657, 541, 367, 223, 121, 62], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 23, 84, 171, 312, 463, 640, 778, 834, 820, 763, 752, 655, 518, 374, 244, 133, 52], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 21, 70, 169, 342, 527, 725, 808, 861, 857, 799, 688, 622, 523, 369, 232, 115, 41], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 9, 28, 76, 150, 301, 492, 660, 760, 823, 862, 790, 749, 646, 525, 352, 223, 116, 54], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 6, 21, 64, 165, 290, 434, 585, 771, 852, 847, 785, 739, 630, 535, 354, 230, 114, 42], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 19, 76, 190, 337, 506, 680, 775, 851, 853, 816, 705, 588, 496, 388, 232, 127, 54]]
With that, the plot can be replicated as follows:
using StatsPlots
boxes = -0.002:0.0001:0.0012
boxed = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 7, 26, 80, 170, 322, 486, 688, 817, 888, 849, 783, 732, 624, 500, 349, 232, 130, 49], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 28, 83, 181, 318, 491, 670, 761, 849, 843, 862, 799, 646, 481, 361, 225, 98, 50], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 8, 28, 80, 179, 322, 493, 660, 753, 803, 832, 823, 783, 657, 541, 367, 223, 121, 62], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 23, 84, 171, 312, 463, 640, 778, 834, 820, 763, 752, 655, 518, 374, 244, 133, 52], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 21, 70, 169, 342, 527, 725, 808, 861, 857, 799, 688, 622, 523, 369, 232, 115, 41], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 9, 28, 76, 150, 301, 492, 660, 760, 823, 862, 790, 749, 646, 525, 352, 223, 116, 54], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 6, 21, 64, 165, 290, 434, 585, 771, 852, 847, 785, 739, 630, 535, 354, 230, 114, 42], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 19, 76, 190, 337, 506, 680, 775, 851, 853, 816, 705, 588, 496, 388, 232, 127, 54]]
boxplot(repeat([box for box ∈ boxes], outer=size(boxed)[1]), [(boxed...)...]; outliers=false)
You can change the xticks:
boxed = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 7, 26, 80, 170, 322, 486, 688, 817, 888, 849, 783, 732, 624, 500, 349, 232, 130, 49], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 28, 83, 181, 318, 491, 670, 761, 849, 843, 862, 799, 646, 481, 361, 225, 98, 50], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 8, 28, 80, 179, 322, 493, 660, 753, 803, 832, 823, 783, 657, 541, 367, 223, 121, 62], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 7, 23, 84, 171, 312, 463, 640, 778, 834, 820, 763, 752, 655, 518, 374, 244, 133, 52], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 21, 70, 169, 342, 527, 725, 808, 861, 857, 799, 688, 622, 523, 369, 232, 115, 41], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 9, 28, 76, 150, 301, 492, 660, 760, 823, 862, 790, 749, 646, 525, 352, 223, 116, 54], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 6, 21, 64, 165, 290, 434, 585, 771, 852, 847, 785, 739, 630, 535, 354, 230, 114, 42], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 19, 76, 190, 337, 506, 680, 775, 851, 853, 816, 705, 588, 496, 388, 232, 127, 54]]
boxes = -0.002:0.0001:0.0012
xx = repeat(boxes, outer = length(boxed))
yy = collect(Iterators.flatten(boxed))
using StatsPlots
xtick = collect(-0.002:0.0005:0.0012)
boxplot(xx * 20000, yy, xticks = (xtick * 20000, xtick))
Update: you can change bar_width
boxplot(xx, yy, bar_width = 0.0001)

cross product calcuation by store level in r

I have the following data (Which is a slight adaptation of an earlier question):
The dimensions are: [1] 131 46
I am trying to create a list of chain by chain product sales.
# A tibble: 6 x 46
L5 ` Chain100` ` Chain103` ` Chain104` ` Chain106` ` Chain109` ` Chain15 ` ` Chain17 ` ` Chain19 ` ` Chain20 `
<fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 ABBE~ 0 0 0 0 0 0 0 0 0
2 ANHE~ 0 0 0 0 0 0 0 0 0
3 ANHE~ 0 0 0 0 0 0 0 0 0
4 B E 0 0 0 0 0 0 0 0 0
5 BACA~ 124 339 16 32 0 0 0 0 0
6 BACA~ 0 0 0 0 0 0 0 0 0
# ... with 36 more variables: ` Chain23 ` <dbl>, ` Chain25 ` <dbl>, ` Chain42 ` <dbl>, ` Chain43 ` <dbl>, ` Chain44
# ` <dbl>, ` Chain47 ` <dbl>, ` Chain48 ` <dbl>, ` Chain49 ` <dbl>, ` Chain50 ` <dbl>, ` Chain52 ` <dbl>, `
# Chain54 ` <dbl>, ` Chain57 ` <dbl>, ` Chain60 ` <dbl>, ` Chain61 ` <dbl>, ` Chain62 ` <dbl>, ` Chain65 ` <dbl>,
# ` Chain66 ` <dbl>, ` Chain67 ` <dbl>, ` Chain68 ` <dbl>, ` Chain70 ` <dbl>, ` Chain71 ` <dbl>, ` Chain72
# ` <dbl>, ` Chain75 ` <dbl>, ` Chain8 ` <dbl>, ` Chain80 ` <dbl>, ` Chain82 ` <dbl>, ` Chain83 ` <dbl>, ` Chain84
# ` <dbl>, ` Chain87 ` <dbl>, ` Chain88 ` <dbl>, ` Chain89 ` <dbl>, ` Chain90 ` <dbl>, ` Chain91 ` <dbl>, `
# Chain93 ` <dbl>, ` Chain96 ` <dbl>, ` Chain99 ` <dbl>
The data looks like the above. So I am interested in trying to create multiple lists for each product. That is chain100 and chain103 both sold BACARDI SILVER (along with a few other chains).
What I am trying to do is to make multiple lists which look like the following:
Chain1 Chain2 Chain3 Chain4
Chain1 -
BACARDI SILVER Chain2 234 -
Chain3 72 541 -
Chain4 0 231 0 -
So for each row or product there will be multiple lists (comparing the cross product purchases in each "chain").
Data:
structure(list(L5 = structure(1:131, .Label = c("ABBEY DE LEFFE BLONDE PALE AL",
"ANHEUSER WORLD LAGER", "ANHEUSER WORLD SELECT", "B E", "BACARDI SILVER",
"BACARDI SILVER LIMON", "BACARDI SILVER MOJITO", "BACARDI SILVER MOJITO PARTY P",
"BACARDI SILVER O3", "BACARDI SILVER RAZ", "BACARDI SILVER SAMPLER",
"BACARDI SILVER SIGNATURE", "BASS PALE ALE", "BEACH BUM BLONDE ALE",
"BECKS", "BECKS DARK", "BECKS OKTOBERFEST", "BECKS PREMIER LIGHT",
"BEST OF BELGIUM", "BODDINGTONS PUB CREAM ALE", "BREWMASTERS PRIVATE RESERVE",
"BUD ICE", "BUD ICE LIGHT", "BUD LIGHT", "BUD LIGHT CHELADA",
"BUD LIGHT GOLDEN WHEAT", "BUD LIGHT LIME", "BUD LIGHT LIME LIME A RITA",
"BUD LIGHT PARTY PACK", "BUD LIGHT PLATINUM LAGER", "BUDWEISER",
"BUDWEISER AMERICAN ALE", "BUDWEISER BREWMASTERS PROJECT", "BUDWEISER CHELADA",
"BUDWEISER DRY", "BUDWEISER HAPPY HOLIDAYS", "BUDWEISER ICE DRAFT",
"BUDWEISER MILLENNIUM", "BUDWEISER SELECT", "BUDWEISER SELECT 55",
"BUSCH", "BUSCH ICE", "BUSCH LIGHT", "BUSCH NA", "CZECHVAR",
"DOC OTIS HARD LEMON", "GOOSE ISLAND 312 URBAN WHEAT", "GOOSE ISLAND CHRISTMAS ALE",
"GOOSE ISLAND HONKERS ALE", "GOOSE ISLAND IPA", "GOOSE ISLAND SEASONAL",
"GROLSCH AMBER ALE", "GROLSCH LAGER", "GROLSCH LIGHT LAGER",
"GROLSCH SUMMER BLONDE", "HAAKE BECK NA", "HARBIN LAGER", "HOEGAARDEN WHITE ALE",
"HURRICANE HIGH GRAVITY", "HURRICANE HIGH GRAVITY LAGER", "HURRICANE MALT LIQUOR",
"JACKS PUMPKIN SPICE ALE", "KILLARNEYS RED LAGER", "KING COBRA",
"KIRIN ICHIBAN", "KIRIN ICHIBAN LAGER", "KIRIN LAGER", "KIRIN LIGHT",
"LANDSHARK LAGER", "LOWENBRAU", "MARGARITAVILLE", "MARGARITAVILLE 5 O CLOCK",
"MICHELOB", "MICHELOB AMBER BOCK", "MICHELOB BLACK AND TAN",
"MICHELOB DRY", "MICHELOB DUNKEL WEISSE", "MICHELOB GOLDEN DRAFT",
"MICHELOB GOLDEN DRAFT LIGHT", "MICHELOB HEFEWEIZEN", "MICHELOB HONEY LAGER",
"MICHELOB IRISH RED ALE", "MICHELOB LIGHT", "MICHELOB MARZEN",
"MICHELOB PALE ALE", "MICHELOB SEASONAL", "MICHELOB SPCLTY ALES & LGRS W",
"MICHELOB SPECIALTY ALES & LAG", "MICHELOB ULTR POMEGRANAT RSPB",
"MICHELOB ULTR TUSCN ORNG GRAP", "MICHELOB ULTRA", "MICHELOB ULTRA AMBER",
"MICHELOB ULTRA DRAGON FRUIT P", "MICHELOB ULTRA FRUIT SAMPLER",
"MICHELOB ULTRA LIGHT", "MICHELOB ULTRA LIME CACTUS", "NATTY DADDY LAGER",
"NATURAL ICE", "NATURAL LIGHT", "ODOULS", "ODOULS AMBER", "PEELS",
"RED WOLF", "REDBRIDGE", "ROCK GREEN LIGHT", "ROCK LIGHT", "ROLLING ROCK EXTRA PALE",
"ROLLING ROCK LIGHT", "SAINT PAULI GIRL", "SAINT PAULI GIRL DARK",
"SAINT PAULI N A", "SHADOWS WILD BLACK LAGER", "SHOCK TOP BELGIAN WHITE ALE",
"SHOCK TOP PUMPKIN WHEAT", "SHOCK TOP RASPBERRY WHEAT ALE", "SHOCK TOP SEASONAL",
"SHOCK TOP VARIETY PACK", "SHOCK TOP WHEAT IPA", "SPRING HEAT SPICED WHEAT",
"STELLA ARTOIS LAGER", "STONE MILL", "TAKE 6 HOME", "TEQUIZA",
"TIGER LAGER", "TILT", "TILT 8 PERCENT", "ULTRA 19TH HOLE", "WHITBREAD TRADITIONAL PALE AL",
"WILD BLUE", "WILD HOP", "WILD HOP ORGANIC LAGER"), class = "factor"),
` Chain100` = c(0, 0, 0, 0, 124, 0, 0, 0, 45, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 208, 154, 1053, 0, 0, 0, 0, 0, 0,
1046, 0, 0, 0, 0, 0, 0, 0, 0, 0, 661, 1, 585, 64, 0, 41,
0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0,
0, 0, 0, 0, 0, 0, 0, 180, 127, 27, 0, 0, 0, 0, 31, 63, 0,
361, 0, 0, 0, 9, 0, 0, 0, 241, 0, 0, 0, 0, 0, 0, 233, 508,
146, 45, 0, 0, 0, 0, 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, 0, 0), ` Chain103` = c(0,
0, 0, 0, 339, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 530, 284, 2309, 0, 0, 0, 0, 0, 0, 2252, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1464, 3, 1391, 171, 0, 157, 0, 0, 0, 0, 0, 3,
47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 85, 0, 0, 0, 0, 0, 0,
0, 0, 422, 249, 91, 0, 0, 1, 6, 43, 131, 0, 853, 0, 0, 0,
18, 0, 0, 0, 138, 0, 0, 0, 0, 0, 0, 401, 1188, 375, 113,
0, 0, 0, 0, 0, 587, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 158, 0, 0, 0, 0, 0, 0, 0, 0), ` Chain104` = c(0, 0,
0, 0, 16, 0, 0, 0, 33, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 91, 17, 336, 0, 0, 0, 0, 0, 0, 312, 0, 0, 0, 0, 0, 0,
0, 0, 0, 238, 5, 295, 38, 0, 3, 0, 0, 0, 0, 0, 0, 4, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 25,
14, 0, 0, 0, 0, 0, 3, 0, 104, 0, 0, 0, 0, 0, 0, 0, 99, 0,
0, 0, 0, 0, 0, 16, 154, 16, 0, 0, 0, 0, 0, 0, 49, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0), ` Chain106` = c(0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 633, 266, 2230, 0, 0, 0, 0,
0, 0, 2115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1540, 103, 1561, 190,
0, 194, 0, 0, 0, 0, 0, 7, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0,
77, 83, 0, 0, 0, 0, 0, 0, 0, 0, 528, 225, 112, 0, 0, 74,
168, 43, 113, 0, 865, 0, 0, 0, 5, 0, 0, 0, 20, 0, 0, 0, 0,
0, 0, 299, 1236, 373, 116, 0, 0, 0, 0, 0, 501, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 208, 0, 0, 0, 0, 0, 0, 0,
0), ` Chain109` = c(0, 0, 0, 0, 0, 0, 0, 0, 0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286, 105, 1430, 537,
0, 25, 0, 326, 0, 821, 1697, 471, 181, 0, 0, 77, 322, 70,
744, 0, 0, 0, 0, 0, 156, 0, 0, 0, 0, 0, 0, 482, 2, 0, 68,
0, 32, 45, 0, 0, 0, 0, 5), ` Chain43 ` = c(37, 0, 0, 0, 4,
0, 0, 0, 0, 24, 0, 101, 252, 0, 602, 225, 35, 107, 0, 210,
0, 1343, 0, 6191, 279, 244, 2003, 242, 0, 642, 5266, 64,
16, 20, 0, 0, 0, 0, 2755, 2284, 2598, 59, 2992, 566, 30,
0, 205, 6, 36, 96, 39, 0, 0, 0, 0, 31, 0, 327, 18, 43, 0,
0, 0, 188, 15, 6, 0, 14, 1061, 0, 30, 0, 121, 1175, 0, 0,
0, 0, 0, 0, 35, 0, 1069, 3, 0, 54, 21, 0, 424, 0, 2972, 535,
144, 9, 78, 457, 0, 2064, 3224, 845, 431, 0, 0, 455, 0, 29,
1180, 0, 261, 111, 36, 0, 539, 37, 390, 193, 15, 34, 0, 1400,
0, 103, 0, 0, 327, 14, 6, 0, 219, 0, 0), ` Chain44 ` = c(45,
0, 0, 0, 27, 0, 62, 6, 0, 104, 0, 113, 167, 0, 359, 209,
15, 62, 0, 139, 0, 694, 59, 3604, 207, 495, 1092, 0, 24,
0, 3085, 273, 0, 46, 0, 0, 0, 0, 1609, 969, 1377, 81, 1580,
337, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 166, 0, 52,
0, 0, 0, 98, 35, 0, 0, 11, 618, 1, 0, 0, 174, 566, 0, 0,
29, 0, 0, 0, 55, 0, 820, 29, 3, 120, 55, 0, 285, 65, 1430,
371, 138, 0, 0, 284, 0, 909, 1683, 455, 177, 0, 0, 177, 2,
120, 722, 0, 0, 0, 0, 0, 209, 0, 0, 0, 0, 0, 0, 503, 0, 0,
0, 0, 9, 62, 0, 0, 89, 0, 0), ` Chain47 ` = c(48, 0, 0, 0,
117, 0, 314, 20, 0, 247, 0, 29, 261, 0, 477, 276, 8, 108,
0, 145, 0, 698, 219, 3641, 231, 167, 1108, 0, 0, 0, 3272,
368, 0, 89, 0, 0, 0, 0, 1647, 163, 1453, 79, 1662, 343, 23,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 1, 154, 0, 51, 0, 0, 0,
62, 36, 0, 0, 4, 613, 33, 0, 0, 239, 632, 0, 0, 100, 0, 0,
0, 126, 32, 921, 87, 69, 135, 185, 0, 298, 173, 1440, 496,
0, 65, 0, 320, 0, 843, 1715, 457, 185, 0, 0, 73, 2, 271,
737, 0, 0, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 455, 0, 0, 1,
0, 24, 77, 0, 0, 0, 0, 0), ` Chain48 ` = c(46, 38, 0, 71,
631, 0, 137, 0, 287, 476, 0, 0, 315, 44, 473, 280, 29, 180,
12, 137, 0, 1241, 838, 5938, 0, 0, 0, 0, 0, 0, 5550, 0, 0,
0, 47, 28, 0, 0, 3154, 0, 2664, 69, 2973, 602, 8, 0, 0, 0,
0, 0, 0, 0, 484, 15, 38, 45, 27, 133, 0, 0, 0, 54, 0, 105,
70, 0, 0, 19, 0, 141, 0, 0, 917, 1129, 0, 0, 0, 0, 0, 0,
102, 0, 1883, 22, 0, 0, 0, 63, 33, 25, 2355, 958, 0, 0, 0,
58, 0, 1243, 2922, 877, 349, 374, 0, 61, 401, 0, 1251, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 333, 102, 0, 163, 39, 158,
11, 0, 0, 0, 96, 0), ` Chain49 ` = c(4, 30, 37, 67, 721,
0, 29, 0, 376, 452, 2, 0, 44, 8, 25, 39, 0, 0, 0, 13, 0,
853, 490, 3820, 0, 0, 0, 0, 0, 0, 3716, 0, 0, 0, 67, 11,
0, 0, 1632, 0, 1974, 0, 2066, 390, 0, 0, 0, 0, 0, 0, 0, 0,
252, 0, 8, 0, 0, 18, 0, 0, 0, 1, 0, 52, 5, 0, 0, 0, 0, 0,
0, 0, 710, 792, 0, 0, 0, 0, 0, 0, 95, 0, 1363, 0, 0, 0, 0,
22, 0, 0, 1717, 95, 0, 0, 0, 0, 0, 874, 1979, 606, 180, 143,
0, 6, 41, 0, 833, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 46,
13, 0, 90, 0, 17, 0, 0, 0, 0, 19, 0), ` Chain50 ` = c(0,
0, 126, 0, 357, 133, 0, 0, 453, 415, 25, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 732, 523, 2985, 0, 0, 0, 0, 0, 0, 2927, 0, 0,
0, 83, 0, 1, 0, 0, 0, 1722, 0, 1767, 413, 0, 14, 0, 0, 0,
0, 0, 0, 188, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 28, 0, 3,
0, 0, 0, 0, 0, 687, 629, 6, 0, 0, 0, 0, 8, 139, 0, 1106,
0, 0, 0, 0, 15, 0, 0, 1387, 0, 0, 0, 0, 0, 0, 706, 1660,
475, 221, 0, 0, 0, 0, 0, 667, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 182, 0, 0, 0, 0, 0, 0, 0, 0), ` Chain52 ` = c(0,
0, 0, 0, 450, 0, 0, 0, 440, 122, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 699, 518, 2710, 0, 0, 0, 0, 0, 0, 2670, 0, 0, 0,
67, 0, 0, 0, 0, 0, 1650, 8, 1686, 417, 0, 186, 0, 0, 0, 0,
0, 0, 155, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 14, 0, 21, 0,
0, 0, 0, 0, 726, 572, 194, 0, 0, 0, 0, 99, 199, 0, 1032,
0, 0, 0, 17, 24, 0, 0, 932, 0, 0, 0, 0, 0, 0, 729, 1550,
459, 215, 0, 6, 0, 0, 0, 685, 4, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 244, 0, 0, 0, 0, 0, 0, 0, 0), ` Chain54 ` = c(0,
0, 0, 0, 418, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 672, 484, 2349, 0, 0, 0, 0, 0, 0, 2232, 0, 0, 0, 72, 0,
0, 0, 0, 0, 1411, 38, 1381, 399, 0, 241, 0, 0, 0, 0, 0, 15,
151, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 52, 3, 0, 27, 0, 0, 0,
0, 0, 648, 405, 172, 1, 0, 7, 27, 139, 194, 0, 966, 0, 0,
0, 42, 0, 0, 0, 177, 0, 0, 0, 0, 0, 0, 639, 1293, 432, 264,
0, 52, 0, 0, 0, 633, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 307, 0, 0, 0, 0, 0, 0, 0, 0), ` Chain57 ` = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 552, 346, 1586, 0, 0, 0, 0, 0, 0, 1627, 0, 0, 0, 74, 0,
0, 1, 0, 0, 1037, 37, 1060, 311, 0, 191, 0, 0, 0, 0, 0, 29,
168, 0, 0, 0, 0, 0, 0, 0, 13, 0, 116, 49, 0, 0, 37, 0, 0,
0, 0, 0, 482, 310, 111, 0, 0, 75, 304, 96, 151, 0, 685, 0,
0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 424, 899, 296, 199,
0, 50, 0, 0, 0, 457, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 258, 0, 0, 0, 0, 0, 0, 0, 0), ` Chain60 ` = c(21,
0, 0, 0, 9, 0, 359, 7, 0, 169, 13, 0, 236, 0, 327, 205, 8,
75, 0, 86, 0, 296, 70, 1707, 71, 0, 333, 0, 0, 0, 1649, 61,
0, 55, 0, 0, 0, 0, 954, 0, 700, 0, 873, 239, 12, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 89, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 389, 0, 0, 0, 184, 468, 0, 0, 26, 0, 0, 0, 0, 0, 549,
26, 14, 64, 28, 1, 120, 0, 1066, 420, 0, 0, 0, 121, 0, 319,
662, 419, 41, 1, 0, 41, 147, 51, 483, 0, 0, 0, 0, 0, 94,
0, 0, 0, 0, 0, 0, 247, 42, 0, 0, 0, 49, 0, 0, 0, 116, 0,
11), ` Chain61 ` = c(0, 0, 0, 0, 0, 0, 88, 0, 0, 0, 0, 22,
135, 0, 262, 98, 0, 58, 0, 113, 0, 426, 3, 1695, 0, 79, 641,
50, 0, 152, 1564, 47, 0, 0, 0, 0, 0, 0, 858, 794, 796, 0,
911, 203, 0, 0, 66, 0, 31, 48, 23, 0, 0, 0, 0, 0, 0, 106,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 354, 0, 49, 11, 125, 347, 0,
0, 0, 0, 0, 0, 0, 0, 456, 0, 0, 5, 6, 0, 192, 0, 909, 286,
0, 0, 51, 185, 0, 460, 672, 378, 178, 0, 0, 139, 0, 23, 264,
7, 92, 31, 0, 23, 198, 0, 138, 48, 13, 0, 0, 395, 0, 0, 0,
0, 0, 0, 0, 0, 89, 0, 0), ` Chain62 ` = c(41, 0, 0, 0, 35,
0, 176, 7, 0, 23, 0, 35, 167, 0, 232, 143, 0, 92, 0, 85,
0, 254, 21, 1464, 25, 245, 596, 0, 25, 0, 1348, 196, 0, 23,
0, 0, 0, 0, 788, 537, 608, 0, 703, 212, 11, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 101, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 358,
0, 0, 0, 141, 362, 0, 0, 7, 0, 0, 0, 0, 0, 392, 23, 6, 45,
40, 0, 183, 0, 822, 279, 0, 0, 0, 179, 0, 282, 562, 353,
101, 0, 0, 46, 0, 72, 367, 0, 0, 0, 0, 0, 181, 0, 0, 0, 0,
0, 0, 264, 8, 0, 0, 0, 5, 0, 0, 0, 170, 0, 0), ` Chain65 ` = c(58,
0, 0, 3, 7, 0, 382, 20, 18, 258, 0, 0, 530, 0, 691, 473,
0, 138, 0, 184, 0, 984, 280, 5247, 60, 58, 682, 0, 0, 0,
5073, 307, 0, 63, 0, 6, 0, 0, 2635, 95, 2176, 1, 2711, 734,
23, 0, 0, 0, 0, 0, 0, 0, 381, 0, 0, 0, 0, 164, 0, 0, 0, 5,
0, 0, 0, 0, 0, 0, 453, 0, 0, 0, 588, 1419, 0, 0, 40, 0, 0,
0, 27, 0, 1623, 70, 35, 75, 109, 58, 230, 0, 2989, 1200,
0, 0, 0, 229, 0, 1028, 2053, 1278, 130, 546, 0, 96, 180,
124, 1404, 0, 0, 0, 0, 0, 207, 0, 0, 0, 0, 0, 0, 520, 64,
0, 0, 0, 90, 0, 0, 0, 213, 28, 0), ` Chain66 ` = c(0, 0,
0, 48, 193, 0, 43, 1, 121, 290, 9, 13, 5, 0, 4, 9, 0, 0,
0, 0, 5, 647, 258, 2806, 54, 8, 188, 0, 0, 0, 2638, 20, 0,
0, 1, 1, 0, 0, 691, 61, 1478, 42, 1653, 322, 0, 0, 0, 0,
0, 0, 0, 0, 242, 0, 0, 0, 0, 0, 0, 83, 0, 0, 0, 10, 0, 0,
0, 2, 113, 0, 26, 0, 427, 573, 0, 0, 0, 0, 0, 0, 87, 0, 767,
0, 0, 4, 0, 27, 49, 0, 1236, 31, 18, 4, 0, 63, 0, 560, 1041,
470, 48, 0, 0, 0, 13, 0, 564, 0, 0, 0, 0, 0, 12, 12, 14,
0, 0, 0, 0, 29, 0, 0, 0, 0, 2, 45, 0, 13, 13, 0, 0), ` Chain67 ` = c(0,
0, 0, 0, 180, 0, 0, 0, 336, 224, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 617, 308, 2310, 0, 0, 100, 44, 0, 80, 2135, 0, 0,
0, 1, 0, 0, 0, 64, 48, 1227, 23, 1354, 261, 0, 8, 2, 3, 1,
1, 0, 0, 221, 0, 0, 1, 0, 0, 49, 0, 0, 0, 0, 0, 0, 0, 0,
0, 33, 0, 8, 0, 514, 512, 6, 0, 0, 5, 0, 0, 62, 0, 753, 0,
0, 0, 0, 4, 21, 0, 1091, 0, 4, 0, 14, 25, 0, 433, 921, 458,
46, 0, 0, 0, 0, 0, 509, 0, 0, 0, 0, 0, 9, 0, 1, 31, 7, 0,
0, 18, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0), ` Chain68 ` = c(0,
0, 0, 0, 25, 0, 18, 7, 3, 27, 0, 22, 0, 0, 0, 0, 0, 0, 0,
0, 0, 68, 10, 470, 33, 23, 132, 0, 2, 0, 387, 19, 0, 0, 0,
0, 0, 0, 65, 64, 282, 18, 298, 75, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 35, 0, 0,
0, 0, 33, 0, 0, 2, 0, 0, 0, 0, 0, 58, 5, 0, 18, 0, 0, 21,
1, 173, 0, 16, 0, 0, 35, 0, 58, 126, 24, 0, 0, 0, 0, 0, 3,
52, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 2,
34, 0, 0, 0, 0, 0), ` Chain70 ` = c(0, 0, 0, 0, 356, 0, 0,
0, 303, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 422, 319, 1508,
0, 0, 0, 0, 0, 0, 1429, 0, 0, 0, 1, 0, 0, 0, 0, 0, 884, 0,
943, 192, 0, 123, 0, 0, 0, 0, 0, 0, 126, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 548, 387, 122, 0,
0, 0, 0, 0, 103, 0, 673, 0, 0, 0, 3, 0, 0, 0, 551, 0, 0,
0, 0, 0, 0, 251, 716, 393, 123, 0, 0, 0, 0, 0, 390, 35, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191, 0, 0, 0, 0, 0,
0, 0, 0), ` Chain71 ` = c(0, 0, 0, 0, 54, 0, 20, 2, 14, 26,
0, 6, 0, 0, 0, 0, 3, 5, 0, 0, 0, 80, 26, 474, 30, 9, 111,
0, 0, 0, 377, 39, 0, 0, 0, 0, 0, 0, 64, 10, 277, 27, 285,
56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0,
0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 2, 5, 0, 0, 15, 0, 0, 0, 0,
11, 54, 13, 3, 20, 0, 4, 17, 9, 155, 2, 0, 10, 0, 32, 0,
80, 127, 26, 0, 0, 0, 0, 0, 12, 49, 0, 0, 0, 0, 0, 3, 0,
0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 12, 35, 0, 0, 1, 0, 0), ` Chain72 ` = c(0,
0, 0, 0, 244, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 315, 243, 1039, 0, 0, 0, 0, 0, 0, 1020, 0, 0, 0, 0, 0,
0, 0, 0, 0, 688, 0, 781, 155, 0, 135, 0, 0, 0, 0, 0, 0, 81,
0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0,
429, 257, 93, 0, 0, 14, 13, 0, 84, 0, 491, 0, 0, 0, 16, 0,
0, 0, 72, 0, 0, 0, 0, 0, 0, 169, 659, 297, 136, 0, 0, 0,
0, 0, 247, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 196,
0, 0, 0, 0, 0, 0, 0, 0), ` Chain75 ` = c(0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 332, 230, 818,
0, 0, 0, 0, 0, 0, 805, 0, 0, 0, 0, 0, 0, 0, 0, 0, 731, 0,
708, 152, 0, 173, 0, 0, 0, 0, 0, 0, 114, 0, 0, 0, 0, 0, 0,
0, 0, 0, 71, 0, 0, 0, 0, 0, 0, 0, 0, 0, 423, 241, 123, 0,
0, 92, 139, 0, 121, 0, 467, 0, 0, 0, 19, 0, 0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0, 4, 0, 0, 0, 0, 0, 0,
15, 0, 0, 0, 0, 0, 0, 41, 5, 0, 3, 84, 2, 0, 0, 0, 0, 0,
0, 0, 68, 59, 0, 0, 0, 0, 0, 0, 0, 0, 171, 0, 0, 0, 0, 3,
0, 13, 132, 40, 0, 0, 0, 7, 0, 108, 214, 17, 0, 1, 0, 3,
29, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 1, 0, 0,
0, 0, 34, 0, 0, 0, 1, 0)), row.names = c(NA, -131L), class = c("tbl_df",
"tbl", "data.frame"))

auto.arima forecast with multivariate xreg - unexpected results

In my spare time I try to sharpen my skills a bit on forecasting techniques and today's issue focused on forecasting with multiple regressors. I have created a time series that is influenced by two regressors, but wondering how forecast with them.
library(forecast)
I tried the following:
First my time series:
ts.series3 <- structure(c(313, 253, 230, 258, 261, 303, 266, 269, 245, 274,
346, 252, 283, 286, 260, 365, 295, 268, 301, 304, 353, 310, 313,
285, 319, 403, 294, 330, 333, 303, 425, 343, 312, 350, 354, 411,
361, 366, 333, 469, 380, 346, 487, 394, 359, 404, 511, 372, 418
), .Tsp = c(2003.08333333333, 2007.08333333333, 12), class = "ts")
The time series above is based on the trend show in ts.trend (below) and is modified by the modifiers. In case the first modifiers is relevant the value is increased by 25%, and in case of the second then the value is decreased with 10%. When both are applicable then they are increased by 15%.
ts.trend <- structure(c(250, 253, 255, 258, 261, 264, 266, 269, 272, 274,
277, 280, 283, 286, 289, 292, 295, 298, 301, 304, 307, 310, 313,
316, 319, 323, 326, 330, 333, 337, 340, 343, 347, 350, 354, 357,
361, 366, 370, 375, 380, 385, 390, 394, 399, 404, 409, 414, 418
), .Tsp = c(2003.08333333333, 2007.08333333333, 12), class = "ts")
A multivariate time series with the two regressors:
modifiers <- structure(c(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0,
0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0,
1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0,
1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), .Dim = c(60L,
2L), .Dimnames = list(NULL, c("Adjust1", "Adjust2")), .Tsp = c(2003.08333333333,
2008, 12), class = c("mts", "ts"))
Then I try to make the following model:
fit.series3 <- auto.arima(ts.series3,xreg=window(modifiers,end=2007.16))
fcast.series3 <- forecast(fit.series3,xreg=window(modifiers,start=2007.161))
The code seems to be working fine, but the plot (see below) doesn't really make sense as there are no regressors identified you would expect that the forecast would more or less follow the trend line. Is there somebody who can provide some insights into what is happening here?
plot(fcast.series3)
The forecast plot looks as following when I am not using any regressor variables. I am more confident about this forecast than about the one in the plot above. I used the following lines of code to produce the chart:
fit.series3clean <- auto.arima(ts.series3)
fcast.series3clean <- forecast(fit.series3clean)
plot(fcast.series3clean)
I am wondering whether somebody understand what is happening with my forecast with multivariate xreg values. Also, I am curious to hear about other approaches to forecasting with multivariate regressors.
Take a look at your fitted model:
> fit.series3
Series: ts.series3
ARIMA(0,1,1)(0,1,0)[12]
Coefficients:
ma1 Adjust1 Adjust2
-0.7586 80.1919 285.6239
s.e. 0.0832 0.0842 NaN
sigma^2 estimated as 71.55: log likelihood=-128.38
AIC=264.76 AICc=266.05 BIC=271.09
Warning message:
In sqrt(diag(x$var.coef)) : NaNs produced
There is a problem with the coefficient of Adjust2 as the standard error is NaN.
The following code shows the problem:
> window(diff(diff(modifiers[,2],12)),end=2007.16)
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2004 0 0 0 0 0 0 0 0 0 0
2005 0 0 0 0 0 0 0 0 0 0 0 0
2006 0 0 0 0 0 0 0 0 0 0 0 0
2007 0 0
During the fitting period the twice differenced Adjust2 is always zero making the coefficient essentially undefined (and with infinite variance).

image function in R

I'm trying to do something a little bit complicated for a beginner in programming.
I have a matrix 16x16 and I want to plot the values as a heatmap using image() in R.
How can I plot the "0" (zeros) in blue when the sum (row index + column index) is <= 15? Is that possible?
example matrix:
x <- c(3045, 893, 692, 830, 617, 155, 246, 657, 105, 60, 18, 7, 7, 4, 2, 11234,
2985, 2242, 2471, 1575, 366, 503, 1283, 170, 79, 32, 6, 4, 1, 3, 19475, 4756,
3233, 3251, 1810, 409, 575, 1210, 139, 41, 11, 4, 2, 0, 0, 20830, 4739, 2990,
2531, 1346, 298, 325, 612, 60, 17, 1, 0, 1, 0, 0, 15304, 3196, 1885, 1440, 610,
117, 115, 185, 14, 2, 0, 0, 0, 0, 0, 8026, 1535, 806, 539, 223, 33, 37, 39, 0,
0, 0, 0, 0, 0, 0, 3300, 562, 286, 141, 45, 14, 5, 12, 0, 0, 0, 0, 0, 0, 0, 1067,
160, 65, 40, 14, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 277, 47, 6, 2, 1, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 72, 6, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 5, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
xmat <- matrix(x, ncol = 12)
xmat <- cbind(xmat, rep(0,16), rep(0,16), rep(0,16), rep(0,16))
xmat <- rbind(xmat, rep(0,16))
dimnames(xmat) = list(0:15, 0:15)
xmat
Thanks!
Vitor
Plot the cases meeting the criteria as blue.
xmat.new <- xmat
xmat.new[!((row(xmat) + col(xmat) <= 15) & xmat==0)] <- NA
image(xmat.new,col="blue")
Plot the cases not meeting the criteria as normal. Notice the add=TRUE
xmat.new <- xmat
xmat.new[((row(xmat) + col(xmat) <= 15) & xmat==0)] <- NA
image(xmat.new,add=TRUE)
Result:
Edited to include #Marek's suggestion to simplify the statements.

Resources