# [Gretl-users] Scatter by 2 groups

Ricardo Gonçalves Silva ricardogs at terra.com.br
Tue Nov 3 18:09:44 EST 2009

```Thanks Allin.
This was just what I need.

Rick

--------------------------------------------------
From: "Allin Cottrell" <cottrell at wfu.edu>
Sent: Thursday, October 22, 2009 4:15 PM
To: "Gretl list" <gretl-users at lists.wfu.edu>
Subject: Re: [Gretl-users] Scatter by 2 groups

>
> On Mon, 19 Oct 2009, [iso-8859-1] Ricardo Gon�alves Silva wrote:
>
>> I need to do a scatter plot by two groups (like time and
>> individual, in a panel data).
>> I have continuous data and 4 classes for each grouping variable
>> (16 combinations).
>> Can Gretl does this?
>
> Sorry this has taken a while.
>
> If I have the right idea of what it is you want to do, you can do
> a sequence of scatter plots using a loop and the "smpl" command.
>
> Suppose we have variables of interest y and x, and a group
> variable "byvar", and we want a scatter of y versus x for each
> value of byvar:
>
> matrix byvals = sort(values(byvar))
> scalar nvals = rows(byvals)
> loop i=1..nvals
>  smpl byvar=byvals[i] --restrict
>  gnuplot y x
>  smpl --full
> endloop
>
> The same idea can be extended to the case of two grouping
> variables, with an inner loop pertaining to (say) "byvar2".
>
> matrix byvals = sort(values(byvar))
> scalar n = rows(byvals)
> matrix byvals2 = sort(values(byvar2))
> scalar m = rows(byvals2)
> loop i=1..n
>  loop j=1..m
>    smpl byvar=byvals[i] && byvar2=byvals2[j] --restrict
>    gnuplot y x
>    smpl --full
>  endloop
> endloop
>
> Allin Cottrell
>
>

> _______________________________________________
> Gretl-users mailing list
> Gretl-users at lists.wfu.edu
> http://lists.wfu.edu/mailman/listinfo/gretl-users

```