R-squared problem for fitnlm-model

Hey,
i have a question about the calculation of the ordinary and adjusted R-squared values in my fit-model. I need to fit two different functions (system of ode's), whereas there is a dependence of the second function from the first: 1st ode:
x0_4G = 0;
[T, Y] = ode15s(@DiffEq_given_4G, t, x0_4G);
%x_4G = m(t)
function dFunc_given = DiffEq_given_4G(t, x_4G)
xdot_4G = 0;
C = 0.15;
xdot_4G = Param(1) * C * (Param(3) - x_4G) - Param(2) * x_4G; %dm/dt
dFunc_given = xdot_4G;
end
2nd ode-system:
x0 = [0;0;0;0];
[T, Y] = ode15s(@DiffEq_given, t, x0);
% x(1) = m_ext, x(2) = m_int, x(3) = phi_int,
% x(4) = m_int + m_ext
function dFunc_given = DiffEq_given(t, x)
xdot = [0;0;0;0];
C = 0.15;
% Get the calculated parameters for 4°C
k_a = evalin('base', 'coef_4G(1,1)');
k_d = evalin('base', 'coef_4G(1,2)');
m_0 = evalin('base', 'coef_4G(1,3)');
xdot(1) = k_a * C * (m_0 - x(1)) - k_d * x(1) - xdot(2); %d(m_ext)/dt
xdot(2) = Param(1) * (Param(2) - x(3))* x(1); %d(m_int)/dt
xdot(3) = Param(1) * (Param(2) - x(3)); %d(phi_int)/dt
xdot(4) = xdot(1) + xdot(2); %dm/dt
dFunc_given = xdot;
end
When i fit the calculated functions i get this results (blue: m(t) for 4°C, red: m(t) for 37°C):
When you look at the function for 37°C (red one), you can see discrepancies between the measured and the fitted values, but the R² and the adj. R² is about 0.99. Is it possible, that the funtion "fitnlm" has problems with the calculation of the paramters, so that the calculation of the R²-values go wrong, too?
Thanks for your help, kind regards,
Simon

Answers (0)

Products

Asked:

on 2 Nov 2016

Community Treasure Hunt

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

Start Hunting!