HI everyone,
I have been a little frustrated with the fact that JMP still does not have a GAM modeling platform (even if it exists in SAS for many years) so I decided to create an add-in that is based on the mgcv package in R. So to run this add-in you will need to have R v. 3.3.3 running on your computer. It basically creates a JMP dialog window with many of the options available in the R package and retrieves the essential results from R and adds some graphs and options. If you need additional features, please let me know. Here are some screen shots of the interface and results window.
Best regards, Yves



Hi Yves !
Thank you for such a prompt response!!
Indeed, it works with the script (maybe the reason is that I didn't have R 3.3 install before, now I have it). I wonder if you can recommend me something for my ordinary predictors that have a good fit as a SASH or Zero-inflated Poisson). I have been reading that using a penalized spline can be used in ordinary using a specific amount of knots (related with the number of ordinary levels).
Hello Yves Praire!
Really interesting Addin, I wonder if is compatible with JMP Pro 16.1?
I give me an error when I tried to install it.

Hi Ingrid,
Sorry I hadn't seen your post. If mccv outputs it then yes it would be easy to add it. I'll look into it.
Thanks for your interest, Yves
Hi Raewdy,
Here is the script for it. Regards, Yves
Names Default To Here( 1 );
Clear Globals();
//
// Check host and R connection
//
macsys = Host is( "Mac" );
winsys = Host is( "Windows" );
connected = R Is Connected();
R Term();
If( connected == 0,
If( macsys == 1,
Set Environment Variable( "R_HOME", "/Library/Frameworks/R.framework/Versions/Current/Resources" )
);
If( winsys == 1,
ppath = Pick Directory( "Locate the directory of your R program version 3.3.3" );
ppath=substr(ppath,2,length(ppath)-1);
part = Parse( Eval Insert( "
Set Environment Variable( \!"R_HOME\!",\!"^ppath^\!" );" ) );
Eval( part );
);
);
R Init();
connected = R Is Connected();
R Term();
If( connected == 0,
ww2 = New Window( "Warning",
Spacer Box(),
Text Box( " CANNOT ESTABLISH CONNECTION WITH R " ),
Spacer Box(),
H Center Box(
Button Box( "OK",
ww2 << close window;
)
)
);
Stop();
);
//
// CHECK R VERSION
//
R Init();
connected = R Is Connected();
If( connected == 1,
Rver = Char( R Get Version() );
If( Rver == "[3 3 3]",
,
ww1 = New Window( "Warning",
<<MODAL> 1, TAV ||= TLV );
If( Nxvar >= 1,
TAV ||= TSV,
Print( "Please select variables" )
);
nm = Loc Nonmissing( TAV );
nnm=n row(nm);
SV=TSV[nm];
LV=TLV[nm];
YV=TYV[nm];
LY = Min( YV ) * .95;
HY = Max( YV ) * 1.05;
if(nnm<NPTERMS>= HR,
HR = Abs( LR ),
LR = -HR
);
R Term();
genfit = rsq || dev || nobs;
pest = J( npterms, 1, . );
pstderr = J( npterms, 1, . );
pt = J( npterms, 1, . );
pprob = J( npterms, 1, . );
For( i = 1, i <= npterms, i++,
pest[i] = ptable[i];
pstderr[i] = ptable[i + 1 * npterms];
pt[i] = ptable[i + 2 * npterms];
pprob[i] = If( ptable[i + 3 * npterms] <= 0.0001,
0.0001,
ptable[i + 3 * npterms]
);
);
sedf = J( nxvar, 1, . );
srdf = J( nxvar, 1, . );
sf = J( nxvar, 1, . );
sprob = J( nxvar, 1, . );
For( i = 1, i <= nxvar, i++,
sedf[i] = stable[i];
srdf[i] = stable[i + nxvar * 1];
sf[i] = stable[i + 2 * nxvar];
sprob[i] = If( stable[i + 3 * nxvar] <= 0.0001,
0.0001,
stable[i + 3 * nxvar]
);
);
New Window( "GAM Model Fit",
Outline Box( Eval Insert( "Family: ^selfam^" ) ),
Outline Box( Eval Insert( "Link function: ^sellnk^" ) ),
Outline Box( "Whole Model",
{"Save predicted", New Column( "Predicted values", values( fitvalues ) ),
"Save residuals", New Column( "Residuals", values( YV - fitvalues ) )},
H List Box(
V List Box(
Outline Box( "Obs vs Pred.",
Graph Box(
X Scale( LYH, HYH ),
Y Scale( LY, HY ),
Yname( "Obs Y" ),
Xname( "Pred Y" ),
Frame Size( 250, 250 ),
Line( {LY, LY}, {HY, HY} ),
Marker( Marker State( 0 ), fitvalues, YV )
)
),
Outline Box( "Residuals vs Pred.",
Graph Box(
Y Scale( LR, HR ),
X Scale( LYH, HYH ),
Yname( "Residuals" ),
Xname( "Pred Y" ),
Frame Size( 250, 120 ),
Line( {LYH, 0}, {HYH, 0} ),
Marker( Marker State( 0 ), fitvalues, Resids )
)
)
),
Outline Box( "Smoother and Linear leverage plots", Picture Box( SmPl ) )
)
),
Outline Box( "Summary of Fit",
Table Box(
String Col Box( , {"adj. R-square", "Deviance", "Number of Obs."} ),
Number Col Box( , genfit )
)
),
Outline Box( "Parametric terms estimates",
Table Box(
String Col Box( "Term", pterms ),
Number Col Box( "Estimate", pest ),
Number Col Box( "Std Error", pstderr ),
Number Col Box( "Prob.", pprob ),
)
),
Outline Box( "Smoothed terms estimates",
Table Box(
String Col Box( "Term", sterms ),
Number Col Box( "Est. df", sedf ),
Number Col Box( "Ref df", srdf ),
Number Col Box( "F", sf ),
Number Col Box( "Prob.", sprob ),
)
)
);
If( cw == 0,
nw << close window
);
)
)
)
)
);</NPTERMS></MODAL>Dear Raewdy,
Unfortunately, this has nothing to do with the script, it is a limitation of the JMP R integration functions. Only JMP can fix that. Presumably, they will fix it in the next version of JMP... That being said, you can have multiple versions of R on your computer, including R 3.3.3.
Regards, Yves