How to compute the regression coefficient in Matlab with exp and ln?

I would like to compute the regression coefficients `a` and `b` for my data using this equation:
y=exp(a * ln(1 - t / h) + b * ln(1 - t / t1))
and this data(example):
t = [1,2,5,4,8,7,5,1,2,5,4,1,2,1,5]
t1 = [1,2,4,4,5,3,7,5,6,8,7,1,2,1,5]
h = [1,2,3,2,9,6,8,3,6,7,4,5,2,1,5]
y = [1,2,1,4,4,6,5,8,5,7,3,1,4,1,5]
but I do not know how to include `exp` and `ln`. PLease help

4 件のコメント

dpb
dpb 2013 年 12 月 26 日
Bad data...
>> log(1-t./h)
ans =
-Inf -Inf -0.4055 + 3.1416i 0 + 3.1416i -2.1972
-1.7918 + 3.1416i -0.9808 -0.4055 -0.4055 -1.2528
-Inf -0.2231 -Inf -Inf -Inf
If you can get a reasonable set of data for which (1-t/h) and (1-t/t1) are both >0 then you can try nlinfit but I suspect it'll be very difficult to separate out the two additive exponential terms.
Or, you can transform and solve for the log terms w/ OLS using
ln y = a ln(1-w) + b ln(1-x) where w=t/h and x=t/t1
with likely similar difficulties.
san der
san der 2013 年 12 月 26 日
編集済み: san der 2013 年 12 月 26 日
I have a reasonable set of data for which (1-t/h) and (1-t/t1) are both >0. Thanks why shall I use the nonlinear fit? What you mean by this:it'll be very difficult to separate out the two additive exponential terms
dpb
dpb 2013 年 12 月 26 日
a) Well, 'cuz it's a nonlinear equation, maybe? :)
b) The difficulty in estimating your a and b separately is that since they're an additive term in the exponential they combine as a single argument.
It would help if the data were collected for a design matrix that has those two terms evaluated independently altho I've not taken the time to try to work out a specific design for the case.
san der
san der 2013 年 12 月 26 日
in fact the original equation is like this {ln y = a ln(1-w) + b ln(1-x) where w=t/h and x=t/t1} so I need to find a and b based on initial values of y then I use a and b to find y. but then result will reflect ln(y) not y. what do you think?

サインインしてコメントする。

回答 (1 件)

Keith Dalbey
Keith Dalbey 2013 年 12 月 26 日

0 投票

let t, h, t1, and y be column vectors then
if true
% code
G=[log(1-t./h) log(1-t./t1)]; ab=(G'*G)\(G'*log(y))
end

4 件のコメント

Matt J
Matt J 2013 年 12 月 26 日
編集済み: Matt J 2013 年 12 月 26 日
ab=(G'*G)\(G'*log(y))
This should probably just be
ab=G\log(y);
There's no need for the system of equations to be made square.
Keith Dalbey
Keith Dalbey 2013 年 12 月 26 日
perhaps we should tell him that I did least squares, and that you used the overloaded \ operator which does the equivalent of a pseudo inverse for non-square matrices. The answers should be identical for small matrices, for large ones your approach would be more accurate (less round off error), mine would likely be faster.
san der
san der 2013 年 12 月 26 日
Thanks but this will produce ab! I want a and b separately
dpb
dpb 2013 年 12 月 26 日
Did you try it?

サインインしてコメントする。

カテゴリ

タグ

質問済み:

2013 年 12 月 26 日

コメント済み:

dpb
2013 年 12 月 26 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by