全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 HLM专版
1455 0
2014-01-10
Hello !

I have been using the code below to fit a random intercepts (variance components) model.

data {
    int<lower=1> n2 ;  
    int<lower=1> N ;
    real y[N] ;
    int school[N] ;
}
parameters {
    real u2_z[n2] ;
    real<lower=.1,upper=100> sigma ;
    real<lower=.1,upper=100> sigma_u2;
    real <lower=0,upper=1000> beta;
}
model {
    real mu[N];
    for (i in 1:N)
      mu <- beta + u2_z[school] * sigma_u2;

    y ~ normal(mu,sigma);
    u2_z ~ normal(0, 1) ;
}

This would be fitted in lme4 as
lmer(outcome ~1 + (1|school.ID),data=dt.all)
I now want to include a term for random slope, which would be fitted in lme4 as

lmer(outcome ~1 + (year|school.ID),data=dt.all)
or
lmer(outcome ~1 + (year-1|school.ID),data=dt.all)

The variable year is a factor with 3 levels., Please can anyone help me modify the stan model?
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群