Based on the MWE of this question, I want to apply the regression only to a portion of the graph as in this other question, but not just the last portion. I want to do regression on the beginning so that the instruction skip first n=3 do not apply.
I can't make it work as I wish, i.e. regression only on the initial part of the graph. The command select coords between index={1}{3} generates an error.
\begin{tikzpicture}
\begin{axis}[ytick={1,...,6}]
\pgfplotstableread{%
X Z Y
1 3 0
2 4 1
3 5 2
4 6 6 }\test
\addplot[only marks, mark=*]
table[x=X, y=Y] {\test};
\addplot[ no markers,dashed, red,
select coords between index={1}{3}
]
table [
header=false,
x=X,
y={create col/linear regression={y=Y}}] {\test};
\end{axis}
\end{tikzpicture}
When commenting the line with select coords between index the regression applies to all graph, and this is not what I want

