cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
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