필터 지우기
필터 지우기

My code with bayesian linear regression

조회 수: 5 (최근 30일)
Yohan
Yohan 2024년 4월 25일
댓글: Yohan 2024년 5월 6일
Currently I am just playing around with matlab to get used to the program and this is my following code so far. The purpose of my code is to run a following bayesian linear regression: My dependent variable is CAPB1 (stand for cyclically adjusted primary balance) and my independent variables are Govsize, GDPperCapita and CPIlevel. The Matlab website said I have to use bayeslm code but I am not aware of how does this code can be added here.
For your information on prior, I am assuming a normal distribution of parameter.
clear
% Load and prepare data
Cyclicalitydata = readtable("Could be final data set.xlsx");
BelgiumData = Cyclicalitydata(strcmp(Cyclicalitydata.Country, 'Belgium'), :);
BelgiumData = rmmissing(BelgiumData);
varnames = {'Govsize', 'GDPperCapita', 'CPIlevel'};
X = BelgiumData{:, varnames};
Y = BelgiumData{:, 'CAPB1'};
Also I am not sure how to use the semiconjugateblm and conjugateblm code too. The Matlab website wans't that friendly to me since it does not really provide an example of how to use those codes instead they said I can use some codes they mentioned.

답변 (1개)

Harsh
Harsh 2024년 5월 6일
Hi Yohan,
From what I can gather, you are working with a code which should perform bayesian linear regression in MATLAB and are unable to find any relevant documentation that demonstrats how "bayeslm", "semiconjugateblm" and "conjugateblm" should be used.
For relevant examples on "bayeslm", "semiconjugateblm" and "conjugateblm" copy the following code snippets in MATLAB:
% This example uses "bayeslm" function with "conjugateblm"
openExample('econ/CreateNormalInverseGammaConjugatePriorModelExample')
% This example uses "bayeslm" function with "semiconjugateblm"
openExample('econ/CreateNormalInverseGammaSemiconjugatePriorModelExample')
Refer the following documentations for more information on "bayeslm", "semiconjugateblm" and "conjugateblm":
  1. semiconjugateblm: https://www.mathworks.com/help/econ/semiconjugateblm.html
  2. conjugateblm: https://www.mathworks.com/help/econ/conjugateblm.html
I hope this helps, thanks!
  댓글 수: 1
Yohan
Yohan 2024년 5월 6일
Thank you so much! do you also have something similar to bayesian time varying coefficient model? That basically involves state space modelling.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by