cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-184128%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E3%82%B3%E3%83%83%E3%82%AF%E3%82%B9%E3%82%B9%E3%83%8D%E3%83%ABR2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-184128%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF%E3%80%81%E3%81%BF%E3%82%93%E3%81%AA%E3%80%81%3C%2FP%3E%0A%3CP%3E%E3%83%AD%E3%82%B8%E3%82%B9%E3%83%86%E3%82%A3%E3%83%83%E3%82%AF%E5%9B%9E%E5%B8%B0%E3%82%92%E6%8E%A8%E5%AE%9A%E3%81%97%E3%81%A6%E3%81%84%E3%81%BE%E3%81%99%E3%80%82%3CSPAN%20style%3D%22color%3A%20%23000000%3B%22%3E%3CSPAN%20style%3D%22font-family%3A%20Times%20New%20Roman%3B%22%3E%3CSPAN%20style%3D%22font-size%3A%20medium%3B%22%3E%E3%82%B3%E3%83%83%E3%82%AF%E3%82%B9%E3%82%B9%E3%83%8D%E3%83%AB%3CI%3E%20R%20%3C%2FI%3E%3CSUP%3E%202%20%3C%2FSUP%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%E3%81%9D%E3%82%8C%E3%81%AF%E3%81%A9%E3%81%93%E3%81%8B%E3%81%AB%E9%9A%A0%E3%82%8C%E3%81%A6%E3%81%84%E3%82%8B%E3%81%AE%E3%81%A7%E3%81%99%E3%81%8B%E3%81%9D%E3%82%8C%E3%81%A8%E3%82%82%E7%A7%81%E3%81%AF%E3%81%9D%E3%82%8C%E3%82%92%E6%89%8B%E5%8B%95%E3%81%A7%E8%A8%88%E7%AE%97%E3%81%99%E3%82%8B%E5%BF%85%E8%A6%81%E3%81%8C%E3%81%82%E3%82%8A%E3%81%BE%E3%81%99%E3%81%8B%EF%BC%9F%E8%AA%B0%E3%81%8B%E4%BE%BF%E5%88%A9%E3%81%AA%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%82%92%E6%8C%81%E3%81%A3%E3%81%A6%E3%81%84%E3%81%BE%E3%81%99%E3%81%8B%EF%BC%9F%3C%2FP%3E%0A%3CP%3EJMP%E3%81%AF%E3%83%87%E3%83%95%E3%82%A9%E3%83%AB%E3%83%88%E3%81%A7McFadden%E3%81%A8Nagelkerke%E3%81%AE%E3%81%BF%E3%82%92%E7%A7%81%E3%81%AB%E4%B8%8E%E3%81%88%E3%81%BE%E3%81%99%E3%80%82%3C%2FP%3E%0A%3CP%3E%E3%81%93%E3%82%8C%E3%82%89%E3%81%AF%E7%A7%81%E3%81%8C%E3%83%95%E3%82%A9%E3%83%AD%E3%83%BC%E3%81%97%E3%81%A6%E3%81%84%E3%82%8B%E5%AE%9A%E7%BE%A9%E3%81%A7%E3%81%99%E3%80%82%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fstats.idre.ucla.edu%2Fother%2Fmult-pkg%2Ffaq%2Fgeneral%2Ffaq-what-are-pseudo-r-squareds%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fstats.idre.ucla.edu%2Fother%2Fmult-pkg%2Ffaq%2Fgeneral%2Ffaq-what-are-pseudo-r-squareds%2F%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E3%81%82%E3%82%8A%E3%81%8C%E3%81%A8%E3%81%86%E3%81%94%E3%81%96%E3%81%84%E3%81%BE%E3%81%97%E3%81%9F%EF%BC%81%3C%2FP%3E%0A%3CP%3E%E3%83%AD%E3%83%B3%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-184169%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E6%97%A5%E6%99%82%EF%BC%9A%E3%82%B3%E3%83%83%E3%82%AF%E3%82%B9%E3%82%B9%E3%83%8D%E3%83%ABR2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-184169%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E3%81%82%E3%81%AA%E3%81%9F%E3%81%AF%E3%81%82%E3%81%AA%E3%81%9F%E3%81%8C%E5%BC%95%E7%94%A8%E3%81%97%E3%81%9F%E5%BC%8F%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%A6%E5%85%A8%E4%BD%93%E3%83%A2%E3%83%87%E3%83%AB%E3%83%86%E3%82%B9%E3%83%88%E3%83%AC%E3%83%9D%E3%83%BC%E3%83%88%E3%81%AB%E7%A4%BA%E3%81%95%E3%82%8C%E3%81%9F%E7%B5%90%E6%9E%9C%E3%81%8B%E3%82%89%E3%81%9D%E3%82%8C%E3%82%92%E8%A8%88%E7%AE%97%E3%81%97%E3%81%AA%E3%81%91%E3%82%8C%E3%81%B0%E3%81%AA%E3%82%89%E3%81%AA%E3%81%84%E3%81%A7%E3%81%97%E3%82%87%E3%81%86%E3%80%82%E3%81%93%E3%81%AE%E8%A8%88%E7%AE%97%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AE%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%81%AF%E3%82%8F%E3%81%8B%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93%E3%81%8C%E3%80%81%E3%81%93%E3%81%AE%E3%82%B3%E3%83%9F%E3%83%A5%E3%83%8B%E3%83%86%E3%82%A3%E3%81%AE%5BFile%20Exchange%5D%E9%A0%98%E5%9F%9F%E3%82%92%E6%A4%9C%E7%B4%A2%E3%81%A7%E3%81%8D%E3%81%BE%E3%81%99%E3%80%82%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%81%8C%E5%BF%85%E8%A6%81%E3%81%8B%E3%81%A9%E3%81%86%E3%81%8B%E3%82%8F%E3%81%8B%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93%E3%80%82%E8%A8%88%E7%AE%97%E5%BC%8F%E3%81%AF%E3%81%A8%E3%81%A6%E3%82%82%E7%B0%A1%E5%8D%98%E3%81%A7%E3%81%99%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-184170%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E6%97%A5%E6%99%82%EF%BC%9A%E3%82%B3%E3%83%83%E3%82%AF%E3%82%B9%E3%82%B9%E3%83%8D%E3%83%ABR2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-184170%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88%E3%81%AF%E7%B5%90%E5%B1%80%E6%82%AA%E3%81%8F%E3%81%AA%E3%81%84%E3%81%A7%E3%81%99%E3%80%82%E3%81%93%E3%81%AE%E4%BE%8B%E3%81%AF%E3%81%82%E3%81%AA%E3%81%9F%E3%81%8C%E3%81%9D%E3%82%8C%E3%82%92%E3%81%99%E3%82%8B%E3%81%93%E3%81%A8%E3%81%8C%E3%81%A7%E3%81%8D%E3%82%8B1%E3%81%A4%E3%81%AE%E6%96%B9%E6%B3%95%E3%82%92%E7%A4%BA%E3%81%97%E3%81%A6%E3%81%84%E3%81%BE%E3%81%99%EF%BC%9A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20to%20Here(%201%20)%3B%0A%0A%2F%2F%20example%20case%3A%20Big%20Class%0Adt%20%3D%20Open(%20%22%24SAMPLE_DATA%2FBig%20Class.jmp%22%20)%3B%0A%0A%2F%2F%20fit%20binary%20logistic%20model%0Alr%20%3D%20dt%20%26lt%3B%26lt%3B%20Fit%20Model(%0A%20Y(%20%3Asex%20)%2C%0A%20Effects(%20%3Aage%2C%20%3Aheight%2C%20%3Aweight%20)%2C%0A%20Personality(%20%22Nominal%20Logistic%22%20)%2C%0A%20Run(%20Likelihood%20Ratio%20Tests(%201%20)%2C%20Wald%20Tests(%200%20)%20)%0A)%3B%0A%0A%2F%2F%20access%20Whole%20Model%20Test%20report%0Alr%20rep%20%3D%20(lr%20%26lt%3B%26lt%3B%20Report)%5B%22Whole%20Model%20Test%22%5D%3B%0A%0A%2F%2F%20obtain%20likelihood%20for%20reduced%20and%20full%20models%0AL%20intercept%20%3D%20Exp(%20-(lr%20rep%5BNumberColBox(1)%5D%20%26lt%3B%26lt%3B%20Get(%203%20))%20)%3B%0AL%20full%20%20%20%20%20%20%3D%20Exp(%20-(lr%20rep%5BNumberColBox(1)%5D%20%26lt%3B%26lt%3B%20Get(%202%20))%20)%3B%0AN%20%20%20%20%20%20%20%20%20%20%20%3D%20lr%20rep%5BNumberColBox(8)%5D%20%26lt%3B%26lt%3B%20Get(%201%20)%3B%0A%0A%2F%2F%20compute%20Cox-Snell%20R%20square%0Ar%20sqr%20cs%20%20%20%20%3D%201%20-%20(L%20intercept%2FL%20full)%5E(2%2FN)%3B%0A%0A%2F%2F%20copy%20original%20report%0Alabel%20%3D%20lr%20rep%5BStringColBox(2)%5D%20%26lt%3B%26lt%3B%20Insert%20Row(%202%2C%20%7B%20%22RSquare%20(C-S)%22%20%7D%20)%20%26lt%3B%26lt%3B%20Clone%20Box%3B%0Ar%20sqr%20u%20%3D%20lr%20rep%5BNumberColBox(5)%5D%20%26lt%3B%26lt%3B%20Get(%201%20)%3B%0Aaicc%20%20%20%20%3D%20lr%20rep%5BNumberColBox(6)%5D%20%26lt%3B%26lt%3B%20Get(%201%20)%3B%0Abic%20%20%20%20%20%3D%20lr%20rep%5BNumberColBox(7)%5D%20%26lt%3B%26lt%3B%20Get(%201%20)%3B%0A%0A%2F%2F%20replace%20with%20new%20report%0Alr%20rep%5BTablebox(2)%5D%20%26lt%3B%26lt%3B%20Delete%3B%0Alr%20rep%20%26lt%3B%26lt%3B%20Append(%0A%20TableBox(%0A%20%20label%2C%0A%20%20Number%20Col%20Box(%20%22%22%2C%20%7B%20r%20sqr%20u%2C%20r%20sqr%20cs%2C%20aicc%2C%20bic%2C%20N%20%7D%20)%0A%20)%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-184171%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E6%97%A5%E6%99%82%EF%BC%9A%E3%82%B3%E3%83%83%E3%82%AF%E3%82%B9%E3%82%B9%E3%83%8D%E3%83%ABR2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-184171%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E7%A7%81%E3%81%AE%E3%81%99%E3%81%B9%E3%81%A6%E3%81%AE%E3%82%B3%E3%83%A1%E3%83%B3%E3%83%88%E3%81%8C%E6%B6%88%E3%81%88%E3%81%9F%E3%81%AE%E3%81%AF%E9%9D%A2%E7%99%BD%E3%81%84%E3%81%A7%E3%81%99%E3%81%AD%EF%BC%81%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-184172%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E6%97%A5%E6%99%82%EF%BC%9A%E3%82%B3%E3%83%83%E3%82%AF%E3%82%B9%E3%82%B9%E3%83%8D%E3%83%ABR2%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-184172%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E3%83%9E%E3%83%BC%E3%82%AF%E3%81%82%E3%82%8A%E3%81%8C%E3%81%A8%E3%81%86%E3%80%82%E5%AE%8C%E7%92%A7%E3%81%AB%E5%8B%95%E4%BD%9C%E3%81%97%E3%81%BE%E3%81%99%E3%80%82%3CBR%20%2F%3E%3CBR%20%2F%3E%E3%83%AD%E3%83%B3%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
ron_horne
Super User (Alumni)

Cox-Snell R2

Hi All,

I am estimating a logistic regression and need to get the Cox-Snell R2 is it hiding anywhere or do i have to calculate it manually? does anyone have the script handy?

JMP only gives me the McFadden and Nagelkerke by default.

these are the definitions i am following:

https://stats.idre.ucla.edu/other/mult-pkg/faq/general/faq-what-are-pseudo-r-squareds/

 

thank you!

Ron

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Cox-Snell R2

The script is not too bad after all. This example shows one way that you could do it:

 

Names Default to Here( 1 );

// example case: Big Class
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

// fit binary logistic model
lr = dt << Fit Model(
	Y( :sex ),
	Effects( :age, :height, :weight ),
	Personality( "Nominal Logistic" ),
	Run( Likelihood Ratio Tests( 1 ), Wald Tests( 0 ) )
);

// access Whole Model Test report
lr rep = (lr << Report)["Whole Model Test"];

// obtain likelihood for reduced and full models
L intercept = Exp( -(lr rep[NumberColBox(1)] << Get( 3 )) );
L full      = Exp( -(lr rep[NumberColBox(1)] << Get( 2 )) );
N           = lr rep[NumberColBox(8)] << Get( 1 );

// compute Cox-Snell R square
r sqr cs    = 1 - (L intercept/L full)^(2/N);

// copy original report
label = lr rep[StringColBox(2)] << Insert Row( 2, { "RSquare (C-S)" } ) << Clone Box;
r sqr u = lr rep[NumberColBox(5)] << Get( 1 );
aicc    = lr rep[NumberColBox(6)] << Get( 1 );
bic     = lr rep[NumberColBox(7)] << Get( 1 );

// replace with new report
lr rep[Tablebox(2)] << Delete;
lr rep << Append(
	TableBox(
		label,
		Number Col Box( "", { r sqr u, r sqr cs, aicc, bic, N } )
	)
);

View solution in original post

3 REPLIES 3

Re: Cox-Snell R2

You will have to calculate it from the results presented in the Whole Model Test report using the formula that you cited. I don't know of a script for this calculation, but you could search the File Exchange area of this Community. I don't know if a script is necessary. The formula is pretty simple.

Re: Cox-Snell R2

The script is not too bad after all. This example shows one way that you could do it:

 

Names Default to Here( 1 );

// example case: Big Class
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

// fit binary logistic model
lr = dt << Fit Model(
	Y( :sex ),
	Effects( :age, :height, :weight ),
	Personality( "Nominal Logistic" ),
	Run( Likelihood Ratio Tests( 1 ), Wald Tests( 0 ) )
);

// access Whole Model Test report
lr rep = (lr << Report)["Whole Model Test"];

// obtain likelihood for reduced and full models
L intercept = Exp( -(lr rep[NumberColBox(1)] << Get( 3 )) );
L full      = Exp( -(lr rep[NumberColBox(1)] << Get( 2 )) );
N           = lr rep[NumberColBox(8)] << Get( 1 );

// compute Cox-Snell R square
r sqr cs    = 1 - (L intercept/L full)^(2/N);

// copy original report
label = lr rep[StringColBox(2)] << Insert Row( 2, { "RSquare (C-S)" } ) << Clone Box;
r sqr u = lr rep[NumberColBox(5)] << Get( 1 );
aicc    = lr rep[NumberColBox(6)] << Get( 1 );
bic     = lr rep[NumberColBox(7)] << Get( 1 );

// replace with new report
lr rep[Tablebox(2)] << Delete;
lr rep << Append(
	TableBox(
		label,
		Number Col Box( "", { r sqr u, r sqr cs, aicc, bic, N } )
	)
);
ron_horne
Super User (Alumni)

Re: Cox-Snell R2

Thank you Mark. works perfect.

Ron

Recommended Articles