Nuclear Whiskers
Nuclear Whiskers

Reputation: 71

Iterate through variables in a regression in SAS/JMP

I'm trying to take a set of independent variables and test if they are (statistically significantly) differently-correlated to two groups of data.

I've been advised that the way to do this in JMP is to make a series of linear regressions like the following,

result = group + varA + group*varA

and then examine the significance of the interaction effect, e.g., the "Prob > F" column in this "Country*Displacement" example: https://i.sstatic.net/EcCdd.png (I don't have the reputation to post an image.)

Now, I need to be able to switch out one of these variables; that is, for a list of ~350 variables, say varA, varB, etc., I need to run the following regressions,

result = group + varA + group*varA
result = group + varB + group*varB
result = group + varC + group*varC
...

and get the significance of that interaction effect. Previous attempts to scripting have resulted in ~350 results windows, or ~350 model dialogs . . . any advice would be appreciated.

Edit:

For example, using the Airline Delays JMP sample data set, this is the result from one of the steps: https://i.sstatic.net/HVFL8.png. I need to extract the significance of the interaction effect (the 0.1397 under Effect Tests) for each of a set of variables; for example, interchanging the "Distance" variable with "Elapsed Time". But I need to interchange this variable for each in a set of ~350.

Upvotes: 1

Views: 236

Answers (1)

Faller
Faller

Reputation: 1698

Assuming you know how to for through these values. This will get you the effect P Values.

fit = Fit Model(
    Y( :Arrival Delay ),
    Effects( :Distance, :Day of Week, :Distance * :Day of Week ),
    Personality( Standard Least Squares ),
    Emphasis( Minimal Report ),
    Run(
        :Arrival Delay << {Lack of Fit( 0 ), Plot Actual by Predicted( 0 ),
        Plot Residual by Predicted( 0 ), Plot Effect Leverage( 0 )}
    )
);

hash = associative array(fit<<Get Effect Names, fit<<Get Effect PValues);

value = hash["Distance*Day of Week"];

then just close fit << Close window; and move on to the next parameter.

Upvotes: 0

Related Questions