-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UPDATE] move summary stats to separate files. AIC, AICc, BIC.
- Loading branch information
Showing
8 changed files
with
314 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* | ||
* ADJUSTED COEFFICIENT OF DETERMINATION | ||
* | ||
* | ||
* DESCRIPTION: | ||
* - Computes the adjusted coefficient of determination (adjusted R squared). | ||
* | ||
* NOTES: | ||
* [1] | ||
* | ||
* | ||
* TODO: | ||
* [1] | ||
* | ||
* | ||
* LICENSE: | ||
* MIT | ||
* | ||
* Copyright (c) 2015. Athan Reines. | ||
* | ||
* | ||
* AUTHOR: | ||
* Athan Reines. kgryte@gmail.com. 2015. | ||
* | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// MODULES // | ||
|
||
var rsq = require( './rsquared.js' ); | ||
|
||
|
||
// ADJUSTED R SQUARED // | ||
|
||
/** | ||
* FUNCTION: arsq( mss, tss, mdf, rdf ) | ||
* Computes the adjusted coefficient of determination. | ||
* | ||
* @param {Number} mss - model sum of squares | ||
* @param {Number} tss - total sum of squares | ||
* @param {Number} mdf - model degrees of freedom | ||
* @param {Number} rdf - residual degrees of freedom | ||
* @returns {Number} adjusted coefficient of determination | ||
*/ | ||
function arsq( mss, tss, mdf, rdf ) { | ||
var r2 = rsq( mss, tss ); | ||
return r2 - (1-r2)*(mdf/rdf); | ||
} // end FUNCTION arsq() | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = arsq; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* | ||
* AIC | ||
* | ||
* | ||
* DESCRIPTION: | ||
* - Computes the Akaike information criterion. | ||
* | ||
* NOTES: | ||
* [1] | ||
* | ||
* | ||
* TODO: | ||
* [1] | ||
* | ||
* | ||
* LICENSE: | ||
* MIT | ||
* | ||
* Copyright (c) 2015. Athan Reines. | ||
* | ||
* | ||
* AUTHOR: | ||
* Athan Reines. kgryte@gmail.com. 2015. | ||
* | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/** | ||
* FUNCTION: aic( ll, k ) | ||
* Computes the Akaike information criterion. | ||
* | ||
* @param {Number} ll - log likelihood | ||
* @param {Number} k - number of parameters | ||
* @returns {Number} Akaike information criterion | ||
*/ | ||
function aic( ll, k ) { | ||
return 2 * ( k - ll ); | ||
} // end FUNCTION aic() | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = aic; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* | ||
* AIC | ||
* | ||
* | ||
* DESCRIPTION: | ||
* - Computes the corrected Akaike information criterion for finite sample sizes. | ||
* | ||
* NOTES: | ||
* [1] | ||
* | ||
* | ||
* TODO: | ||
* [1] | ||
* | ||
* | ||
* LICENSE: | ||
* MIT | ||
* | ||
* Copyright (c) 2015. Athan Reines. | ||
* | ||
* | ||
* AUTHOR: | ||
* Athan Reines. kgryte@gmail.com. 2015. | ||
* | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// MODULES // | ||
|
||
var aic = require( './aic.js' ); | ||
|
||
|
||
// CORRECTED AIC // | ||
|
||
/** | ||
* FUNCTION: aicc( ll, N, k ) | ||
* Computes the corrected Akaike information criterion for finite sample sizes. | ||
* | ||
* @param {Number} ll - log likelihood | ||
* @param {Number} N - sample size | ||
* @param {Number} k - number of parameters | ||
* @returns {Number} Akaike information criterion | ||
*/ | ||
function aicc( ll, N, k ) { | ||
return aic( ll, k ) + (2*k*(k+1)) / (N-k-1); | ||
} // end FUNCTION aicc() | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = aicc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* | ||
* BIC | ||
* | ||
* | ||
* DESCRIPTION: | ||
* - Computes the Bayesian information criterion. | ||
* | ||
* NOTES: | ||
* [1] | ||
* | ||
* | ||
* TODO: | ||
* [1] | ||
* | ||
* | ||
* LICENSE: | ||
* MIT | ||
* | ||
* Copyright (c) 2015. Athan Reines. | ||
* | ||
* | ||
* AUTHOR: | ||
* Athan Reines. kgryte@gmail.com. 2015. | ||
* | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/** | ||
* FUNCTION: bic( ll, N, k ) | ||
* Computes the Bayesian information criterion. | ||
* | ||
* @param {Number} ll - log likelihood | ||
* @param {Number} N - number of observations | ||
* @param {Number} k - number of parameters | ||
* @returns {Number} Bayesian information criterion | ||
*/ | ||
function bic( ll, N, k ) { | ||
return -2*ll + k*Math.log( N ); | ||
} // end FUNCTION bic() | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = bic; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* | ||
* LOG LIKELIHOOD | ||
* | ||
* | ||
* DESCRIPTION: | ||
* - Computes the log likelihood. | ||
* | ||
* NOTES: | ||
* [1] | ||
* | ||
* | ||
* TODO: | ||
* [1] | ||
* | ||
* | ||
* LICENSE: | ||
* MIT | ||
* | ||
* Copyright (c) 2015. Athan Reines. | ||
* | ||
* | ||
* AUTHOR: | ||
* Athan Reines. kgryte@gmail.com. 2015. | ||
* | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/** | ||
* FUNCTION: loglikelihood( N, rss ) | ||
* Computes the log likelihood. | ||
* | ||
* @param {Number} N - number of observations | ||
* @param {Number} rss - residual sum of squares (sum of squared errors) | ||
* @returns {Number} log likelihood | ||
*/ | ||
function loglikelihood( N, rss ) { | ||
return -N / 2 * ( Math.log( (rss/N) * 2 * Math.PI ) + 1 ); | ||
} // end FUNCTION loglikelihood() | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = loglikelihood; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* | ||
* COEFFICIENT OF DETERMINATION | ||
* | ||
* | ||
* DESCRIPTION: | ||
* - Computes the coefficient of determination (R squared). | ||
* | ||
* NOTES: | ||
* [1] | ||
* | ||
* | ||
* TODO: | ||
* [1] | ||
* | ||
* | ||
* LICENSE: | ||
* MIT | ||
* | ||
* Copyright (c) 2015. Athan Reines. | ||
* | ||
* | ||
* AUTHOR: | ||
* Athan Reines. kgryte@gmail.com. 2015. | ||
* | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/** | ||
* FUNCTION: rsq( mss, tss ) | ||
* Computes the coefficient of determination. | ||
* | ||
* @param {Number} mss - model sum of squares | ||
* @param {Number} tss - total sum of squares | ||
* @returns {Number} coefficient of determination | ||
*/ | ||
function rsq( mss, tss ) { | ||
return mss / tss; | ||
} // end FUNCTION rsq() | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = rsq; |