24小时热门版块排行榜    

查看: 3577  |  回复: 15

monitor2885

至尊木虫 (知名作家)

队长

[求助] 求广义线性模型GLM的函数表达式 已有1人参与

y=b0+b1*x1+b2*x2+b3*sin(x3)

y=[7.1;4.1;5.2;6.3];
x1=[1;2;3;4];
x2=[100;205;306;150];
x3=[8;10;12;5];

link 函数是 normal,求 glmfit 的表达式,求 b0, b1, b2, b3,谢谢。
回复此楼
Retirement
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

512095518

专家顾问 (正式写手)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★
感谢参与,应助指数 +1
monitor2885: 金币+10, ★★★很有帮助 2015-10-29 09:55:21
b0 = 3.3941
b1 = 1.5278
b2 = -0.0044
b3 = 2.6494
没有极限,只有超越!
2楼2015-10-29 09:52:11
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

monitor2885

至尊木虫 (知名作家)

队长

引用回帖:
2楼: Originally posted by 512095518 at 2015-10-29 09:52:11
b0 = 3.3941
b1 = 1.5278
b2 = -0.0044
b3 = 2.6494

b = glmfit([x1 x2 x3],y,'normal','link','normal')
这个语句,为何不对呀?第一个Normal代表distr,第二个normal是link函数,不对吗?
Retirement
3楼2015-10-29 09:55:10
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

512095518

专家顾问 (正式写手)

【答案】应助回帖

我不太明白就是link函数是normal是什么意思,我用matlab非线性拟合帮你求出参数

y=[7.1;4.1;5.2;6.3];
x1=[1;2;3;4];
x2=[100;205;306;150];
x3=[8;10;12;5];
x=[x1 x2 x3];
f=@(b,x)b(4)+b(1)*x(:,1)+b(2)*x(:,2)+b(3)*sin(x(:,3))
b0=[0 0 0 0]';
opt=optimset('TolFun',1e-3,'TolX',1e-3);
[b R]=nlinfit(x,y,f,b0,opt)

最后求得b的数组
没有极限,只有超越!
4楼2015-10-29 09:55:11
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

monitor2885

至尊木虫 (知名作家)

队长

引用回帖:
4楼: Originally posted by 512095518 at 2015-10-29 09:55:11
我不太明白就是link函数是normal是什么意思,我用matlab非线性拟合帮你求出参数

