cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
mostarr
Level IV

Fit x by y on subset of data vs other subset of data

Hi, this is not a JSL question like most of my others are.

 

I have some data, and I'd like to fit x by y on it, one half of the data vs the other half of the data. I realize a caveman way of doing this is cut pasting the second half of the data into a new column. But I'd really rather not adjust the table like that. Any solutions? I was advised to use the Split function under Tables so I could toy around with that, but is that all there is to it? Anything more specific?

 

Thank you hugely in advance, and thank you so much for all the help you've been providing to this date. You are an amazing and amazingly patient community.

 

Best,

Mike

3 ACCEPTED SOLUTIONS

Accepted Solutions
Jeff_Perkinson
Community Manager Community Manager

Re: Fit x by y on subset of data vs other subset of data

If I'm reading your question correctly, it sounds like you have a single column of data that has both your X values and Y values in it.

 

Do you have a column that identifies whether a row is an X or Y value? Do you have another column (or combination of columns) that identifies which XY pair that row belongs to?

 

For example, in the table below Value has both X and Y values. Measure identifies whether a row is a height or weight value, and name, age, sex together identify a unique entity for that height or weight.

 

If this is the kind of data you have then yes, Tables->Split is exactly what you need.

 

You would complete the Split dialog with Measure in the Split By role, Value in the Split Columns role, and name, age, sex in the Group role. 

 

2021-07-06_16-19-41.170.png

 

name

age

sex

Measure

Value

KATIE

12

F

height

59

KATIE

12

F

weight

95

LOUISE

12

F

height

61

LOUISE

12

F

weight

123

JANE

12

F

height

55

JANE

12

F

weight

74

JACLYN

12

F

height

66

JACLYN

12

F

weight

145

LILLIE

12

F

height

52

LILLIE

12

F

weight

64

TIM

12

M

height

60

TIM

12

M

weight

84

JAMES

12

M

height

61

JAMES

12

M

weight

128

ROBERT

12

M

height

51

ROBERT

12

M

weight

79

BARBARA

13

F

height

60

BARBARA

13

F

weight

112

ALICE

13

F

height

61

ALICE

13

F

weight

107

SUSAN

13

F

height

56

SUSAN

13

F

weight

67

JOHN

13

M

height

65

JOHN

13

M

weight

98

JOE

13

M

height

63

JOE

13

M

weight

105

 

-Jeff

View solution in original post

Re: Fit x by y on subset of data vs other subset of data

Hi @mostarr,

 

Ya, split is basically it. @Jeff_Perkinson as given a way to do it if you know what to split by. If there is only a single column in your data, then like copy and paste will be the quickest.

Chris Kirchberg, M.S.2
Data Scientist, Life Sciences - Global Technical Enablement
JMP Statistical Discovery, LLC. - Denver, CO
Tel: +1-919-531-9927 ▪ Mobile: +1-303-378-7419 ▪ E-mail: chris.kirchberg@jmp.com
www.jmp.com

View solution in original post

mzwald
Staff

Re: Fit x by y on subset of data vs other subset of data

Another option besides splitting your datatable is creating a new column to randomly group your rows (or could systematically group them by row counts) into different groupings and use that grouping as an overlay such as in this example:

// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );

// New column: Group
Data Table( "Big Class" ) << New Column( "Group",
	Character,
	"Nominal",
	Formula( If( Random Integer( 2 ) == 1, "Group A", "Group B" ) )
);

// Report snapshot: Big Class - Graph Builder
Graph Builder(
	Size( 534, 456 ),
	Show Control Panel( 0 ),
	Variables( X( :height ), Y( :weight ), Overlay( :Group ) ),
	Elements(
		Points( X, Y, Legend( 5 ) ),
		Line Of Fit( X, Y, Legend( 7 ), Equation( 1 ) )
	)
);

View solution in original post

7 REPLIES 7
Jeff_Perkinson
Community Manager Community Manager

Re: Fit x by y on subset of data vs other subset of data

If I'm reading your question correctly, it sounds like you have a single column of data that has both your X values and Y values in it.

 

