# PSTricks---plotstyle LSM (Least Square method)

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*}

\begin{document}

\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?

-

that was a problem with different axes unit. Try it with this version:

http://texnik.dante.de/tex/generic/pst-plot/pst-plot.tex

With this file it works for me.

And by the way, there is now a pst-fit, see http://texnik.dante.de/doc/generic/pst-fit/pst-fit-doc.pdf

-
Thanks. It is now working properly. 1 Vote up. –  yCalleecharan Nov 29 '11 at 8:11