Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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

share|improve this answer
    
Thanks. It is now working properly. 1 Vote up. –  yCalleecharan Nov 29 '11 at 8:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.