[R] An error in fitting a non linear regression
Saeed Ahmadi
ahmadi_saeed at yahoo.com
Tue Feb 24 12:41:50 CET 2009
Hi Peter,
You are totally right and it was a miscalculating and misunderstanding from
me.
Regarding the R-squared calculation of non linear model (question 2), is
there any way to do that?
Regards
Saeed
Petr Pikal wrote:
>
> Hi
>
> r-help-bounces at r-project.org napsal dne 24.02.2009 11:31:22:
>
>>
>> Hi,
>>
>> Thank you for the reply and suggestions.
>>
>> I have two questions?
>> 1) If I want to use log, it seems that I have to take log from both
> sides of
>> the model which will lead to lm(log(q)~log(-depth)). What is
> tehdifference
>> between this syntax and lm(log(q) ~ I(-depth))?
>
>
> If you have
>
> y = a*exp(-b*x) then log of this equation is
>
> log(y) = log(a) - b * x
>
> at least I was told that by my teacher back at school some decades ago
> that log(exp(x)) = x.
>
> You can prove it by
>
> log(exp(whatever))
>
> interactively in R
>
> Regards
> Petr
>
>>
>> 2) How can I calculate the R-squared of a fitted non linear model?
>>
>> Regards
>> Saeed
>>
>>
>> Christian Ritz-3 wrote:
>> >
>> > Hi Saeed,
>> >
>> > one approach is to try out several initial value combinations for a
> and b.
>> >
>> > It often helps to find initial values of the same order of magnitude
> and
>> > of the same sign
>> > as the final estimates.
>> >
>> > To get such initial values, you could linearize the model:
>> >
>> > lm(log(q) ~ I(-depth))
>> >
>> >
>> > and supply the estimated coefficients from the linear regression as
>> > starting values:
>> >
>> > nreg <- nls(q ~ a*exp(-b*depth), start = list(a = 0.76168, b =
> -0.08484))
>> > summary(nreg)
>> >
>> >
>> > Christian
>> >
>> > ______________________________________________
>> > 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.
>> >
>> >
>>
>> --
>> View this message in context:
> http://www.nabble.com/An-error-in-fitting-a-non-
>> linear-regression-tp22118160p22179525.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.
>
> ______________________________________________
> 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.
>
>
--
View this message in context: http://www.nabble.com/An-error-in-fitting-a-non-linear-regression-tp22118160p22180225.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list