rearrange {cabootcrs} | R Documentation |

## Rearranges bootstrap axes by comparing to sample axes

### Description

`rearrange`

compares one set of axes for row points and column points (from the bootstrap
data matrix) to another (from the sample data matrix) by looking at all possible
reorderings and reflections (only) of the bootstrap axes and picking the one which
best matches the sample axes.

### Usage

```
rearrange(
RS,
RB,
CS,
CB,
r,
reflectonly = FALSE,
catype = "sca",
mcatype = "Burt",
mcaindividualboot = FALSE,
maxrearrange = 6
)
```

### Arguments

`RS` |
Sample axes for row points (as columns) |

`RB` |
Bootstrap axes for row points (as columns) |

`CS` |
Sample axes for column points (as columns) |

`CB` |
Bootstrap axes for column points (as columns) |

`r` |
Rank of the bootstrap matrix |

`reflectonly` |
TRUE to reflect the axes only, no reordering |

`catype` |
Can be "sca" for simple or "mca" for multiple CA. |

`mcatype` |
"Burt" if using Burt matrix rows and columns are the same, so only use column axes |

`mcaindividualboot` |
TRUE to use highly experimental method |

`maxrearrange` |
Maximum number of axes to rearrange |

### Details

This is only intended for internal use by the `cabootcrs`

function.

Finds the rearrangement of columns of RB and CB to maximise match = tr( abs(RS'*RB + CS'*CB) )

Uses the Hungarian algorithm via lp.assign in lpSolve up to a maximum of maxrearrange vectors.

Algorithm assigns columns (B) to rows (S), hence transpose matrix so postmultiplication moves B to coincide with S.

In effect this is Procrustes rotation of bootstrap axes to best match sample axes, except that there is no rotation, only reflection and reordering of axes (aka rearranging).

Note that this seeks the best fit to all axes, not best fit just to the ones whose variances are being calculated, and does not weight the reordering by eigenvalues or restrict how far a vector can be reordered by. Hence a fairly low maxrearrange may be preferable.

Faster than full comparison when rank >= 4, for maxrearrange=6, but can take much longer if rearrange all axes

Rearranging more axes means higher chance of finding a matching axis, so std dev can be decreased by average of 1-2% if all axes are rearranged.

Limited testing suggests that rearranging all axes tends to over-reorder and hence underestimate variances, due to ignoring eigenvalues, hence seems best to rearrange 6 as before, unless very large numbers of close eigenvalues.

When mca bootstrap replicate has fewer "real" singular values (i.e. > 1/p) than the sample matrix then only the first B@realr axes will be compared, so that the last sample axis will get nothing from this replicate and the "real" bootstrap axes will be matched only with the same first few sample ones.

r = rank of bootstrap matrix, so if < sample rank will ignore last sample axis

### Value

list containing:

T = matrix to rearrange xB so it is equivalent to xS, i.e. xS <- xB * T

numre = number of axes checked for rearranging = min(r,maxrearrange)

match = assign$objval from the Hungarian algorithm

same = flag for whether there was no reordering of axes (but may have been reflection)

### See Also

### Examples

```
# Not intended for direct call by users
```

*cabootcrs*version 2.1.0 Index]