Description Usage Arguments Details Author(s) References Examples
Calculates a quasi-rsquared value for non linear least squares regression models. The formula for calculating this is given in the paper in the references (Spiess 2010).
1 | quasi.rsq.nls(mdl, y, param)
|
mdl |
model object from which R^2 is desired. Used to calculate the residual sum of squares. |
y |
the dependent variable in the model. |
param |
the number of parameters of the non-linear model |
Cautionary notes of whether its useful are provided in the stack overflow reference. A personal highlight of which is 'If someone asks for rope to hang themselves, its fine to give it to them (while performing due diligence by asking "are you sure you want to do this?")'
Calculated as :
1 - (n-1)/(n-param) * (1 - R^2)
where R^2 = 1 - RSS/TSS
RSS is the residual sum of squares given by deviance(mdl)
TSS is given by how much variance there is in the dependent variable:
(n - 1)*var(y)
Daniel Padfield
Spiess, A.-N. & Neumeyer, N. (2010) An evaluation of R2 as an inadequate measure for nonlinear models in pharmacological and biochemical research: a Monte Carlo approach. BMC pharmacology, 10, 6.
http://stackoverflow.com/questions/14530770/calculating-r2-for-a-nonlinear-model
1 2 3 4 5 6 7 8 9 10 11 12 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (mdl, n, param)
{
adj <- (sum(!is.na(y)) - 1)/(sum(!is.na(y)) - param)
sum.sq <- (sum(!is.na(y)) - 1) * var(y, na.rm = TRUE)
rsq <- 1 - (adj * (deviance(mdl)/sum.sq))
return(rsq)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.