Graphs: Adding a line in a scatter plot

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

RDS
Posts: 86
Joined: Thu Feb 17, 2011 9:50 am

Graphs: Adding a line in a scatter plot

Postby RDS » Fri Sep 04, 2015 10:54 am

I would like to add a line showing the relationship between two variables x and y in a scatter plot.

graph gra_b1.scat(n) x y
gra_b1.option linepat
gra_b1.setelem(1) lcolor(blue) lwidth(2) symbol(circle)
gra_b1.setelem(2) lcolor(blue) lwidth(2) symbol(circle)

what is the command to add the line?

Thank you.

CharlieEVIEWS
Posts: 202
Joined: Tue Jul 17, 2012 9:47 am

Re: Graphs: Adding a line in a scatter plot

Postby CharlieEVIEWS » Fri Sep 04, 2015 10:57 am

Code: Select all

wfcreate u 100
genr x = nrnd
genr y = nrnd
group myscat x y
freeze(myscat_graph) myscat.scat linefit

RDS
Posts: 86
Joined: Thu Feb 17, 2011 9:50 am

Re: Graphs: Adding a line in a scatter plot

Postby RDS » Fri Sep 04, 2015 11:04 pm

It is useful, but it seems not flexible enough.

For example you cannot standardize variables with the option (n):
myscat.scat(n)

or you cannot add a text with the option
myscat.addtext(.2, .1, x) Relation between x and y

RDS
Posts: 86
Joined: Thu Feb 17, 2011 9:50 am

Re: Graphs: Adding a line in a scatter plot

Postby RDS » Fri Sep 04, 2015 11:34 pm

I have figure out how to add a text:
myscat.addtext(.2, .1) Relation between x and y

but not how to standardize variables with the option (n)

Once standardized the variables, is it possible to add a vertical line crossing the zero?

Best

RDS
Posts: 86
Joined: Thu Feb 17, 2011 9:50 am

Re: Graphs: Adding a line in a scatter plot

Postby RDS » Sat Sep 05, 2015 2:12 am

I also found the way to add the vertical line crossing the zero.

The questions left are:

1) automatic standardization of the variables (n)
2) rather than a linear fit, what would be the command to add a polynomial (power = 2) in the graph?

All the information for fitting regressions in graphs are note available in "Eviews 8 Command Ref.pdf"
Where are these reported?

Best

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13322
Joined: Tue Sep 16, 2008 5:38 pm

Re: Graphs: Adding a line in a scatter plot

Postby EViews Gareth » Sat Sep 05, 2015 6:35 am

Object Reference
Follow us on Twitter @IHSEViews

RDS
Posts: 86
Joined: Thu Feb 17, 2011 9:50 am

Re: Graphs: Adding a line in a scatter plot

Postby RDS » Sat Sep 05, 2015 11:33 pm

Thanks very useful.

The last think I need to do is to add a scalar in the graph.

For example I run a regression between x and y and save the adjusted R^2 named adjr2.

I need to add the scalar adjr2 in the graph.


Note that I cannot add the number using addtext because it is a loop of many charts.

Best

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13322
Joined: Tue Sep 16, 2008 5:38 pm

Re: Graphs: Adding a line in a scatter plot

Postby EViews Gareth » Sun Sep 06, 2015 8:02 am

You'll have to use addtext
Follow us on Twitter @IHSEViews

RDS
Posts: 86
Joined: Thu Feb 17, 2011 9:50 am

Re: Graphs: Adding a line in a scatter plot

Postby RDS » Sun Sep 06, 2015 3:06 pm

Addtext would add a text not the scalar`.
Unless you are suggesting to add the number directly in the addtext option.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13322
Joined: Tue Sep 16, 2008 5:38 pm

Re: Graphs: Adding a line in a scatter plot

Postby EViews Gareth » Sun Sep 06, 2015 6:33 pm

Convert the scalar to text with the @str function.
Follow us on Twitter @IHSEViews


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 23 guests