moffset(mat, roffset = 0, coffset = 0, postfix = "")
c(mat)
,
i.e., going down successive columns, as the columns go
from left to right. Wrapping of values is done.mat
.
If character, the offset is computed by matching with
the row or column names.
For example, for the
roffset
+ 1, coffset
+ 1)
becomes the (1, 1) element.
The elements are assumed to be ordered in the same way
as the elements of c(mat)
,
This function is applicable to, e.g.,
alcoff
,
where it is useful to define the effective day as starting
at some other hour than midnight, e.g., 6.00am.
This is because partying on Friday night continues on into Saturday morning,
therefore it is more interpretable to use the effective day when
considering a daily effect.
This is a data preprocessing function for rcim
and plotrcim0
. The differences between
Rcim
and moffset
is that
Rcim
only reorders the level of the rows and columns
so that the data is shifted but not moved.
That is, a value in one row stays in that row,
and ditto for column.
But in moffset
values in one column can be moved to a previous column.
See the examples below.
Rcim
,
rcim
,
plotrcim0
,
alcoff
,
crashi
.moffset(alcoff, 3, 2, "*") # Some day's data is moved to previous day.
Rcim(alcoff, 3 + 1, 2 + 1) # Data does not move as much.
alcoff # Original data
moffset(alcoff, 3, 2, "*") - Rcim(alcoff, 3+1, 2+1) # Note the differences
# An 'effective day' data set:
alcoff.e <- moffset(alcoff, roffset = "6", postfix = "*")
fit.o <- rcim(alcoff) # default baselines are first row and col
fit.e <- rcim(alcoff.e) # default baselines are first row and col
par(mfrow = c(2, 2), mar = c(9,4,2,1))
plot(fit.o, rsub = "Not very interpretable", csub = "Not very interpretable")
plot(fit.e, rsub = "More interpretable", csub = "More interpretable")
# Some checking
all.equal(moffset(alcoff), alcoff) # Should be no change
moffset(alcoff, 1, 1, "*")
moffset(alcoff, 2, 3, "*")
moffset(alcoff, 1, 0, "*")
moffset(alcoff, 0, 1, "*")
moffset(alcoff, "6", "Mon", "*") # This one is good
# Customise row and column baselines
fit2 <- rcim(Rcim(alcoff.e, rbaseline = "11", cbaseline = "Mon*"))
Run the code above in your browser using DataLab