请选择 进入手机版 | 继续访问电脑版
楼主: zhsh5518
4486 8

[原创博文] 求教!mixed model SAS 与 R的结果为何不同? [推广有奖]

  • 0关注
  • 0粉丝

本科生

54%

还不是VIP/贵宾

-

威望
0
论坛币
31 个
通用积分
1.2000
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
931 点
帖子
53
精华
0
在线时间
104 小时
注册时间
2007-12-6
最后登录
2023-12-3

zhsh5518 发表于 2012-2-28 09:45:47 |显示全部楼层 |坛友微信交流群
相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
以前一直用的SAS, 现在也想学学R, 但在做混合模型的时候,发现 R 和SAS 的结果总是有差别,例如下面的例子,数据见附件。
R 程序:
a =read.table("RIKZ.txt",header=T)
a$fBeach <- factor(a$Beach)
library (nlme)
mixed <- lme(Richness ~ NAP, random = ~1 +NAP| fBeach,data=a)
summary (mixed)

SAS程序
proc mixed data=rikz;
class beach;
model richness=nap /intercept;
random intercept nap/ subject=beach;
run;
但是R 和SAS的结果却不同,这是怎么回事呢?求高人指点!
该数据和R程序见于Mixed Effects Models and Extensions in Ecology with R, P109
SAS程序是我自己写的,是不是有哪里写的不对啊?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:mixed model model Mixed mode del 程序 模型

RIKZ.txt

808 Bytes

jingju11 发表于 2012-2-28 09:57:15 |显示全部楼层 |坛友微信交流群
...
hi, there:
First of all, i would check if they are using the same method; as i know, for SAS, it is REML as default; what about R? it may be ML;if that is true, you would expect some difference in the results.\\jingju

使用道具

zhsh5518 发表于 2012-2-28 10:01:12 |显示全部楼层 |坛友微信交流群
多谢jingju的回复,但是就这个例子来说,SAS和R是一样的,都是REML,不知道问题在哪里?

使用道具

jingju11 发表于 2012-2-28 10:23:30 |显示全部楼层 |坛友微信交流群
you are right. the default for R is reml too. so, what do you mean the resuts are different? jingju

使用道具

zhsh5518 发表于 2012-2-28 10:33:20 |显示全部楼层 |坛友微信交流群
运行上述程序后R的结果是:
Linear mixed-effects model fit by REML
Data: a
       AIC      BIC    logLik
  244.3839 254.9511 -116.1919

Random effects:
Formula: ~1 + NAP | fBeach
Structure: General positive-definite, Log-Cholesky parametrization
            StdDev   Corr  
(Intercept) 3.549100 (Intr)
NAP         1.715015 -0.99
Residual    2.702785      

Fixed effects: Richness ~ NAP
                Value Std.Error DF   t-value p-value
(Intercept)  6.588729 1.2647708 35  5.209425   0e+00
NAP         -2.830029 0.7229514 35 -3.914549   4e-04
而SAS的结果是:
The Mixed Procedure

                                                     Fit Statistics

                                          -2 Res Log Likelihood           238.0
                                          AIC (smaller is better)         244.0
                                          AICC (smaller is better)        244.6
                                          BIC (smaller is better)         244.6


                                              Type 3 Tests of Fixed Effects

                                                    Num     Den
                                      Effect         DF      DF    F Value    Pr > F

                                      Intercept       1       8      29.53    0.0006
                                      NAP             1       8      14.51    0.0052
可见两种结果在AIC,BIC, 分母自由度,及最终的P值上都有不同!问题到底出在哪里呢?

使用道具

jingju11 发表于 2012-2-28 10:46:43 |显示全部楼层 |坛友微信交流群
in sas, df =3 were used but it is 6 in r. so, i doubut the group effect in r can be identical to subject effect in sas.//jingju

使用道具

zhsh5518 发表于 2012-2-28 10:57:06 |显示全部楼层 |坛友微信交流群
JINGJU能否解释清楚点?你说的我不大明白还是。

使用道具

jingju11 发表于 2012-2-29 10:47:56 |显示全部楼层 |坛友微信交流群
Bates thinks, that is something about different contrasts used. i dont understand that. jingju

使用道具

yijiaobani 发表于 2016-8-2 11:25:30 |显示全部楼层 |坛友微信交流群
默认的设置不一样,你可以看到在混线性模型中,SAS、R、ASReml得到的AIC和BIC都不一样。
但方差组分和标准误是一致的。

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-3-28 18:35