Choose Language Hide Translation Bar
Highlighted
vince_faller
Super User

Getting Prediction Formula from Parameter Estimates

Don't know if this is SAS IP or not, but if not does anyone have a function for turning parameter estimates (for any data type/modeling type/model), into the prediction formula JMP uses.  
I can't use the normal "Get Prediction Formula" because ... reasons.  

 

I'd like to do something like this. The type of model doesn't matter too much to me. But if it does for the calculation,  let's start simple. 

Names Default to Here (1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
dt << Clear Select();
r = dt << Select Rows( 28::40 );
r << Hide and Exclude;
dt << Clear Select();
dt:sex[[3, 6, 9, 12, 27]] = "G";

fm = dt << Fit Model(
	Y( :height ),
	Effects( :age[:sex], :sex, :weight, :sex * :weight, :age * :weight[:sex] ),
	Personality( "Generalized Regression" ),
	Generalized Distribution( "Normal" ),
	Run( Fit( Estimation Method( Lasso ), Validation Method( AICc ) ) )
);
pred = fm << (fit[1] << Get Prediction Formula);

// what I want
prediction_from_estimates = function({fm}, 
	{DEFAULT LOCAL}, 
	olb = report(fm)[OutlineBox("Parameter Estimates?")];
	terms = olb[StringColBox("Term")] << Get;
	est = olb[NumberColBox("Estimate")] << Get;
	
	// do some stuff
	return(prediction_formula)
);

// and I'd like it to be able to do 
other_pred = prediction_from_estimates(fm);
nameexpr(pred) == nameexpr(other_pred); // true

I'd also take any references to read up on.  

 

 

Vince Faller - Predictum
2 REPLIES 2
Highlighted
MathStatChem
Level VI

Re: Getting Prediction Formula from Parameter Estimates

Have you tried 

 

fd= fm << publish prediction formula;

formula_function= fd << copy formula as function;
formula_transform = fd << copy formula as transform;
formula_sas = fd << generate sas code(No Editor);
formula_python = fd << generate python code(No Editor);
formula_c= fd << generate C Code(No Editor);
formula_java = fd << generate JavaScript Code(No Editor);

?

Highlighted
vince_faller
Super User

Re: Getting Prediction Formula from Parameter Estimates

It's not that I can't use the native values.  It's that I have a table of parameter values from a simulate table and I'm trying to average them and create a prediction formula based on that.  I could save the prediction formula and then do a substitute, but that seems very prone to error.  

Vince Faller - Predictum
Article Labels

    There are no labels assigned to this post.