# poisson regression using genetics algorithm

2 ビュー (過去 30 日間)
dmr 2020 年 8 月 13 日
コメント済み: Gifari Zulkarnaen 2020 年 8 月 19 日
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.

サインインしてコメントする。

### 回答 (1 件)

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 件のコメント表示非表示 1 件の古いコメント
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
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

サインインしてコメントする。

### カテゴリ

Find more on Genetic Algorithm in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by