poisson regression using genetics algorithm
조회 수: 5 (최근 30일)
이전 댓글 표시
Hi,
i've seen a few examples in the community on how to use genetics algorithm in optimizing regression models but i was wondering if i can use genetics algorithm as an approach to optimize poisson regression model (especially since i don't think pr uses mse to estimate the parameters). i have four independent variables and i've generated the parameters using maximum likelihood method but i don't know how to apply it to genetics algorithm. maybe some ideas on what should i use as an objective function and how to initialize the chromosomes? thanks in advance.
댓글 수: 0
답변 (1개)
Gifari Zulkarnaen
2020년 8월 13일
편집: Gifari Zulkarnaen
2020년 8월 13일
I dont really understand statistics and PR, but I think you can define the objective function as a function of PR variables which generate least error of regression. And using matlab toolbox, you dont need to code GA yourself. Can you give us your attempt of objective function script?
It's more likely in this form:
global X Y
X = rand(4,3); % x data, with 4 variables input of 3 samples
Y = rand(1,3); % y data, with 1 output of 3 samples
[teta,err] = ga(@obj_func,4);
function err = obj_func(teta)
global X Y
PR = exp(teta*X); % PR prediction
err = sumsqr(Y - PR); % difference between actual output and predicted regression
end
댓글 수: 2
Gifari Zulkarnaen
2020년 8월 19일
Sorry I forgot to check this.
First, do you want to code GA yourself or just use toolbox from matlab? If using toolbox from matlab, you dont need to initialize the variable. See the syntanx.
Second, I dont get how substracting the update of parameter can be an error measurement. According to wikipedia, the MLE of PR would be like this:
L = sum(y.*teta*x - exp(teta*x));
But GA will work better if the problem is minimization, so objective function should become:
f = 1/L;
So, the script would be:
global x y_data % make the data global variables
load data
m = size(data,1); % number of samples
x = [ones(m,1) data(2:4)]'; % to simplify the coding, input data become 4 x m matrix
y_data = data(:,1)'; % y is a response variable, transposed
% GA optimization
teta = ga(@obj_func,4); % teta is the optimized parameters result, yes the GA coding is only this line
% Optimized PR model
y_PR = exp(teta*x); % which teta is vector of parameters: [b0 b1 b2 b3]
% Objective function
function f = obj_func(teta)
global x y_data
L = sum(y_data.*teta*x - exp(teta*x)); % MLE of PR
f = 1/L; % to become minimization problem
end
참고 항목
카테고리
Help Center 및 File Exchange에서 Nonlinear Regression에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!