【发布时间】:2012-08-23 13:48:13
【问题描述】:
我想创建一个函数,在给定两个时间段的数据的情况下,找到 Bass 扩散模型的参数 p 和 q。
模型(方程)如下:
n(T) = p*m + (q-p)*n(T-1) + q/m*n(T-1)^2
在哪里
n(T) = number of addoptions occuring in period T
n(T-1) = number of cumulative adoptions that occured before T
p = coefficient of innovation
q = coefficient of imitation
m = number of eventual adopters
例如,如果 m = 3.000.000 以下年份的数据如下:
2000: n(T) = 820, n(T-1) = 0
2005: n(T) = 25000, n(T-1) = 18000
然后必须求解以下方程组(以确定 p 和 q 的值):
p*m + (q-p)*0 + q/3.000.000 * 0^2 == 820
p*m + (q-p)*18000 + q/3.000.000 * 18000^2 == 25000
通过关注Matlab documentation我尝试创建一个函数Bass:
function F = Bass(m, p, q, cummulativeAdoptersBefore)
F = [p*m + (q-p)*cummulativeAdoptersBefore(1) + q/m*cummulativeAdoptersBefore(1).^2;
p*m + (q-p)*cummulativeAdoptersBefore(2) + q/m*cummulativeAdoptersBefore(2).^2];
end
应该在 fsolve(@Bass,x0,options) 中使用,但在这种情况下,m、p、q、cummulativeAdoptersBefore(1) 和 cummulativeAdoptersBefore(2) 应该在 x0 中给出,并且所有变量都将被视为未知而不仅仅是后两者。
有谁知道如何求解上述方程组?
谢谢!
【问题讨论】:
-
所以...你真的只有 1 个方程,
n(T)和n(T-1)的数据有几个T。如果我错了,请纠正我,但这听起来很像你没有这样做。您确定lsqcurvefit不是更适合您的问题吗?fsolve用于不同方程的系统... -
@RodyOldenhuis:你是对的。我会检查 lsqcurvefit。谢谢!
标签: matlab