[R] different regression coeffs with different starting point

William Dunlap wdunlap at tibco.com
Mon Mar 14 16:43:51 CET 2011


> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Jen
> Sent: Monday, March 14, 2011 3:27 AM
> To: r-help at r-project.org
> Subject: [R] different regression coeffs with different starting point
> 
> Hi all,
> I have a question about the optimisation methods used in nonlinear
> regression. I have some data that I would like to fit a tobit 
> regression
> model to (see code below). It seems that the solution is very 
> sensitive to
> the initial condition that I give it - is there any option to use a
> different optimisation process where the solution will be 
> less sensitive to
> the initial condition?
> Many thanks in advance,
> J
> 
> require(AER)
> data_in = c(0,6,12,18,24,30,36,42,48,54,60,66,72,78)
> data_in2 = data_in^2
> data_in3 = data_in^3
> data_out =
> c(139487.00,133333.00,62500.00,58823.00,56338.00,27549.00,4244
> .00,600.00,112.00,95.00,48.00,31.00,15.00,14.99)
> ldata_out = log(data_out)
> 
> 
> m2 <- lm(ldata_out ~ data_in + data_in2)
> print(m2)
> quad_mod <- tobit(ldata_out ~ data_in + data_in2,
>   left=log(15-0.01),init = coef(m2))
> quad_mod2 <- tobit(ldata_out ~ data_in + data_in2,
>   left=log(15-0.01),init = coef(m2)-0.01)
> print(quad_mod)
> print(quad_mod2)

When I tried this the second call to tobit gave a warning:
  > quad_mod2 <- tobit(ldata_out ~ data_in + data_in2, left=
log(15-0.01),init = coef(m2)-0.01)
  Warning message:
  In survreg.fit(X, Y, weights, offset, init = init, controlvals =
control,  :
     Ran out of iterations and did not converge
Did you get the warning?   If not there is a bug in
your system or you are using an old version of some
package.  If there was a warning, it is misleading to
not put the warning in the description of the problem.

Responding to the warning, I increased maxiter to 100
and got essentially the same result as in quad_mod
(only the iteration number and the call were different).
  > quad_mod2a <- tobit(ldata_out ~ data_in + data_in2, left=
log(15-0.01),init = coef(m2)-0.01, maxiter=100)
  > all.equal(quad_mod, quad_mod2a)
  [1] "Component 5: Mean relative difference: 3.181818"
"Component 13: target, current do not match when deparsed"
  > names(quad_mod)[5]
  [1] "iter"
  > quad_mod[[5]]
  [1] 11
  > quad_mod2a[[5]]
  [1] 46

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> 
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/different-regression-coeffs-with
-different-starting-point-tp3353536p3353536.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 



More information about the R-help mailing list