Learn R Programming

regtools (version 1.1.0)

nlshc: Heteroscedastic Nonlinear Regression

Description

Extension of nls to the heteroscedastic case.

Usage

nlshc(nlsout,type='HC')

Arguments

nlsout

Object of type 'nls'.

type

Eickert-White algorithm to use. See documentation for nls.

Value

Estimated covariance matrix

Details

Calls nls but then forms a different estimated covariance matrix for the estimated regression coefficients, applying the Eickert-White technique to handle heteroscedasticity. This then gives valid statistical inference in that setting.

Some users may prefer to use nlsLM of the package minpack.lm instead of nls. This is fine, as both functions return objects of class 'nls'.

References

Zeileis A (2006), Object-Oriented Computation of Sandwich Estimators. Journal of Statistical Software, 16(9), 1--16, http://www.jstatsoft.org/v16/i09/.

Examples

Run this code
# NOT RUN {
# simulate data from a setting in which mean Y is 
# 1 / (b1 * X1 + b2 * X2)
n <- 250
b <- 1:2
x <- matrix(rexp(2*n),ncol=2)
meany <- 1 / (x %*% b)  # reg ftn
y <- meany + (runif(n) - 0.5) * meany  # heterosced epsilon
xy <- cbind(x,y)
xy <- data.frame(xy)
# see nls() docs
nlout <- nls(X3 ~ 1 / (b1*X1+b2*X2),
   data=xy,start=list(b1 = 1,b2=1))
nlshc(nlout)
# }

Run the code above in your browser using DataLab