Problem with FindFit - No more memory available.
- To: mathgroup at smc.vnet.net
- Subject: [mg123625] Problem with FindFit - No more memory available.
- From: Anne Beyer <abeyer at stanford.edu>
- Date: Tue, 13 Dec 2011 05:43:23 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
Hi,
I'm trying to fit a model to data using FindFit. The model includes a
FindRoot and NIntegrate function. When I run the program, I get the
error message that "No more memory is available. Mathematica kernel
has shut down." Do you know what I'm doing wrong? Any help is highly
appreciated.
Thanks,
Anne
<< "MultivariateStatistics`"
H[t_, m_, s_] := CDF[LogNormalDistribution[m, s], t]/
PDF[LogNormalDistribution[m, s], t]
r[t_, c_, m_, s_] := (c + t)/(c*H[t, m, s] + t*(c + t))
t[c_?NumericQ, m_?NumericQ, s_?NumericQ, y_?NumericQ] := x /.
FindRoot[r[x, c, m, s] == y, {x, 0.2}]
U[t_?NumericQ, m_?NumericQ, s_?NumericQ, c_?NumericQ] :=
NIntegrate[0.5*(c/(c*H[x, m, s] + x*(c + x)))^2, {x, t, Infinity}]
w[c_?NumericQ, m_?NumericQ, s_?NumericQ, y_?NumericQ] := U[t[c, m, s,
y], m, s, c] + (t[c, m, s, y]*c)/(c + t[c, m, s, y])*1/2*y^2
"Data and estimation"
data = {{0.2, 0.02}, {0.4, 0.05}, {0.6, 0.1}, {0.8, 0.15}, {0.3,
0.03}}
model = w[c, m, s, y]
estimatedw = FindFit[data, {model, c > 0, s > 0}, {{c, 1}, {m, 1},
{s, 1}}, y]
Show[ListPlot[data], Plot[estimatedw[r], {r, 0, 0.8}], Frame -> True]