cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar

JSL Bivariate analysis with "by"-argument, group-by + fit as loop (?)

Dear Community,

 

Currently I am trying to automate several recurring JMP routines with JSL. My tables have after several hundred lines of code now the form I want to have and I fail in JSL on a supposedly simple bivariate analysis :(

As an example I have attached a simplified table. If you click through it is:

  • X = :days, Y = :Readout, By = :Classification
  • => SHIFT Hot button => Group by :Individuals => SHIFT Hot button => Fit each value

The resulting code copied from the editor is: 

Bivariate(
	SendToByGroup( {Is Missing( :Classification )} ),
	Y( :Readout ),
	X( :Days ),
	SendToByGroup(
		{Is Missing( :Classification )},
		Fit Where(
			:Individuals == "Ind7",
			Fit Each Value( {Line Color( {212, 73, 88} )} )
		),
		Fit Where(
			:Individuals == "Ind22",
			Fit Each Value( {Line Color( {66, 112, 221} )} )
		)
	),
	SendToByGroup(
		{:Classification == "A"},
		Fit Where(
			:Individuals == "Ind2",
			Fit Each Value( {Line Color( {212, 73, 88} )} )
		),
		Fit Where(
			:Individuals == "Ind4",
			Fit Each Value( {Line Color( {61, 174, 70} )} )
		),
		Fit Where(
			:Individuals == "Ind5",
			Fit Each Value( {Line Color( {66, 112, 221} )} )
		),
		Fit Where(
			:Individuals == "Ind6",
			Fit Each Value( {Line Color( {204, 121, 41} )} )
		),
		Fit Where(
			:Individuals == "Ind8",
			Fit Each Value( {Line Color( {40, 182, 143} )} )
		),
		Fit Where(
			:Individuals == "Ind9",
			Fit Each Value( {Line Color( {162, 43, 221} )} )
		),
		Fit Where(
			:Individuals == "Ind12",
			Fit Each Value( {Line Color( {196, 189, 43} )} )
		),
		Fit Where(
			:Individuals == "Ind14",
			Fit Each Value( {Line Color( {39, 174, 174} )} )
		),
		Fit Where(
			:Individuals == "Ind15",
			Fit Each Value( {Line Color( {197, 41, 201} )} )
		),
		Fit Where(
			:Individuals == "Ind24",
			Fit Each Value( {Line Color( {142, 176, 40} )} )
		),
		Fit Where(
			:Individuals == "Ind28",
			Fit Each Value( {Line Color( {40, 154, 190} )} )
		)
	),
	SendToByGroup(
		{:Classification == "B"},
		Fit Where(
			:Individuals == "Ind1",
			Fit Each Value( {Line Color( {212, 73, 88} )} )
		),
		Fit Where(
			:Individuals == "Ind11",
			Fit Each Value( {Line Color( {61, 174, 70} )} )
		),
		Fit Where(
			:Individuals == "Ind16",
			Fit Each Value( {Line Color( {66, 112, 221} )} )
		),
		Fit Where(
			:Individuals == "Ind17",
			Fit Each Value( {Line Color( {204, 121, 41} )} )
		),
		Fit Where(
			:Individuals == "Ind21",
			Fit Each Value( {Line Color( {40, 182, 143} )} )
		),
		Fit Where(
			:Individuals == "Ind23",
			Fit Each Value( {Line Color( {162, 43, 221} )} )
		),
		Fit Where(
			:Individuals == "Ind25",
			Fit Each Value( {Line Color( {196, 189, 43} )} )
		),
		Fit Where(
			:Individuals == "Ind26",
			Fit Each Value( {Line Color( {39, 174, 174} )} )
		),
		Fit Where(
			:Individuals == "Ind27",
			Fit Each Value( {Line Color( {197, 41, 201} )} )
		)
	),
	SendToByGroup(
		{:Classification == "C"},
		Fit Where(
			:Individuals == "Ind20",
			Fit Each Value( {Line Color( {212, 73, 88} )} )
		)
	),
	SendToByGroup(
		{:Classification == "D"},
		Fit Where(
			:Individuals == "Ind3",
			Fit Each Value( {Line Color( {212, 73, 88} )} )
		),
		Fit Where(
			:Individuals == "Ind10",
			Fit Each Value( {Line Color( {61, 174, 70} )} )
		),
		Fit Where(
			:Individuals == "Ind13",
			Fit Each Value( {Line Color( {66, 112, 221} )} )
		),
		Fit Where(
			:Individuals == "Ind18",
			Fit Each Value( {Line Color( {204, 121, 41} )} )
		),
		Fit Where(
			:Individuals == "Ind19",
			Fit Each Value( {Line Color( {40, 182, 143} )} )
		)
	),
	By( :Classification )
);

My problem now is that this script if I hard code it like this will not work with new Indiviudals, which will be added to this table. And I also realize that I have to work with lists and a For()-loop in some form.

 

For the lists, I started as follows:

//Writes only the different individual values of column :Classification into a variable
	classlist = dt:"Classification" << Get values;
	classvalues = Associative Array(classlist) << Get Keys;
	
//Writes only the different individual values of column :Individuals into a variable
	IDlist = dt:"Individuals" << Get values;
	IDvalues = Associative Array(IDlist) << Get Keys;

But how I now approach the For()-loop correctly, I unfortunately do not know...

 

Does anyone have any ideas or can help me?

 

1 ACCEPTED SOLUTION

Accepted Solutions
vince_faller
Super User (Alumni)

Re: JSL Bivariate analysis with "by"-argument, group-by + fit as loop (?)

Here's a big class example that I think does what you want.  

names default to here(1);
dt = open("$SAMPLE_DATA\Big Class.jmp");
dt << Bivariate(
	Y( :weight ),
	X( :height ),
	GroupBy(:sex),
	By( :age ), 
	FitLine(1)
);

 

Vince Faller - Predictum

View solution in original post

2 REPLIES 2
vince_faller
Super User (Alumni)

Re: JSL Bivariate analysis with "by"-argument, group-by + fit as loop (?)

Here's a big class example that I think does what you want.  

names default to here(1);
dt = open("$SAMPLE_DATA\Big Class.jmp");
dt << Bivariate(
	Y( :weight ),
	X( :height ),
	GroupBy(:sex),
	By( :age ), 
	FitLine(1)
);

 

Vince Faller - Predictum

Re: JSL Bivariate analysis with "by"-argument, group-by + fit as loop (?)

I'm almost ashamed of my question.... I have no longer seen the forest for the trees.

 

 

 

Recommended Articles