我想知道是否可以让 TikZ/pgfplots
输出线性回归,这也会给我回归本身的不确定性。有点像这样:
注意 a 和 b 存在不确定性。
目前,我有这个
\begin{tikzpicture}
\centering
\pgfplotsset{width=11cm,
compat=1.3,
legend style={font=\footnotesize}}
\begin{axis}[
title={$R_1$:Experimental Plot I vs. V},
xlabel={V},
ylabel={I}},
legend cell align=left,
legend pos=north west]
\addplot+[blue][mark size=1.5pt] table[row sep=\\,
y={create col/linear regression={y=Y}}] % compute a linear regression from the
%input table
{
X Y\\
0.44 0.001 \\
-0.44 -0.001 \\
4.24 0.008 \\
-4.40 -0.008 \\
9.68 0.018 \\
-9.99 -0.018 \\
15.56 0.029 \\
-15.64 -0.029 \\
18.67 0.035 \\
-18.67 -0.035 \\
};
\addlegendentry{%
$\pgfmathprintnumber{\pgfplotstableregressiona} \cdot a
\pgfmathprintnumber[print sign]{\pgfplotstableregressionb}$ lin. Regression} %
\addplot+[blue,only marks,mark=*,mark size=1pt][error bars/.cd,y dir=both,y explicit,
x dir=both,x explicit]
coordinates {
( 0.44 , 0.001 ) +- ( 0.01 , 0.00025 )
( -0.44 , -0.001 ) +- ( 0.01 , -0.00025 )
(4.24,0.008) +- (0.01,0.002)
(-4.40,-0.008) +- (0.01,-0.002)
(9.68,0.018) +- (0.01,0.0045)
(-9.99,-0.018) +- (0.01,-0.0045)
(15.56,0.029) +- (0.01,0.00725)
(-15.64,-0.029) +- (0.01,-0.00725)
(18.67,0.035) +- (0.01,0.00875)
(-18.67,-0.035) +- (0.01,-0.00875)
};
\end{axis}
\end{tikzpicture}
提前致谢。
编辑:我不是要求回归的 r^2 值,而是要求回归本身的不确定性。