Rescales an NMF model keeping the fitted target matrix identical.

```
S3 (NMF)
`scale`(x, center = c("basis", "coef"), scale = 1)
```

- x
- an NMF object
- center
- either a numeric normalising vector
`delta`

, or either`'basis'`

or`'coef'`

, which respectively correspond to using the column sums of the basis matrix or the inverse of the row sums of the coefficient matrix as a normalising vector. If numeric,`center`

should be a single value or a vector of length the rank of the NMF model, i.e. the number of columns in the basis matrix. - scale
- scaling coefficient applied to
`D`

, i.e. the value of`alpha`

, or, if`center='coef'`

, the value of`1/alpha`

(see section*Details*).

an NMF object

Standard NMF models are identifiable modulo a scaling factor, meaning that the basis components and basis profiles can be rescaled without changing the fitted values:

X = W H = (W D) (D^-1 H) with`D= alpha * diag(1/delta_1, ..., 1/delta_r)`

The default call

`scale(object)`

rescales the basis NMF object so that each column of the basis matrix sums up to one.

```
# random 3-rank 10x5 NMF model
x <- rnmf(3, 10, 5)
# rescale based on basis
colSums(basis(x))
```

```
## [1] 4.822 4.774 5.044
```

```
colSums(basis(scale(x)))
```

```
## [1] 1 1 1
```

```
rx <- scale(x, 'basis', 10)
colSums(basis(rx))
```

```
## [1] 10 10 10
```

```
rowSums(coef(rx))
```

```
## [1] 0.7124 1.1672 1.6006
```

```
# rescale based on coef
rowSums(coef(x))
```

```
## [1] 1.477 2.445 3.173
```

```
rowSums(coef(scale(x, 'coef')))
```

```
## [1] 1 1 1
```

```
rx <- scale(x, 'coef', 10)
rowSums(coef(rx))
```

```
## [1] 10 10 10
```

```
colSums(basis(rx))
```

```
## [1] 0.7124 1.1672 1.6006
```

```
# fitted target matrix is identical but the factors have been rescaled
rx <- scale(x, 'basis')
all.equal(fitted(x), fitted(rx))
```

```
## [1] TRUE
```

```
all.equal(basis(x), basis(rx))
```

```
## [1] "Mean relative difference: 0.7951"
```

```
```