[R] Non-Linear Regression Problem
spencer.graves at pdf.com
Wed Apr 14 18:26:51 CEST 2004
1. For the equation you mentioned, have you considered the following:
DF <- data.frame(t.=c(1, 4, 16), Y=c(.8, .45, .04))
# I do NOT use "t" as a name, as it
# may conflict with the matrix transpose function.
fit0 <- lm(log(Y)~t.-1, DF)
lm(formula = log(Y) ~ t. - 1, data = DF)
If this is the problem you really wanted to solve AND you honestly
need NONLINEAR least squares, I would expect that (-0.2) should provide
a reasonable starting value for nls:
> fit1 <- nls(Y~exp(-THETA*t.), data=DF, start=c(THETA=-0.2))
Nonlinear regression model
model: Y ~ exp(-THETA * t.)
residual sum-of-squares: 0.0003018337
2. Alternatively, you could compute the sum of squares for all
values of THETA = seq(0, .01, 100) in a loop, then find the minimum by
3. If this is just a toy example, and your real problem has
several parameters, "expand.grid" will produce a grid, and you can
compute the value of your function and the sum of squares of residuals
at every point in the grid in a single loop, etc.
hope this helps. spencer graves
> Dear all,
> I was wondering if there is any way i could do a "Grid Search" on
> a parameter space using R (as SAS 6.12 and higher can do it) to start
> the Newton-Gauss Linearization least squares method when i have NO
> prior information about the parameter.
> W. N. Venables and B. D. Ripley (2002) "Modern Applied Statistics with
> S", 4 th ed., page 216-7 has a topic "Self-starting non-linear
> regressions" using negexp.SSival - but i can not solve my hypothetical
> problem using that - my problem is :
> Y = EXP(-(THETA * t)) with data below for estimating THETA:
> t Y
> 1 0.80
> 4 0.45
> 16 0.04
> Whatever i could do, is in
> Any response / help / comment / suggestion / idea / web-link / replies
> will be greatly appreciated.
> Thanks in advance for your time.
> Mohammad Ehsanul Karim <wildscop at yahoo.com>
> Institute of Statistical Research and Training
> University of Dhaka, Dhaka- 1000, Bangladesh
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide!
More information about the R-help