Standard Error of the Regression for NLS Model

1.3k views Asked by At

I am currently working on a non-linear analysis of various datasets using nls model. On the other hand, I want to calculate the standard error of the regression of the nls model.

The formula of the standard error of regression:

n <- nrow(na.omit((data))

SE = (sqrt(sum(pv-av)^2)/(n-2))

where pv is the predicted value and av is the actual value.

I have a problem on calculating the standard error. Should I calculate the predicted value and actual value first? Are the values based on the dataset? Any help is highly appreciated. Thank You.

1

There are 1 answers

0
G. Grothendieck On BEST ANSWER

R provides this via sigma:

fm <- nls(demand ~ a + b * Time, BOD, start = list(a = 1, b = 1))
sigma(fm)
## [1] 3.085016

This would also work where deviance gives residual sum of squares.

sqrt(deviance(fm) / (nobs(fm) - length(coef(fm))))
## [1] 3.085016