How to create fitting plots using data and a parametric function, whose parameter I estimated through maximum likelihood?

8 vues (au cours des 30 derniers jours)
Dear all,
I want to plot data vs fitted function I found through Maximum Likelihood Estimation.
The following 4 plots are needed:
- observed and fitted densities
- observed and fitted densities in log
- observed vs fitted frequencies in log
- Q-Q plot in log
The function I used is a double Pareto-lognormal function. I managed to estimate the parameters of the function but now I'm struggling with the plots. Any help would be great.
The function is as follows:
Y = log(X)
n = length(Y);
m = mean(Y);
theta(1)= 3.3025;
theta(2)= 2.2771;
theta(3)= 0.9303;
p = theta(1)*theta(3) - (Y-m + 1/theta(1) - 1/theta(2) )/theta(3);
q = theta(2)*theta(3) + (Y-m + 1/theta(1) - 1/theta(2) )/theta(3);
M = log( (1-normcdf(p)).*normpdf(q) + (1-normcdf(q)).*normpdf(p) ) + .5*(log(2*pi)+p.^2) + .5*(log(2*pi)+q.^2);
function F=n*log(theta(1)) + n*log(theta(2)) - n*log(theta(1)+theta(2)) + ...
sum(-.5*(log(2*pi) + ( (Y-m + 1/theta(1) - 1/theta(2))/theta(3) ).^2) ) + sum(M);
end
F = -F;
  2 commentaires
dpb
dpb le 21 Juil 2019
function F=n*log(theta(1)) + n*log(theta(2)) - n*log(theta(1)+theta(2)) + ...
sum(-.5*(log(2*pi) + ( (Y-m + 1/theta(1) - 1/theta(2))/theta(3) ).^2) ) + sum(M);
end
F = -F;
What's the negation of F after the function? Shouldn't be either
function F=n*log(theta(1)) + n*log(theta(2)) - n*log(theta(1)+theta(2)) + ...
sum(-.5*(log(2*pi) + ( (Y-m + 1/theta(1) - 1/theta(2))/theta(3) ).^2) ) + sum(M);
F = -F;
end
or
function F=-(n*log(theta(1)) + n*log(theta(2)) - n*log(theta(1)+theta(2)) + ...
sum(-.5*(log(2*pi) + ( (Y-m + 1/theta(1) - 1/theta(2))/theta(3) ).^2) ) + sum(M));
end
?
Also, where are X, Y? Nobody can do nuttin' without the data.
Lastly, what have you tried and where did you run into a problem, specifically?
Alessandro Calabrese
Alessandro Calabrese le 21 Juil 2019
Thanks for your answer dpb.
X are just income data of a survey. Actually from 0 to 541879.19, and are called before by
X = LabourIncSHIW2002(:,18);
after correctly loading the file with
cd('/Users/******.*******/Desktop/******/Italy/Matlab/Data')
[LabourIncSHIW2002, txt2002]= xlsread('Matlab_2002_data_excel.xlsx');
The problem is, that I don't get the values calculated as it says "The current use of n (in the function) is inconsistent".
I guess the plotting is the easy part.

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by