y=;
x1=;
x2=;
x3=;
x=;
f=@(b,x)b(4)+b(1)*x(:,1)+b(2)*x(:,2)+b(3)*sin(x(:,3))
b0=';
opt=optimset('TolFun',1e-3,'Tol ...

如果写成 b = glmfit([x1 x2 sin(x3)],y,'normal') 就对了。为什么不写Link呢?奇怪。你看matlab help里面那个汽车的例子,写link了呀
Use the glmfit function to carry out the associated regression:

b = glmfit(w,[poor total],'binomial','link','logit')
b =
  -13.3801
    0.0042
Retirement
5楼2015-10-29 09:57:40
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

512095518

专家顾问 (正式写手)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★
monitor2885: 金币+10, ★★★很有帮助 2015-10-29 10:42:13
引用回帖:
5楼: Originally posted by monitor2885 at 2015-10-29 09:57:40
如果写成 b = glmfit(,y,'normal') 就对了。为什么不写Link呢?奇怪。你看matlab help里面那个汽车的例子,写link了呀
Use the glmfit function to carry out the associated regression:

b = glmfit(w,,'bino ...

实际上b = glmfit([x1 x2 sin(x3)],y)也就可以出结果了,我猜想广义线性模型中的Y=b0+b1*x1+b2*x2+b3*x3,其中用sin(x3)来代替x3这才适用模型,所以你最开始b = glmfit([x1 x2 x3],y,'normal','link','normal')这样直接用x3就有问题,不符合模型假设

b = glmfit([x1 x2 sin(x3)],y,'normal','link','identity')这个格式也是可以的

函数格式为b = glmfit(X,y,distr,param1,val1,param2,val2,...),distr can be any of the following strings: 'binomial', 'gamma', 'inverse gaussian', 'normal' (the default), and 'poisson'.

b = glmfit(X,y,distr,param1,val1,param2,val2,...) additionally allows you to specify optional parameter name/value pairs to control the model fit. Acceptable parameters are as follows.

从matlab函数解释中看出,param参数是来优化distr分布的,你要注意写全了,要么就都缺省让函数内在保持一致,用b = glmfit([x1 x2 sin(x3)],y),要么就都写全了,用b = glmfit([x1 x2 sin(x3)],y,'normal','link','identity')
没有极限,只有超越!
6楼2015-10-29 10:27:09
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

512095518

专家顾问 (正式写手)

【答案】应助回帖

★ ★ ★ ★ ★
monitor2885: 金币+5, 有帮助 2015-10-29 10:45:30
引用回帖:
3楼: Originally posted by monitor2885 at 2015-10-29 09:55:10
b = glmfit(,y,'normal','link','normal')
这个语句,为何不对呀?第一个Normal代表distr,第二个normal是link函数,不对吗?...

link这个参数里面没有normal这一值作为选项,你用identity来代替你第二个normal就可以了
没有极限,只有超越!
7楼2015-10-29 10:30:31
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

monitor2885

至尊木虫 (知名作家)

队长

引用回帖:
6楼: Originally posted by 512095518 at 2015-10-29 10:27:09
实际上b = glmfit(,y)也就可以出结果了,我猜想广义线性模型中的Y=b0+b1*x1+b2*x2+b3*x3,其中用sin(x3)来代替x3这才适用模型,所以你最开始b = glmfit(,y,'normal','link','normal')这样直接用x3就有问题,不符合 ...

你看stats,哪个是significance?
stats is a structure with the following fields:
beta — Coefficient estimates b
dfe — Degrees of freedom for error
s — Theoretical or estimated dispersion parameter
sfit — Estimated dispersion parameter
se — Vector of standard errors of the coefficient estimates b
coeffcorr — Correlation matrix for b
covb — Estimated covariance matrix for B
t — t statistics for b
p — p-values for b
resid — Vector of residuals
residp — Vector of Pearson residuals
residd — Vector of deviance residuals
resida — Vector of Anscombe residuals
Retirement
8楼2015-10-29 10:44:36
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

512095518

专家顾问 (正式写手)

【答案】应助回帖

引用回帖:
8楼: Originally posted by monitor2885 at 2015-10-29 10:44:36
你看stats,哪个是significance?
stats is a structure with the following fields:
beta — Coefficient estimates b
dfe — Degrees of freedom for error
s — Theoretical or estimated dispersion parame ...

你是要求R2么,我感觉那里面都不是,matlab里面没有直接求R2的命令,需要自己写。不过方法也很简单。
R2就是决定系数(coefficient of determination),有的教材上翻译为判定系数,也称为拟合优度。

你原始数为b,拟合方程求得数为a,则
R2 =sum((a - mean(b)).^2)/sum((b - mean(b)).^2)
没有极限,只有超越!
9楼2015-10-29 10:57:14
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

monitor2885

至尊木虫 (知名作家)

队长

引用回帖:
9楼: Originally posted by 512095518 at 2015-10-29 10:57:14
你是要求R2么,我感觉那里面都不是,matlab里面没有直接求R2的命令,需要自己写。不过方法也很简单。
R2就是决定系数(coefficient of determination),有的教材上翻译为判定系数,也称为拟合优度。

你原始数 ...

显著性检验,signif=0.1,0.05,0.001...
Retirement
10楼2015-10-29 11:01:46
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 monitor2885 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[教师之家] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +4 7lpolszZVXgi 2026-08-14 4/200 2026-08-15 01:08 by 4wMiSEwB6436
[考研] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +3 HFw0lei2R37i 2026-08-14 7/350 2026-08-15 00:40 by 4wMiSEwB6436
[基金申请] 欢迎发来filecode的Mz6后的代码验证其规律 +23 医学老男孩 2026-08-13 49/2450 2026-08-14 20:02 by zhaifei
[基金申请] 哪位老哥知道今年的国自然具体哪一天放榜? +5 Ldrop2023 2026-08-13 5/250 2026-08-14 18:48 by ssxclkj
[硕博家园] 请教兼职经验 +3 是阿文鸭 2026-08-09 3/150 2026-08-14 12:07 by HER12025
[论文投稿] 职称评审,求友友推荐见刊最快的期刊 +5 工厂打螺丝 2026-08-08 5/250 2026-08-14 11:03 by 玖戈弋
[基金申请] filecode +15 documentary 2026-08-10 17/850 2026-08-14 10:08 by kissu88
[基金申请] FileCode能看出啥? +10 要乐观耀哥 2026-08-10 32/1600 2026-08-14 09:37 by 要乐观耀哥
[基金申请] 我的国基提前知道中了,可是同事的操作让我实在接受不了,怎么会有这样的人 +10 家与远方 2026-08-10 15/750 2026-08-14 02:08 by 绵羊哥哥
[文学芳草园] 阿姨 +4 汪汪锅 2026-08-09 4/200 2026-08-13 19:43 by arzu_hma
[硕博家园] 一作与独作在应聘高校教师时区别大吗 +3 mbygzh 2026-08-08 4/200 2026-08-13 19:31 by 龙-樱
[基金申请] 重要来源:本周末出结果 +10 瞬息宇宙 2026-08-12 10/500 2026-08-13 15:46 by likettle
[基金申请] 不应该看fileCode +7 且听虎啸 2026-08-12 9/450 2026-08-13 14:27 by flydreamws
[基金申请] Filecode 又变了,巨变 +3 WH3796 2026-08-12 4/200 2026-08-13 14:13 by 小木虫6752397
[基金申请] 分享一下我之前已中青C的计划书的filecode +4 布布和一二 2026-08-11 5/250 2026-08-13 12:56 by cratir
[基金申请] 结合人工智能,周易传统文化,filecode打分制来了,3分以上希望很大。 +3 Tide man 2026-08-12 4/200 2026-08-13 08:35 by ZJTJZ
[基金申请] 2019年青年基金涵评意见,大家看看几个A,几个B? +11 Tide man 2026-08-11 11/550 2026-08-13 07:35 by 撸猫猫
[基金申请] 什么时候出结果,有咨询渠道??? +3 Tide man 2026-08-11 3/150 2026-08-11 17:54 by kudofaye
[基金申请] 面上项目filecode邪修 +5 西山十月 2026-08-09 7/350 2026-08-10 07:32 by 仁砚薪传
[基金申请] 关于filecode,很负责任的告诉大家 +6 爱看书的可乐 2026-08-08 7/350 2026-08-08 22:13 by a_niu
信息提示
请填处理意见