This function returns the anova table with the partition of the total sum of squares into due the regression model and residuals and the corresponding \(R^2\) (adjusted for the null model).

R2nls(nls.obj)

Arguments

nls.obj

a object of class nls.

Value

a list with two slots. The first named anova is the table with partition of the total sum of squares (adjusted for the mean or null model or intercept inly model) in regression sum of squares and residual sum of squares. The second named R2 is the coefficient of determination.

Examples

da <- subset(DNase, Run == 4) plot(density ~ log(conc), data = da)
m0 <- nls(density ~ Asym/(1 + exp(-(log(conc) - xmid)/scal)), start = list(Asym = 2.3, xmid = 1.5, scal = 1), data = da) summary(m0)
#> #> Formula: density ~ Asym/(1 + exp(-(log(conc) - xmid)/scal)) #> #> Parameters: #> Estimate Std. Error t value Pr(>|t|) #> Asym 2.32918 0.05301 43.94 1.59e-15 *** #> xmid 1.43745 0.05423 26.51 1.06e-12 *** #> scal 0.99811 0.02240 44.56 1.33e-15 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> Residual standard error: 0.01427 on 13 degrees of freedom #> #> Number of iterations to convergence: 4 #> Achieved convergence tolerance: 4.248e-07 #>
plot(density ~ log(conc), data = da)
with(as.list(coef(m0)), curve(Asym/(1 + exp(-(x - xmid)/scal)), add = TRUE, col = 2))
R2nls(m0)
#> Error in eval(nls.obj$data): object 'da' not found
cor(fitted(m0), da$density)^2
#> [1] 0.9995336