24小时热门版块排行榜    

查看: 3571  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 综述论文作为代表作会不会影响评审专家的印象分? +11 yufeiwaner 2026-08-09 12/600 2026-08-12 01:27 by 南京中西医
[基金申请] 2019年青年基金涵评意见,大家看看几个A,几个B? +4 Tide man 2026-08-11 4/200 2026-08-12 00:39 by liuqidi
[基金申请] 小木虫上这么多卖论文的,真有人买论文么?感觉没必要啊 +8 Tide man 2026-08-10 9/450 2026-08-11 20:39 by beefly
[基金申请] 有时候,自然基金真的不能太认真 (我的申报经验) +3 majunge000 2026-08-11 4/200 2026-08-11 20:13 by lch2012
[基金申请] 帮忙看看fileCode +7 wwncly 2026-08-10 13/650 2026-08-11 19:36 by 冰心玉壶晴
[基金申请] 什么时候出结果,有咨询渠道??? +3 Tide man 2026-08-11 3/150 2026-08-11 17:54 by kudofaye
[基金申请] 分享一下我之前已中青C的计划书的filecode +3 布布和一二 2026-08-11 4/200 2026-08-11 15:20 by aasahr
[基金申请] 听说今天filecode变了 +26 布布和一二 2026-08-06 49/2450 2026-08-11 13:18 by WH3796
[基金申请] filecode +9 documentary 2026-08-10 9/450 2026-08-11 10:08 by wk7465
[基金申请] 我的国基提前知道中了,可是同事的操作让我实在接受不了,怎么会有这样的人 +8 家与远方 2026-08-10 13/650 2026-08-11 09:49 by 家与远方
[基金申请] 关于Filecode分析方法 +3 majunge000 2026-08-10 3/150 2026-08-10 15:46 by lch2012
[基金申请] 据悉今年马上要出结果了 +7 瞬息宇宙 2026-08-10 8/400 2026-08-10 12:42 by Vivilian
[基金申请] 这样的filecode谁见过 +11 布布和一二 2026-08-08 22/1100 2026-08-10 11:10 by wmfsnow
[基金申请] 面上项目filecode邪修 +5 西山十月 2026-08-09 7/350 2026-08-10 07:32 by 仁砚薪传
[基金申请] filecode与中标关系的预测 +5 布布和一二 2026-08-07 5/250 2026-08-09 16:15 by 袁向阳007
[基金申请] fileCode有新解读? +10 Tide man 2026-08-08 18/900 2026-08-09 12:55 by 仁砚薪传
[基金申请] 国基金的申报应该改成非等额制,评价高的钱多评价低的钱少,但是增加资助率 +7 a089 2026-08-07 7/350 2026-08-08 18:05 by gltch
[基金申请] 化学口download_prp&fileCode的固定段好像这几天一直没变,有变的大神么? +3 Tide man 2026-08-07 4/200 2026-08-07 22:39 by Tide man
[基金申请] 固定端突然变了,今天 +6 archvillain 2026-08-06 10/500 2026-08-07 16:03 by 医学老男孩
[基金申请] 好消息?这个有何含义??? +8 Tide man 2026-08-05 10/500 2026-08-05 16:14 by xmuxiaoyu
信息提示
请填处理意见