Hey all,
I'm trying to fit a predator-prey model to two sets of data on oil (one of the price and one of the monthly average of millions of barrels per day). The idea is the amount of oil produced is a "predator" to its "prey," price. I want the two solutions to model their respective sets of data, but I don't know how to make the given DE correlate with a piece of data but also be a system. The data sets both use t for time in months, which is expressed in the data sets. Here's my code:
IV := {t, 0, 51}
DV := {P[t], o[t]}
dP := P'[t] == a*P[t] - b*P[t] o[t]
do := o'[t] == -c*o[t] + d*P[t] o[t]
P[0] == 46 o[0] == 83
model = ParametricNDSolveValue[{dP, do, P[0]==46, o[0]==83}, DV, IV, {a, b, c, d}]
pricedata := {{0, 45.69}, {1, 40.78}, {2, 36.95}, {3, 37.06}, {4,
41.91}, {5, 49.96}, {6, 53.22}, {7, 52.2}, {8, 45.01}, {9,
48.32}, {10, 48.32}, {11, 52.05}, {12, 50.07}, {13, 53.35}, {14,
57.96}, {15, 56.61}, {16, 57.74}, {17, 54.04}, {18, 52.54}, {19,
51.41}, {20, 48.94}, {21, 53.38}, {22, 50.11}, {23, 57.43}, {24,
57.43}, {25, 60.61}, {26, 63.8}, {27, 68.03}, {28, 64.48}, {29,
67.73}, {30, 71.24}, {31, 69.39}, {32, 76.6}, {33, 71.03}, {34,
72.1}, {35, 75.52}, {36, 67.27}, {37, 52.61}, {38, 47.04}, {39,
55.62}, {40, 58.94}, {41, 61.58}, {42, 65.12}, {43, 54.41}, {44,
59.46}, {45, 59.76}, {46, 55.93}, {47, 54.83}, {48, 54.83}, {49,
55.83}, {50, 61.85}, {51, 52.02}};
productiondata := {{0, 81.29}, {1, 81.45}, {2, 81.47}, {3, 80.71}, {4,
80.68}, {5, 79.78}, {6, 79.19}, {7, 79.89}, {8, 80.61}, {9,
80.06}, {10, 80.43}, {11, 81.57}, {12, 82.63}, {13, 82.09}, {14,
81.17}, {15, 81.16}, {16, 80.35}, {17, 79.93}, {18, 80.53}, {19,
81.08}, {20, 81.59}, {21, 80.98}, {22, 81.19}, {23, 81.34}, {24,
82.01}, {25, 81.74}, {26, 82.24}, {27, 82.4}, {28, 82.21}, {29,
81.86}, {30, 81.59}, {31, 82.24}, {32, 82.67}, {33, 83.21}, {34,
83.21}, {35, 84.33}, {36, 84.5}, {37, 84.23}, {38, 82.88}, {39,
82.6}, {40, 82.56}, {41, 82.32}, {42, 81.72}, {43, 81.88}, {44,
81.28}, {45, 82.41}, {46, 80.73}, {47, 82.6}, {48, 83.58}, {49,
83.58}, {50, 83.22}, {51, 82.39}};
fit = FindFit[{pricedata, productiondata},
model[a, b, c, d][t], {a, b, c, d}, t]
What am I missing?