GLM fitting, testing and graphics plotting

1 次查看(过去 30 天)
Hello,
I would be very grateful if you could help me with some doubts regarding GLM. My data has two groups (controls and cases) and I want to estimate how the gray matter volume is related to days of drug abstinence, after correcting for age, in both groups (controls, cases). I imagine this like two fitting lines (one for controls, one for cases) y-axis: gray matter, x-axes:days of abstinence (but corrected for age) and testing the slopes.
I have started this simple code, but I dont't know how to code the groups (0, 1 or 1 - 1) or whether I should demean age and abstinence. Also, I would like to plot a graphic with two lines to see how the data is fitted (after correcting for age). How could I do that?
GM =[2;5;8;4]; % Gray matter
group=[0;0;1;1]; % group (0:controls, 1:cases)
age=[45;20;15;58]; % age (years old)
days_abst=[5;8;7;6]; % days of abstinence (behavior value to test)
d = dataset(GM,group,age,days_abst);
d.group=ordinal(d.group);
m = GeneralizedLinearModel.fit(d,'GM~group+age+days_abst');
devianceTest(m);
coefTest(m,[0 0 0 1]) %? Test if the relationship between GM and days_abst is %significantly different in controls and cases
Thank you very much,
Ursula

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Vector Fields 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by