cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Choose Language Hide Translation Bar

User Input List for Regression Report with Interactions

I have an input box where users can select columns to be run in a regression report. This part works great. I then insert the list of columns into a list. I would like to take the list of columns and make different interactions that can be inserted into a regression report. Specifically, I am interested in slightly more complicated interactions (i.e. Column 1 * Column 2 ^2) When I try to put anything but just the generic list in the regression report, it doesn’t run the report. What do I do to create these interactions in the report?

 

The user input list readout looks like this: {"Column 1", "Column 2", "Column 3"}

 

 

 

platform = dt << Fit Model(
    Y( :Char( variable ) ),
    Effects(
           // What should go here?????
          ),
    Personality( "Generalized Regression" ),
    Generalized Distribution( "Normal" ),
    Run(
        Fit(
            Estimation Method( Two Stage Forward Selection ),
            Validation Method( AICc ),
            Enforce Heredity
        )
    )
);

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: User Input List for Regression Report with Interactions

Here is one way to handle this

names default to here(1);
dt=data table("big class");
variable = "Age";
// If you build your list as expressions the code below works
effectsList = {height, weight, weight * height};

Fit Model(
	Y( :char(variable) ),
	Effects( eval(effectsList) ),
	Personality( "Standard Least Squares" ),
	Emphasis( "Effect Leverage" ),
	Run(
		:char(variable) << {Summary of Fit( 1 ), Analysis of Variance( 1 ),
		Parameter Estimates( 1 ), Scaled Estimates( 0 ),
		Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
		Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 0 ),
		Plot Effect Leverage( 1 ), Plot Residual by Normal Quantiles( 0 ),
		Box Cox Y Transformation( 0 )}
	)
);

/*
// If you build your list using strings
effectsList = {"height", "weight", "weight * height"};
// You can convert the elements back to expressions by
// using the Parse() function
For( i = 1, i <= N Items( effectsList ), i++,
	effectsList[i] = Parse( effectsList[i] );
);
Jim

View solution in original post

5 REPLIES 5
Ressel
Level VI

Re: User Input List for Regression Report with Interactions

The Scripting Index has an example for Effects - copied in below. 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Dogs.jmp" );
obj = Fit Model(
	Y( :LogHist0, :LogHist1, :LogHist3, :LogHist5 ),
	Effects( :drug, :dep1, :drug * :dep1 ),
	Personality( Manova ),
	Run( Response Function( Sum ) )
);
txnelson
Super User

Re: User Input List for Regression Report with Interactions

Here is one way to handle this

names default to here(1);
dt=data table("big class");
variable = "Age";
// If you build your list as expressions the code below works
effectsList = {height, weight, weight * height};

Fit Model(
	Y( :char(variable) ),
	Effects( eval(effectsList) ),
	Personality( "Standard Least Squares" ),
	Emphasis( "Effect Leverage" ),
	Run(
		:char(variable) << {Summary of Fit( 1 ), Analysis of Variance( 1 ),
		Parameter Estimates( 1 ), Scaled Estimates( 0 ),
		Plot Actual by Predicted( 1 ), Plot Regression( 0 ),
		Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 0 ),
		Plot Effect Leverage( 1 ), Plot Residual by Normal Quantiles( 0 ),
		Box Cox Y Transformation( 0 )}
	)
);

/*
// If you build your list using strings
effectsList = {"height", "weight", "weight * height"};
// You can convert the elements back to expressions by
// using the Parse() function
For( i = 1, i <= N Items( effectsList ), i++,
	effectsList[i] = Parse( effectsList[i] );
);
Jim

Re: User Input List for Regression Report with Interactions

Here is another way using expressions. There are more solutions based on expressions than just this example.

 

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Dogs.jmp" );

predictor = { :drug, :dep1 };
n = N Items( predictor );

effectExpr = Expr( Effects() );
For( x1 = 1, x1 < n, x1++,
	Insert Into( effectExpr, predictor[x1] );
	For( x2 = 2, x2 <= n, x2++,
		Eval(
			Substitute(
				Expr( Insert Into( effectExpr, Expr( xxx1 * xxx2 ) ) ),
				Expr( xxx1 ), predictor[x1],
				Expr( xxx2 ), predictor[x2]
			)
		)
	);
);
Show( Name Expr( effectExpr) );

Eval(
	Substitute(
		Expr(
			obj = dt << Fit Model(
				Y( :LogHist0, :LogHist1, :LogHist3, :LogHist5 ),
				eee,
				Personality( Manova ),
				Run( Response Function( Sum ) )
			);
		),
		Expr( eee ), Name Expr( effectExpr )
	)
);

Re: User Input List for Regression Report with Interactions

This solution seems like it could be really flexible. I am unfamiliar with expressions, so please bear with me. 

 

I tried to have both the basic interactions (a * b) and more complex interactions (a * b^2) work at the same time and I can't seem to figure out how to make it work. Can you provide a little more guidance on this?

Re: User Input List for Regression Report with Interactions

JMP does not represent a higher order term in a linear predictor that way (e.g., X^2). It represents it as X*X, so your term would be A * B * B.