I am discovering PSTricks's plotstyle=LSM to make a regression analysis y=m x + c. Here is my code:
\documentclass[12pt]{article}
\usepackage{filecontents}
\begin{filecontents*}{data.dat}
0.0 0.0
144.321 0.84
159.407 0.8925
\end{filecontents*}
\usepackage{pst-plot,pstricks-add}
\begin{document}
\readdata{\data}{data.dat}
\psset{xunit=0.6mm,yunit=30mm,xlabelFactor=$$,labelFontSize=\footnotesize,mathLabel=false}
\begin{pspicture}(0,0)(150,3)
\psaxes[axesstyle=frame,Dx=50,Dy=0.5, ticksize=0 4pt](150,3)
\listplot [xStart=0, xEnd=150,xunit=1,plotstyle=values,rot=90] {\data}
\listplot [xStart=0,xEnd=150,xunit=1,linewidth=1.5pt,linecolor=red,showpoints, dotstyle=square] {\data}
\listplot[PstDebug=1,xStart=0, xEnd=150,xunit=1,plotstyle=LSM,linecolor=blue, linestyle=dashed]{\data}
\end{pspicture}
\end{document}
The parameter xEnd=150 makes the Linear regression analysis only to consider the first two lines of the data file.
On compiling I get the line equation as
y = 0.291017 x + 9.64966e-08
I see that the gradient of 0.291017 seems to be wrong as the gradient should be 0.84/144.321 = 0.0058...
What am I doing wrong here?
