こんにちは。
これがそのスクリプトです。 よろしく、 イヴ
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>