Rearrange the rows and columns of the input so that the first row and first column are baseline. This function is for rank-zero row-column interaction models (RCIMs; i.e., general main effects models).

Rcim(mat, rbaseline = 1, cbaseline = 1)

Arguments

mat

Matrix, of dimension \(r\) by \(c\). It is best that it is labelled with row and column names.

rbaseline, cbaseline

Numeric (row number of the matrix mat) or character (matching a row name of mat) that the user wants as the row baseline or reference level. Similarly cbaseline for the column.

Details

This is a data preprocessing function for rcim. For rank-zero row-column interaction models this function establishes the baseline (or reference) levels of the matrix response with respect to the row and columns—these become the new first row and column.

Value

Matrix of the same dimension as the input, with rbaseline and cbaseline specifying the first rows and columns. The default is no change in mat.

Author

Alfian F. Hadi and T. W. Yee.

Note

This function is similar to moffset; see moffset for information about the differences. If numeric, the arguments rbaseline and cbaseline differ from arguments roffset and coffset in moffset by 1 (when elements of the matrix agree).

See also

Examples

(alcoff.e <- moffset(alcoff, roffset = "6", postfix = "*"))
#>    Mon* Tue* Wed* Thu* Fri* Sat* Sun*
#> 6    13    9    9   55   70  155  213
#> 7    20    6    9   42   40  160  200
#> 8     5    8   12   29   40   79   96
#> 9     7    8   14   28   38   44   58
#> 10    7   13   20   36   38   52   69
#> 11    8   10   20   32   27   44   39
#> 12   10   13    8   39   37   73   59
#> 13    9   26   32   37   27   41   45
#> 14   22   41   31   46   42   58   53
#> 15   39   48   62   69   59   75   70
#> 16   28   48   71   85   55   96   95
#> 17   46   59   98  141  136  154  130
#> 18   53  100  117  185  223  236  121
#> 19   74  119  155  289  335  337  146
#> 20   74  135  283  508  591  490  166
#> 21   84  154  326  610  866  754  131
#> 22   90  143  345  765  976 1026  114
#> 23  110  169  363  899 1265 1179  159
#> 0*   98  165  324  827 1379 1332  121
#> 1*   92  157  278  619 1327 1356   97
#> 2*   69  107  229  410  979 1011   60
#> 3*   60   75  238  401  693  718   55
#> 4*   38   48  145  223  346  410   25
#> 5*   10   20   56  139  188  287   19
(aa <- Rcim(alcoff,    rbaseline = "11", cbaseline = "Sun"))
#>     Sun Mon Tue Wed Thu  Fri  Sat
#> 11   39   8  10  20  32   27   44
#> 12   59  10  13   8  39   37   73
#> 13   45   9  26  32  37   27   41
#> 14   53  22  41  31  46   42   58
#> 15   70  39  48  62  69   59   75
#> 16   95  28  48  71  85   55   96
#> 17  130  46  59  98 141  136  154
#> 18  121  53 100 117 185  223  236
#> 19  146  74 119 155 289  335  337
#> 20  166  74 135 283 508  591  490
#> 21  131  84 154 326 610  866  754
#> 22  114  90 143 345 765  976 1026
#> 23  159 110 169 363 899 1265 1179
#> 0  1332 121  98 165 324  827 1379
#> 1  1356  97  92 157 278  619 1327
#> 2  1011  60  69 107 229  410  979
#> 3   718  55  60  75 238  401  693
#> 4   410  25  38  48 145  223  346
#> 5   287  19  10  20  56  139  188
#> 6   213  13   9   9  55   70  155
#> 7   200  20   6   9  42   40  160
#> 8    96   5   8  12  29   40   79
#> 9    58   7   8  14  28   38   44
#> 10   69   7  13  20  36   38   52
(bb <- moffset(alcoff,             "11",             "Sun", postfix = "*"))
#>     Sun* Mon* Tue* Wed* Thu* Fri* Sat*
#> 11    39    8   10   20   32   27   44
#> 12    59   10   13    8   39   37   73
#> 13    45    9   26   32   37   27   41
#> 14    53   22   41   31   46   42   58
#> 15    70   39   48   62   69   59   75
#> 16    95   28   48   71   85   55   96
#> 17   130   46   59   98  141  136  154
#> 18   121   53  100  117  185  223  236
#> 19   146   74  119  155  289  335  337
#> 20   166   74  135  283  508  591  490
#> 21   131   84  154  326  610  866  754
#> 22   114   90  143  345  765  976 1026
#> 23   159  110  169  363  899 1265 1179
#> 0*   121   98  165  324  827 1379 1332
#> 1*    97   92  157  278  619 1327 1356
#> 2*    60   69  107  229  410  979 1011
#> 3*    55   60   75  238  401  693  718
#> 4*    25   38   48  145  223  346  410
#> 5*    19   10   20   56  139  188  287
#> 6*    13    9    9   55   70  155  213
#> 7*    20    6    9   42   40  160  200
#> 8*     5    8   12   29   40   79   96
#> 9*     7    8   14   28   38   44   58
#> 10*    7   13   20   36   38   52   69
aa - bb  # Note the difference!
#>     Sun Mon Tue  Wed  Thu  Fri Sat
#> 11    0   0   0    0    0    0   0
#> 12    0   0   0    0    0    0   0
#> 13    0   0   0    0    0    0   0
#> 14    0   0   0    0    0    0   0
#> 15    0   0   0    0    0    0   0
#> 16    0   0   0    0    0    0   0
#> 17    0   0   0    0    0    0   0
#> 18    0   0   0    0    0    0   0
#> 19    0   0   0    0    0    0   0
#> 20    0   0   0    0    0    0   0
#> 21    0   0   0    0    0    0   0
#> 22    0   0   0    0    0    0   0
#> 23    0   0   0    0    0    0   0
#> 0  1211  23 -67 -159 -503 -552  47
#> 1  1259   5 -65 -121 -341 -708 -29
#> 2   951  -9 -38 -122 -181 -569 -32
#> 3   663  -5 -15 -163 -163 -292 -25
#> 4   385 -13 -10  -97  -78 -123 -64
#> 5   268   9 -10  -36  -83  -49 -99
#> 6   200   4   0  -46  -15  -85 -58
#> 7   180  14  -3  -33    2 -120 -40
#> 8    91  -3  -4  -17  -11  -39 -17
#> 9    51  -1  -6  -14  -10   -6 -14
#> 10   62  -6  -7  -16   -2  -14 -17