- semiconjugateblm: https://www.mathworks.com/help/econ/semiconjugateblm.html
- conjugateblm: https://www.mathworks.com/help/econ/conjugateblm.html
My code with bayesian linear regression
6 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
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":
I hope this helps, thanks!
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!