Choose Language Hide Translation Bar
Highlighted
vince_faller
Super User

dynamic model effects (without string parsing)

I'm trying to create a model of nested items based on user selections where each item is nested in the item before it.  But the effects for fit model have some odd characteristics and when I try to do it dynamically I usually get invalid matrix tokens.  I'm able to do make it work with string parsing but that seems cludgey.  Is there any functional way of calling a column nested (or crossed for that matter)?

 

Names default to here(1);
dt = open("$SAMPLE_DATA\Big Class.jmp");

cols = {"sex", "age"}; //I want each column to be nested into everything before it
cols = {"sex", "age", "name"}; // either fm = Fit Model( Y( :height ), Effects( :age[:sex], :sex ), //how do I do this dynamically Personality( "Standard Least Squares" ), Emphasis( "Effect Leverage" ), Run( :height << {Summary of Fit( 1 ), Analysis of Variance( 1 ), Parameter Estimates( 1 ), Lack of Fit( 0 ), 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 )} ) );
Vince Faller - Predictum
2 REPLIES 2
Highlighted
ms
Super User ms
Super User

Re: dynamic model effects (without string parsing)

Here's a start. To generalize for handling any number (>2) of effect variables requires more work.

 

Names Default To Here(1);
dt = Open("$SAMPLE_DATA\Big Class.jmp");

cols = {"sex", "age"}; 

//Model expr
fme = Expr(
    fm = Fit Model(Y(:height), X, Run())
);
//Effects expr
e = Expr(Effects(a[b], b));
Substitute Into(e, Expr(a), cols[2], Expr(b), cols[1]);

// Edit and eval model expr
Substitute Into(fme, Expr(X), Name Expr(e));
fme;

 

Highlighted
vince_faller
Super User

Re: dynamic model effects (without string parsing)

Yeah it has to be any number of variables.
Vince Faller - Predictum
Article Labels

    There are no labels assigned to this post.