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

Bivariate Profiler Remembered Settings Dynamic Term Value Variables

Hi everyone, 

 

I'd really appreciate some help with some scripting.

 

I'm working on a bivariate fit script that takes two columns from a column dialog. I want to load a profiler that has some remembered settings already loaded. The issue I'm having is that I can't find the right way to reference/substitute the column name within the term value of the profiler. In the example code below I've left the hardcoded references to the column and the script works but I need the script to be flexible with different column names. I've found an user with a similar issue but I've been unsuccessful adapting the solution that worked for them to my example, see Profiler: Using variables in term value script not working. My experience to date with writing expressions and substituting terms has been limited to formula columns so this problem has been a bit much for me.

 

Any help correcting this issue would be greatly appreciated. 

 

Kind regards, 

Cathal

 

New Table( "Example",
	Add Rows( 10 ),
	New Column( "X",
		Numeric,
		"Continuous",
		Format( "Best", 15 ),
		Set Values( [20, 40, 60, 80, 100, 120, 140, 160, 180, 200] )
	),
	New Column( "Y",
		Numeric,
		"Continuous",
		Format( "Best", 15 ),
		Set Values( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] )
	)
); 

// Open dialog to select columns
dlg = Column Dialog(
    colX = Col List( "X",
        Min Col( 1 ), 
        Max Col( 1 ),
    ),
    colY = Col List( "Y",
        Min Col( 1 ), 
        Max Col( 1 ),
    ),
);

// Store list of selected columns
Eval List( Remove( dlg, -1 ) );

// Launch platform: Bivariate
report = Bivariate( 
	Y( colY[1] ) , 
	X( colX[1] ), 
		Fit Polynomial(	1,
		{Profiler(
			1,
			Confidence Intervals( 1 ),	
			Term Value( "X"n( 30, Lock( 0 ), Show( 1 ) ) ), // Need to replace with dynamic reference
			Remember Settings( "1-Month", Differences Report( 0 ) ),
			Term Value( "X"n( 60, Lock( 0 ), Show( 1 ) ) ), // Need to replace with dynamic reference
			Remember Settings( "2-Months" ),
			Term Value( "X"n( 90, Lock( 0 ), Show( 1 ) ) ), // Need to replace with dynamic reference
			Remember Settings( "3-Months", Differences Report( 1 ) ),
			Term Value( "X"n( 90, Lock( 0 ), Show( 1 ) ) ) // Need to replace with dynamic reference
		)}
	)
);
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Bivariate Profiler Remembered Settings Dynamic Term Value Variables

I think something like this might work

Names Default To Here(1);

dt = New Table("Example",
	Add Rows(10),
	New Column("X",
		Numeric,
		"Continuous",
		Format("Best", 15),
		Set Values([20, 40, 60, 80, 100, 120, 140, 160, 180, 200])
	),
	New Column("Y",
		Numeric,
		"Continuous",
		Format("Best", 15),
		Set Values([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
	)
); 

dlg = Column Dialog(
	colX = Col List("X", Min Col(1), Max Col(1), ),
	colY = Col List("Y", Min Col(1), Max Col(1), ),

);
Eval List(Remove(dlg, -1));

report = Eval(Substitute(
	Expr(dt << Bivariate(
		Y(colY[1]),
		X(colX[1]),
		Fit Polynomial(
			1,
			{Profiler(
				1,
				Confidence Intervals(1),
				Term Value(_x_(30, Lock(0), Show(1))),
				Remember Settings("1-Month", Differences Report(0)),
				Term Value(_x_(60, Lock(0), Show(1))),
				Remember Settings("2-Months"),
				Term Value(_x_(90, Lock(0), Show(1))),
				Remember Settings("3-Months", Differences Report(1)),
				Term Value(_x_(90, Lock(0), Show(1)))
			)}
		)
	)),
	Expr(_x_), Name Expr(AsColumn(dt, colX[1]));
));
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Bivariate Profiler Remembered Settings Dynamic Term Value Variables

I think something like this might work

Names Default To Here(1);

dt = New Table("Example",
	Add Rows(10),
	New Column("X",
		Numeric,
		"Continuous",
		Format("Best", 15),
		Set Values([20, 40, 60, 80, 100, 120, 140, 160, 180, 200])
	),
	New Column("Y",
		Numeric,
		"Continuous",
		Format("Best", 15),
		Set Values([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
	)
); 

dlg = Column Dialog(
	colX = Col List("X", Min Col(1), Max Col(1), ),
	colY = Col List("Y", Min Col(1), Max Col(1), ),

);
Eval List(Remove(dlg, -1));

report = Eval(Substitute(
	Expr(dt << Bivariate(
		Y(colY[1]),
		X(colX[1]),
		Fit Polynomial(
			1,
			{Profiler(
				1,
				Confidence Intervals(1),
				Term Value(_x_(30, Lock(0), Show(1))),
				Remember Settings("1-Month", Differences Report(0)),
				Term Value(_x_(60, Lock(0), Show(1))),
				Remember Settings("2-Months"),
				Term Value(_x_(90, Lock(0), Show(1))),
				Remember Settings("3-Months", Differences Report(1)),
				Term Value(_x_(90, Lock(0), Show(1)))
			)}
		)
	)),
	Expr(_x_), Name Expr(AsColumn(dt, colX[1]));
));
-Jarmo
Cathal
Level I

Re: Bivariate Profiler Remembered Settings Dynamic Term Value Variables

That works perfectly. Thanks Jarmo! 

Recommended Articles