I have some independent and dependent data measurements in two variables (vectors), called X and Y, respectively. I am using fmincon to minimize the following cost function
function SSerr = ObjFun(C, X, Y)
Yhat = Model(C, X);
T = ( Yhat - Y ).^2;
SSerr = sum(T(:));
the function "Model" above just calculates the predicted values (Yhat) based on the measured independent variable data (X) and some fit-parameters (C).
I assume that the errors (deviations between predicted Yhat and measured Y) come from a normal (Gaussian) distribution with mean=0 and variance sigma, G(0, sigma2)
I want to calculate the Akaikes Information Criterion (AIC).
AIC = 2k - 2ln(L)
where k is the number of parameters used for the fit (in my case the length of C) and L is the maximum value of the likelihood function.
So my question is: how do I calculate the maximum value of the likelihood function ?
I have seen here that minimising the sum of the squares of the residuals (RSS), as I do above, is equivalent to maximising the likelihood function if the residuals are normally distributed.
But this does not mean that the RSS is equal to the likelihood function - or does it ?
Thanks in advance