|
|
|
||||
|
|
|||||
Igraph is one of the few commands in SPSS that is sensitive to the level (i.e., nominal, ordinal, scale) of variable that is used. If you want to include a regression line on your scatterplot using igraph, both variables need to be scale variables. There are a couple of ways to change the level of the variables in your data set, which will be demonstrated below. First, let's see how to tell what levels of variables are in your data set.
To see the level of the variables, you can either look at the variable view in the SPSS data editor (in the column on the far right, called measure), or you can use the sysfile info command. Let's use the crf241 data set and the sysfile info command to see the levels of variables in this data set. Note that when you use the sysfile info command, you must specify the full path for the data set.
Sysfile Info: c:\crf241.sav File Type: SPSS Data File Creation Date: 24-SEP-2001 08:04:55 Label: None N of Cases: 32 Total # of Defined Variable Elements: 3 # of Named Variables: 3 Data Are Not Weighted Data Are Compressed File Contains Case Data File Contains No Documents File Contains No Variable Sets File Contains No Trends Date Information File Contains No Multiple Response Definitions File Contains No Data Entry for Windows Information File Contains No TextSmart Information Variable Information: Name Position Y * No label * 1 Measurement level: Scale Format: F8 Column Width: 8 Alignment: Right A * No label * 2 Measurement level: Scale Format: F8 Column Width: 8 Alignment: Right B * No label * 3 Measurement level: Nominal Format: F8 Column Width: 8 Alignment: Rightget file 'c:\crf241.sav'. execute. sysfile info 'c:\crf241.sav'.
As you can see, B is a nominal level variable. Let's try to use this variable to make a scatterplot with a regression line, and see what igraph does.
igraph /x1 = var(b) /y = var(y) /fitline method = regression linear line = total /scatter coincident = none.
As you can see, igraph made the scatterplot, but without the regression line that we requested. One way to fix this problem is to include the type = scale option for the nominal variable, as shown below.
igraph /x1 = var(b) type = scale /y = var(y) /fitline method = regression linear line = total /scatter coincident = none.
While including the type = scale option in igraph is very easy to use, it is also temporary.
Sysfile Info: c:\crf241.sav File Type: SPSS Data File Creation Date: 24-SEP-2001 08:04:55 Label: None N of Cases: 32 Total # of Defined Variable Elements: 3 # of Named Variables: 3 Data Are Not Weighted Data Are Compressed File Contains Case Data File Contains No Documents File Contains No Variable Sets File Contains No Trends Date Information File Contains No Multiple Response Definitions File Contains No Data Entry for Windows Information File Contains No TextSmart Information Variable Information: Name Position Y * No label * 1 Measurement level: Scale Format: F8 Column Width: 8 Alignment: Right A * No label * 2 Measurement level: Scale Format: F8 Column Width: 8 Alignment: Right B * No label * 3 Measurement level: Nominal Format: F8 Column Width: 8 Alignment: Rightsysfile info 'c:\crf241.sav'.
This could be inconvenient if you need to create numerous scatterplots with regression lines. To change the type of level of a variable permanently, you can use the variable level command.
variable level b (scale). execute.
Note that if you want to change the level of more than one variable, to be a particular type, you can include all of the variables before indicating the type. For example,
variable level a b y (scale).
You will need to save the data file before this change will be reflected in the sysfile info.
Sysfile Info: c:\crf242.sav File Type: SPSS Data File Creation Date: 24-SEP-2001 09:06:19 Label: None N of Cases: 32 Total # of Defined Variable Elements: 3 # of Named Variables: 3 Data Are Not Weighted Data Are Compressed File Contains Case Data File Contains No Documents File Contains No Variable Sets File Contains No Trends Date Information File Contains No Multiple Response Definitions File Contains No Data Entry for Windows Information File Contains No TextSmart Information Variable Information: Name Position Y * No label * 1 Measurement level: Scale Format: F8 Column Width: 8 Alignment: Right A * No label * 2 Measurement level: Scale Format: F8 Column Width: 8 Alignment: Right B * No label * 3 Measurement level: Scale Format: F8 Column Width: 8 Alignment: Rightsave outfile 'c:\crf242.sav'. sysfile info 'c:\crf242.sav'.
We should point out that if you do not need the code that produces the graph, there is another way to create a scatterplot with a regression line that is insensitive to the type of variables used. You can create a scatterplot (using either point-and-click or the graph command) and then double click on the graph to open the chart editor. From the menu at the top, select 'chart', 'options', and then put a check in the box marked 'total' in the upper right corner under fit line. Close the chart editor and the change will be made on your graph.
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services