On Sun, 9 Nov 2014, Artur T. wrote:

> Dear gretl users,
>
> I trying to draw a specific fitted line into a scatter plot. However, I
> can't figure out how the series called "fitted" in the example below
> does appear as a straight line. The option --with-lines=fitted does not
> solve the issue. Does anybody have a nice solution to this?
>
> <hansl>
> open denmark.gdt --quiet
>
> series D = (diff(LRY)>0)       # define dummy
> series d_LRY = diff(LRY)
> series DLRY = D*d_LRY        # interaction term
> series dM = diff(LRM)
> ols dM 0 d_LRY DLRY            # Threshold OLS
> series fitted = $yhat
>
> gnuplot dM fitted d_LRY --output=display \
>   { set style line 1 lc rgb 'blue' pt 6 ; \
>   set style line 2 lc rgb 'red' pt 5 ; }
> <\hansl>

1) The old-style gnuplot command "set style line" is not going to
    override the new-style "set linetype" directives put into the
    plot file by gretl.

2) While "with-lines=fitted" should work, it won't actually do what
    you want without further work: since the x-axis values are not
    sorted, you'll get a sort of linear spider-web with the fitted
    line doubling back on itself repeatedly.

3) I'd recommand using gretl's new "plot block" syntax for this sort
    of thing. (Reminder to self: document this!)

http://lists.wfu.edu/pipermail/gretl-devel/2014-October/005341.html

Solution:

<hansl>
open denmark.gdt --quiet

series D = (diff(LRY)>0)     # define dummy
series d_LRY = diff(LRY)
series DLRY = D*d_LRY        # interaction term
series dM = diff(LRM)
ols dM 0 d_LRY DLRY          # Threshold OLS
series fitted = $yhat
list plotlist = dM fitted d_LRY
matrix plotmat = msortby({plotlist}, 3)

plot plotmat
   option with-lines=fitted
   literal set linetype 1 lc rgb 'blue' pt 6
   literal set linetype 2 lc rgb 'red' pt 5
end plot --output=display
</hansl>

Allin

Reply via email to