Para bucle para ajuste mínimo cuadradoHola,
Intento obtener el gráfico de contorno del modelo de ajuste de mínimos cuadrados. Entonces, genero el ciclo for para poder obtener el modelo variando uno de los factores.
El problema es que, después de ejecutar el script, todos los gráficos muestran el mismo factor (se supone que varía el ID de Boule). Mostrará el último ID de Boule en todas las pestañas que generé.
names default to here (1);
dt = current data table ();
listID = {"108400", "108610", "109105", "109350", "109838", "109900", "109903", "109904",
"110397", "110422", "110423", "110939", "111167", "111206", "111309", "111704",
"112505", "113023", "113045", "113227", "113344", "113504", "115983", "116118",
"116489", "116490", "116534", "116609", "119687", "119849", "119852", "120478",
"120856", "121030", "121117", "121640"} ;
nw = new window ("Contour", tb = tab box(),my vlb = v list box());
for (i = 1, i<= n items (listID), i++,
tb << add (listID[i], my vlb = v list box());
my vlb<< append(obj = Fit Model(
Y( :Center_Median_BAPL ),
Effects(
:PLMedian & RS,
:Boule_Position & RS,
:Boule_Position * :Boule_Position,
:Boule_ID
),
Personality( "Standard Least Squares" ),
Emphasis( "Effect Leverage" ),
Run(
Profiler(
1,
Confidence Intervals( 1 ),
Term Value(
PLMedian( 925.7, Min( 908 ), Lock( 0 ), Show( 1 ) ),
Boule_Position( 0.82, Lock( 0 ), Show( 1 ) ),
Boule_ID( listID[i], Lock( 0 ), Show( 1 ) )
),
Simulator(
1,
Factors(
PLMedian << Fixed( 925.7 ),
Boule_Position << Fixed( 0.82 )
),
Responses( Center_Median_BAPL << No Noise )
),
Simulator( 0 )
),
Contour Profiler(
1,
Term Value(
PLMedian( 925.7, Min( 910 ), Max( 925 ), Lock( 0 ), Show( 1 ) ),
Boule_Position( 0.82, Lock( 0 ), Show( 1 ) ),
Boule_ID( listID[i], Lock( 0 ), Show( 1 ) )
),
Simulator(
1,
Factors(
PLMedian << Fixed( 925.7 ),
Boule_Position << Fixed( 0.82 )
),
Responses( Center_Median_BAPL << No Noise )
),
Simulator( 0 ),
Contour Value(
Center_Median_BAPL(
903.5,
Lo Limit( 901 ),
Hi Limit( 905 ),
Min( 893.5 ),
Max( 913.5 )
)
),
Grid Density( "40 x 40" ),
Contour Grid( 900, 910, 1, Center_Median_BAPL ),
Horizontal Factor( :Boule_Position ),
Vertical Factor( :PLMedian )
),
:Center_Median_BAPL << {Summary of Fit( 0 ), Analysis of Variance( 0),
Parameter Estimates( 0 ), Scaled Estimates( 0 ), EffectSummary(0),Lack Of Fit (0), Effect Tests(0), Prediction Profiler (0),
Plot Actual by Predicted( 0 ), Plot Regression( 0 ),
Plot Residual by Predicted( 0 ), Plot Studentized Residuals(0 ),
Plot Effect Leverage( 0 ), Plot Residual by Normal Quantiles( 0 ),
Box Cox Y Transformation( 0 ), Show VIF( 0)}
),
Local Data Filter(
Add Filter(
columns( :Boule_Position ),
Where( :Boule_Position >= 0.5992 & :Boule_Position <= 0.82 )
)
),
SendToReport(
Dispatch(
{"Response Center_Median_BAPL", "Contour Profiler"},
"1",
ScaleBox,
{Min( 0.5992 ), Max( 0.82 ), Inc( 0.02 ), Minor Ticks( 0 ),
Label Row( Show Major Grid( 1 ) )}
),
Dispatch(
{"Response Center_Median_BAPL", "Contour Profiler"},
"2",
ScaleBox,
{Min( 908 ), Max( 925 ), Inc( 1 ), Minor Ticks( 0 ),
Label Row( Show Major Grid( 1 ) )}
),
Dispatch(
{"Response Center_Median_BAPL", "Contour Profiler"},
"Contour Profiler Frame",
FrameBox,
{Frame Size( 513, 467 ), DispatchSeg(
Contour Seg( 4 ),
{Line Color( "None" ), Fill Color( {212, 73, 88} )}
)}
)
)
);
)
);
ScriptingRe: For loop for fit mínimo cuadradoCreo que lo que está sucediendo es que todo el código de su plataforma se agrega a su V List Box () antes de que se ejecute, y cuando se ejecuta, todos los valores de la variable i son iguales, por lo que he modificado el código para sustituir en el valor exacto de la variable, antes de que tenga lugar la adición.
Pruébelo y vea si ayuda ... No pude probar el código ya que no tengo su tabla de datos con todos los detalles para el análisis.
Names Default To Here( 1 );
dt = Current Data Table();
listID = {"108400", "108610", "109105", "109350", "109838", "109900", "109903", "109904", "110397", "110422", "110423", "110939", "111167", "111206",
"111309", "111704", "112505", "113023", "113045", "113227", "113344", "113504", "115983", "116118", "116489", "116490", "116534", "116609", "119687",
"119849", "119852", "120478", "120856", "121030", "121117", "121640"};
nw = New Window( "Contour", tb = Tab Box(), my vlb = V List Box() );
For( i = 1, i <= N Items( listID ), i++,
tb << Add( listID[i], my vlb = V List Box() );
Eval(
Substitute(
Expr(
my vlb << append(
obj = Fit Model(
Y( :Center_Median_BAPL ),
Effects( :PLMedian & RS, :Boule_Position & RS, :Boule_Position * :Boule_Position, :Boule_ID ),
Personality( "Standard Least Squares" ),
Emphasis( "Effect Leverage" ),
Run(
Profiler(
1,
Confidence Intervals( 1 ),
Term Value(
PLMedian( 925.7, Min( 908 ), Lock( 0 ), Show( 1 ) ),
Boule_Position( 0.82, Lock( 0 ), Show( 1 ) ),
Boule_ID( __listID__, Lock( 0 ), Show( 1 ) )
),
Simulator(
1,
Factors(
PLMedian << Fixed( 925.7 ),
Boule_Position << Fixed( 0.82 )
),
Responses( Center_Median_BAPL << No Noise )
),
Simulator( 0 )
),
Contour Profiler(
1,
Term Value(
PLMedian( 925.7, Min( 910 ), Max( 925 ), Lock( 0 ), Show( 1 ) ),
Boule_Position( 0.82, Lock( 0 ), Show( 1 ) ),
Boule_ID( __listID__, Lock( 0 ), Show( 1 ) )
),
Simulator(
1,
Factors(
PLMedian << Fixed( 925.7 ),
Boule_Position << Fixed( 0.82 )
),
Responses( Center_Median_BAPL << No Noise )
),
Simulator( 0 ),
Contour Value( Center_Median_BAPL( 903.5, Lo Limit( 901 ), Hi Limit( 905 ), Min( 893.5 ), Max( 913.5 ) ) ),
Grid Density( "40 x 40" ),
Contour Grid( 900, 910, 1, Center_Median_BAPL ),
Horizontal Factor( :Boule_Position ),
Vertical Factor( :PLMedian )
),
:Center_Median_BAPL << {Summary of Fit( 0 ), Analysis of Variance( 0 ), Parameter Estimates( 0 ),
Scaled Estimates( 0 ), EffectSummary( 0 ), Lack Of Fit( 0 ), Effect Tests( 0 ), Prediction Profiler( 0 ),
Plot Actual by Predicted( 0 ), Plot Regression( 0 ), Plot Residual by Predicted( 0 ), Plot Studentized Residuals( 0 ),
Plot Effect Leverage( 0 ), Plot Residual by Normal Quantiles( 0 ), Box Cox Y Transformation( 0 ), Show VIF( 0 )}
),
Local Data Filter(
Add Filter( columns( :Boule_Position ), Where( :Boule_Position >= 0.5992 & :Boule_Position <= 0.82 ) )
),
SendToReport(
Dispatch(
{"Response Center_Median_BAPL", "Contour Profiler"},
"1",
ScaleBox,
{Min( 0.5992 ), Max( 0.82 ), Inc( 0.02 ), Minor Ticks( 0 ), Label Row( Show Major Grid( 1 ) )}
),
Dispatch(
{"Response Center_Median_BAPL", "Contour Profiler"},
"2",
ScaleBox,
{Min( 908 ), Max( 925 ), Inc( 1 ), Minor Ticks( 0 ), Label Row( Show Major Grid( 1 ) )}
),
Dispatch(
{"Response Center_Median_BAPL", "Contour Profiler"},
"Contour Profiler Frame",
FrameBox,
{Frame Size( 513, 467 ), DispatchSeg( Contour Seg( 4 ), {Line Color( "None" ), Fill Color( {212, 73, 88} )} )}
)
)
)
)
),
Expr( __ListID__ ), ListID[i]
)
);
);