Hi there,
I am confused on how to set up the names of the parameters for calculating new quantities. As you can see below, the parameter name I used ‘b_reactgm_c_group‘ is exactly the one stan used, then I still got this error. Please help!
> library(brms)
Loading 'brms' package (version 2.23.0). Useful instructions
can be found by typing help('brms'). A more detailed introduction
to the package is available through vignette('brms_overview').
The following object is masked from ‘package:stats’:
ar
> f1=bf(nagatie_body_image_zjf~ c_judge + c_react+ c_time+react_gm+judge_gm+c_group+c_gender+c_age+(1|id))
> f2=bf(react_gm~c_group+c_qp+int)
> f3=bf(judge_gm~c_group+c_qp+int)
>
> p=get_prior(f1+f2+f3+set_rescor(F),data=dat)
> # flat prior
> p
prior class coef group resp dpar nlpar lb ub tag source
(flat) b judgegm default
(flat) b c_group judgegm (vectorized)
(flat) b c_qp judgegm (vectorized)
(flat) b int judgegm (vectorized)
student_t(3, 0, 2.5) Intercept judgegm default
student_t(3, 0, 2.5) sigma judgegm 0 default
(flat) b nagatiebodyimagezjf default
(flat) b c_age nagatiebodyimagezjf (vectorized)
(flat) b c_gender nagatiebodyimagezjf (vectorized)
(flat) b c_group nagatiebodyimagezjf (vectorized)
(flat) b c_judge nagatiebodyimagezjf (vectorized)
(flat) b c_react nagatiebodyimagezjf (vectorized)
(flat) b c_time nagatiebodyimagezjf (vectorized)
(flat) b judge_gm nagatiebodyimagezjf (vectorized)
(flat) b react_gm nagatiebodyimagezjf (vectorized)
student_t(3, 3.2, 2.5) Intercept nagatiebodyimagezjf default
student_t(3, 0, 2.5) sd nagatiebodyimagezjf 0 default
student_t(3, 0, 2.5) sd id nagatiebodyimagezjf 0 (vectorized)
student_t(3, 0, 2.5) sd Intercept id nagatiebodyimagezjf 0 (vectorized)
student_t(3, 0, 2.5) sigma nagatiebodyimagezjf 0 default
(flat) b reactgm default
(flat) b c_group reactgm (vectorized)
(flat) b c_qp reactgm (vectorized)
(flat) b int reactgm (vectorized)
student_t(3, 0, 2.5) Intercept reactgm default
student_t(3, 0, 2.5) sigma reactgm 0 default
> fit_flat_prior=brm(f1+f2+f3+set_rescor(F),data=dat,iter=10000,cores = 12,backend='cmdstanr',silent=2)
> fit_flat_prior
Family: MV(gaussian, gaussian, gaussian)
Links: mu = identity
mu = identity
mu = identity
Formula: nagatie_body_image_zjf ~ c_judge + c_react + c_time + react_gm + judge_gm + c_group + c_gender + c_age + (1 | id)
react_gm ~ c_group + c_qp + int
judge_gm ~ c_group + c_qp + int
Data: dat (Number of observations: 86)
Draws: 4 chains, each with iter = 10000; warmup = 5000; thin = 1;
total post-warmup draws = 20000
Multilevel Hyperparameters:
~id (Number of levels: 43)
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
sd(nagatiebodyimagezjf_Intercept) 0.48 0.08 0.34 0.65 1.00 5826 10265
Regression Coefficients:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
nagatiebodyimagezjf_Intercept 3.13 0.08 2.97 3.30 1.00 9062 12030
reactgm_Intercept 0.02 0.05 -0.07 0.11 1.00 37909 14542
judgegm_Intercept 0.01 0.05 -0.09 0.11 1.00 32985 12754
nagatiebodyimagezjf_c_judge 0.32 0.12 0.09 0.55 1.00 32814 15552
nagatiebodyimagezjf_c_react 0.27 0.10 0.07 0.47 1.00 25462 16128
nagatiebodyimagezjf_c_time 0.26 0.10 0.05 0.46 1.00 24076 15933
nagatiebodyimagezjf_react_gm 0.74 0.19 0.36 1.11 1.00 9343 11736
nagatiebodyimagezjf_judge_gm 0.28 0.19 -0.09 0.65 1.00 10472 12396
nagatiebodyimagezjf_c_group -0.02 0.18 -0.38 0.34 1.00 9890 12395
nagatiebodyimagezjf_c_gender -0.31 0.20 -0.70 0.07 1.00 9665 12039
nagatiebodyimagezjf_c_age -0.01 0.04 -0.08 0.06 1.00 9950 11906
reactgm_c_group 0.35 0.09 0.16 0.53 1.00 35374 14338
reactgm_c_qp -0.17 0.04 -0.25 -0.08 1.00 33561 14843
reactgm_int -0.29 0.09 -0.47 -0.12 1.00 34503 13811
judgegm_c_group 0.34 0.10 0.14 0.53 1.00 32713 14003
judgegm_c_qp -0.12 0.05 -0.22 -0.03 1.00 33935 14375
judgegm_int -0.19 0.09 -0.38 -0.01 1.00 34639 13808
Further Distributional Parameters:
Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
sigma_nagatiebodyimagezjf 0.36 0.04 0.29 0.46 1.00 7180 9966
sigma_reactgm 0.42 0.03 0.36 0.50 1.00 31294 14195
sigma_judgegm 0.46 0.04 0.39 0.54 1.00 31911 14828
Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
and Tail_ESS are effective sample size measures, and Rhat is the potential
scale reduction factor on split chains (at convergence, Rhat = 1).
> med_stanvars=stanvar(scode='real med=b_reactgm_c_group * b_nagatiebodyimagezjf_react_gm;',block='genquant')
> fit_flat_prior=brm(f1+f2+f3+set_rescor(F),stanvars=med_stanvars,data=dat,iter=10000,cores = 12,backend='cmdstanr',silent=2)
Error : An error occured during compilation! See the message above for more information.
Compiling Stan program...
Semantic error in 'C:/Users/HUAWEI/AppData/Local/Temp/RtmpC2svtE/model-c80778b34d1.stan', line 104, column 11 to column 28:
-------------------------------------------------
102: // actual population-level intercept
103: real b_judgegm_Intercept = Intercept_judgegm - dot_product(means_X_judgegm, b_judgegm);
104: real med=b_reactgm_c_group * b_nagatiebodyimagezjf_react_gm;
^
105: }
106:
-------------------------------------------------
Identifier 'b_reactgm_c_group' not in scope.
make: *** [make/program:66: C:/Users/HUAWEI/AppData/Local/Temp/RtmpC2svtE/model-c80778b34d1.hpp] Error 1
Error: An error occured during compilation! See the message above for more information.
> names(as.data.frame(fit_flat_prior))
[1] "b_nagatiebodyimagezjf_Intercept" "b_reactgm_Intercept" "b_judgegm_Intercept"
[4] "b_nagatiebodyimagezjf_c_judge" "b_nagatiebodyimagezjf_c_react" "b_nagatiebodyimagezjf_c_time"
[7] "b_nagatiebodyimagezjf_react_gm" "b_nagatiebodyimagezjf_judge_gm" "b_nagatiebodyimagezjf_c_group"
[10] "b_nagatiebodyimagezjf_c_gender" "b_nagatiebodyimagezjf_c_age" "b_reactgm_c_group"
[13] "b_reactgm_c_qp" "b_reactgm_int" "b_judgegm_c_group"
[16] "b_judgegm_c_qp" "b_judgegm_int" "sd_id__nagatiebodyimagezjf_Intercept"
[19] "sigma_nagatiebodyimagezjf" "sigma_reactgm" "sigma_judgegm"
[22] "Intercept_nagatiebodyimagezjf" "Intercept_reactgm" "Intercept_judgegm"
> sessionInfo()$running
[1] "Windows 11 x64 (build 26100)"
> packageVersion("brms")
[1] ‘2.23.0’
> packageVersion("cmdstanr")
[1] ‘0.9.0’
> library(cmdstanr)
This is cmdstanr version 0.9.0
- CmdStanR documentation and vignettes: mc-stan.org/cmdstanr
- CmdStan path: C:/Users/HUAWEI/.cmdstan/cmdstan-2.37.0
- CmdStan version: 2.37.0