How to set initial kicks for nls function for potential regression model?

3

I'd like to know how to set the initial "kicks" to use the nonlinear power regression model. I'm working with a pet of data, testing several regression models, even without adjustment, I would like to cite this model, but I have difficulties in defining the values I would like to know a method that would allow me to apply to any set of data, to obtain the initial values of A and B for the function nls(y~B*x^A,start=list(A=1, B=1.7))

dados<-structure(list(y = c(44.42, 77.9, 95.72, 40.24, 63.7, 46.62, 
84.6, 52.49, 88.53, 56.52, 71.21, 65.16, 72.24, 53.81, 67.02), 
    x = c(11.26, 14.78, 17.56, 10.37, 13.27, 10.3, 14.07, 12.26, 
    13.3, 12.84, 13.72, 12.8, 14.86, 11.47, 15.06)), .Names = c("y", 
"x"), row.names = c(NA, -15L), class = "data.frame")

attach(dados)

nls(y~B*x^A,start=list(A=1, B=1.7))
    
asked by anonymous 21.02.2017 / 00:53

1 answer

3

This answer from Cross-Validated seems like a good solution.

The suggestion here is to take the log on both sides and fit a linear model. That would look something like this:

y = b*(x^a)
log(y) = log(b) + a*log(x)

So by doing the linear model you will have an initial estimate for log(b) and a .

Adjust the linear model:

linear <- lm(log(y) ~ log(x), data = dados)
linear
# Call:
#   lm(formula = log(y) ~ log(x), data = dados)
# 
# Coefficients:
#   (Intercept)       log(x)  
#        0.1371       1.5611  

So you'll have 0.1371 the estimate of log(b) and 1.5611 estimate a . A direct estimate of b can be exp(0.1371) = 1.146943 . These values can be used as initial kicks.

modelo <- nls(y~B*x^A,start=list(A=coef(linear)[2], B = exp(coef(linear)[1])), data = dados)
modelo

# Nonlinear regression model
# model: y ~ B * x^A
# data: dados
# A     B 
# 1.436 1.598 
# residual sum-of-squares: 1040
# 
# Number of iterations to convergence: 5 
# Achieved convergence tolerance: 3.365e-07

In the link you have several other answers that might help!

    
21.02.2017 / 18:31