Residuos estudiados externamente¡Hola a todos!
Tengo un cliente al que le gustaría acceder a los residuos externamente estudiados utilizados para el gráfico de residuos estudiados en la Regresión de mínimos cuadrados. ¿Alguien tiene una manera de calcular eso fuera de la plataforma o sabe cómo llegar a esos valores?
Mejor,
METRO
Re: Residuos estudiados externamenteMe parece que las columnas Guardar> residuales estudiantiles son los valores que se trazan en ese gráfico.
Ledi
Re: Residuos estudiados externamenteYo también lo pensé, pero en los documentos dicen que son diferentes ( https://www.jmp.com/support/help/14-2/row-diagnostics.shtml )
METRO
Re: Residuos estudiados externamenteNo miré ninguno de los números, pero siempre puede obtener los valores directamente del marcador seg en el informe:
NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
// Fit Model
fm = dt << Fit Model(
Y( :height ),
Effects( :weight ),
Personality( "Standard Least Squares" ),
Emphasis( "Effect Leverage" ),
Run(
:height << {Summary of Fit( 0 ), Analysis of Variance( 0 ),
Parameter Estimates( 0 ), Effect Tests( 0 ), Effect Details( 0 ),
Lack of Fit( 0 ), Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ),
Plot Residual by Predicted( 1 ), Plot Studentized Residuals( 1 ),
Plot Effect Leverage( 1 ), Plot Residual by Normal Quantiles( 0 ),
Box Cox Y Transformation( 0 )}
),
SendToReport(
Dispatch(
{"Response height", "Whole Model"},
"Regression Plot",
OutlineBox,
{Close( 1 )}
),
Dispatch(
{"Response height", "Whole Model"},
"Actual by Predicted Plot",
OutlineBox,
{Close( 1 )}
)
)
);
// Get values directly from the marker seg . . .
fmRep = Report(fm);
frame = fmRep[FrameBox(4)];
mySeg = (frame << Find Seg( Marker Seg( 1 ) ));
xVals = mySeg << Get X Values;
yVals = mySeg << Get Y Values;
dt2 = asTable(xVals||yVals, << columnNames({"Row Number", "Studentized Residual"}));
dt2 << setName("Residuals");Re: Residuos estudiados externamenteEso es interesante. Intenté hacer clic derecho y seleccionar Personalizar en el gráfico para ver qué podría estar disponible. No hay nada que pueda usar, así que no pensé en los segmentos.
Re: Residuos estudiados externamenteFWIW, este método nunca me ha fallado (todavía. . . )
Re: Residuos estudiados externamente¡Increíble! Gracias, @ian_jmp !
Eso los tiene!
Además, estaba desconcertando esta última noche y me topé con una ecuación que convertirá los residuos estudiantiles en los residuos estudiados externamente. Solo necesita proporcionar el número de factores en el modelo. La ecuación está fuera de la regresión lineal aplicada de Weisburg. está en la página 216 de la 4ta edición. Agregué un script al final de su script para que todo esté en un solo lugar.
Mejor,
METRO
</CODE></P>
<PRE><CODE class=" language-jsl">Names Default To Here( 1 );
Clear Log();
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
// Fit Model
fm = dt << Fit Model(
Y( :height ),
Effects( :weight ),
Personality( "Standard Least Squares" ),
Emphasis( "Effect Leverage" ),
Run(
:height << {Summary of Fit( 0 ), Analysis of Variance( 0 ), Parameter Estimates( 0 ), Effect Tests( 0 ), Effect Details( 0 ),
Lack of Fit( 0 ), Scaled Estimates( 0 ), Plot Actual by Predicted( 1 ), Plot Residual by Predicted( 1 ),
Plot Studentized Residuals( 1 ), Plot Effect Leverage( 1 ), Plot Residual by Normal Quantiles( 0 ),
Box Cox Y Transformation( 0 )}
),
SendToReport(
Dispatch( {"Response height", "Whole Model"}, "Regression Plot", OutlineBox, {Close( 1 )} ),
Dispatch( {"Response height", "Whole Model"}, "Actual by Predicted Plot", OutlineBox, {Close( 1 )} )
)
);
/*METHOD 1
Pull Externally Studentized Residuals from the plot */
// Grab the report object
fmRep = Report( fm );
// Grab the ESR plot frame box
frame = fmRep[FrameBox( 4 )];
// Grab the marker segment in the frame box and pull the values
mySeg = (frame << Find Seg( Marker Seg( 1 ) ));
yVals = mySeg << Get Y Values;
/*METHOD 2
Convert Studentized Residuals to Externally Studentized Residuals (Applied Linear Regression, 4th Ed, 2014 - pg 216)
note the denominator removes one df for the intercept so p should be the df from the model ANOVA*/
// define the total number of terms in the model from the model ANOVA
p = 1;
//export the studentized residuals to the data table and gather table information
fm << Studentized Residuals;
r = Column( N Cols() );
n = N Rows( dt );
// create a blank matrix for the values
ESR = [];
// loop through the residuals matrix (last column in the dt) and calculate the ESR.
For( i = 1, i <= n, i++,
// calculation per reference above
k = r[i] * Sqrt( (n - p - 2) / (n - p - 1 - (r[i] ^ 2)) );
// insert the ESR value into the matrix
ESR = V Concat( ESR, k );
);
// create a new column in the data table with the values (from both methods and method 2 as a formula column)
dt << New Column( "Externally Studentized Residuals (From Report)", Set Values( yVals ) );
dt << New Column( "Externally Studentized Residuals", Set Values( ESR ) );
dt << New Column( "Externally Studentized Residuals (Formula)",
Formula(
Parameter(
{p = 1},
:Studentized Resid height * Sqrt( (N Rows() - p - 2) / (N Rows() - p - 1 - :Studentized Resid height ^ 2) )
)
)
);