Do you have a column that identifies whether a row is an X or Y value? Do you have another column (or combination of columns) that identifies which XY pair that row belongs to?

 

For example, in the table below Value has both X and Y values. Measure identifies whether a row is a height or weight value, and name, age, sex together identify a unique entity for that height or weight.

 

If this is the kind of data you have then yes, Tables->Split is exactly what you need.

 

You would complete the Split dialog with Measure in the Split By role, Value in the Split Columns role, and name, age, sex in the Group role. 

 

2021-07-06_16-19-41.170.png

 

name

age

sex

Measure

Value

KATIE

12

F

height

59

KATIE

12

F

weight

95

LOUISE

12

F

height

61

LOUISE

12

F

weight

123

JANE

12

F

height

55

JANE

12

F

weight

74

JACLYN

12

F

height

66

JACLYN

12

F

weight

145

LILLIE

12

F

height

52

LILLIE

12

F

weight

64

TIM

12

M

height

60

TIM

12

M

weight

84

JAMES

12

M

height

61

JAMES

12

M

weight

128

ROBERT

12

M

height

51

ROBERT

12

M

weight

79

BARBARA

13

F

height

60

BARBARA

13

F

weight

112

ALICE

13

F

height

61

ALICE

13

F

weight

107

SUSAN

13

F

height

56

SUSAN

13

F

weight

67

JOHN

13

M

height

65

JOHN

13

M

weight

98

JOE

13

M

height

63

JOE

13

M

weight

105

 

-Jeff
mostarr
Level IV

Re: Fit x by y on subset of data vs other subset of data

Is there a basic way to do this in JSL? Split()?
mostarr
Level IV

Re: Fit x by y on subset of data vs other subset of data

Actually I am following the syntax in the Scripting Index and results are not as expected. The split in Split(Split()) excludes that column, instead of isolating it, and it doesn't seem it shows the split by column. It's just pretty messy and I don't know that it's working properly.
Jeff_Perkinson
Community Manager Community Manager

Re: Fit x by y on subset of data vs other subset of data

After completing the Tables->Split by hand one time, you can find a Source script in the resulting data table. That will have the script for doing the split. No need to write it by hand. You can copy/paste it into your script.

 

2021-07-08_12-55-29.982.png

 

This is true for most of JSL. Do it by hand then get the script for it from JMP.

Let JMP write your script! 

 

-Jeff

Re: Fit x by y on subset of data vs other subset of data

Hi @mostarr,

 

Ya, split is basically it. @Jeff_Perkinson as given a way to do it if you know what to split by. If there is only a single column in your data, then like copy and paste will be the quickest.

Chris Kirchberg, M.S.2
Data Scientist, Life Sciences - Global Technical Enablement
JMP Statistical Discovery, LLC. - Denver, CO
Tel: +1-919-531-9927 ▪ Mobile: +1-303-378-7419 ▪ E-mail: chris.kirchberg@jmp.com
www.jmp.com
mostarr
Level IV

Re: Fit x by y on subset of data vs other subset of data

Thanks for the responses.

 

I found that a specific type of Split worked perfectly. Now I am wondering if there is a way to save the script automatically? Or do I have to rewrite it manually in JSL?

 

Mike

mzwald
Staff

Re: Fit x by y on subset of data vs other subset of data

Another option besides splitting your datatable is creating a new column to randomly group your rows (or could systematically group them by row counts) into different groupings and use that grouping as an overlay such as in this example:

// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );

// New column: Group
Data Table( "Big Class" ) << New Column( "Group",
	Character,
	"Nominal",
	Formula( If( Random Integer( 2 ) == 1, "Group A", "Group B" ) )
);

// Report snapshot: Big Class - Graph Builder
Graph Builder(
	Size( 534, 456 ),
	Show Control Panel( 0 ),
	Variables( X( :height ), Y( :weight ), Overlay( :Group ) ),
	Elements(
		Points( X, Y, Legend( 5 ) ),
		Line Of Fit( X, Y, Legend( 7 ), Equation( 1 ) )
	)
);