# cumbetaTopN {#cumbetatopn}

## Syntax {#syntax}

`cumbetaTopN(Y, X, S, top, [ascending=true], [tiesMethod='latest'])`

Please see [Cumulative Moving TopN Functions](../Themes/cumTopN.md) for the parameters and windowing logic.

## Details {#details}

The function stably sorts *X* and *Y* by *S* in the order specified by *ascending*, then calculates the coefficient estimate ordinary-least-squares regressions of *Y* on *X* in a cumulative window.

**Return value**: DOUBLE type

## Examples {#examples}

```
Y=1 2 3 10 100 4 3
X=1 7 8 9 0 5 8
S = 0.3 0.5 0.1 0.1 0.5 0.2 0.4
cumbetaTopN(Y, X, S, 6)
// output: [,0.1666,0.2441,0.7483,-6.4428,-6.4428,-6.2293]
```

