I would be very much interested to use a multinomial model with random effects (for a mixed multinomial logistic regression using R).
For the present study, I already analysed independent variables with 2 categories using models of this type:
modele<-glmer(A~ B + C
+(1|Ra)+(1|Rb),family=“binomial”,data=table1)
My independent variable was “A” (with 2 nominal categories).
My two fixed variables were “B” (with 2 nominal categories) and “C” (with 3 nominal categories).
My two random variables were “Ra” and “Rb”.
However, I also have to analyse independent variables with 3 or more nominal categories.
Could you please tell me how I can use “bmrs” for mixed multinomial models? For instance by giving me an example to analyse the independent variable “X” (3 nominal categories) with the same fixed and random variables that I mentioned above.
I thank you very much in advance for your response and your help.
Best regards,
If you have an outcome that is categorical (not ordered categorical) then you can use the categorical() or multinomial() families in brms, e.g., if y consists of >2 categories, and you have two population-level predictors and two group-level predictors one way to model it in brms could be,
brm(y ~ B + C + (1 | Ra) + (1 | Rb), family = cumulative, data = d)
If you want to set a prior on a two-level predictor then it might be sane to code it as 1/2 and not 0/1 in order to set priors in a more straightforward way.
Hi Torkar,
Thanks a lot for your message and your help.
Following your advice, I ran this model:
brm(y ~ B + C + (1 | Ra) + (1 | Rb), family = categorical, data = d)
However, I got these error and warning messages:
Compiling Stan program…
trying URL ‘https://cran.rstudio.com/bin/windows/Rtools/Rtools35.exe’
Content type ‘application/x-msdownload’ length 108622512 bytes (103.6 MB)
downloaded 103.6 MB
Thanks for your quick reply.
I closed my session and reopened Rstudio to run the above-mentioned model again. However, I got these error and warning messages:
Compiling Stan program…
make cmd is
make -f “C:/PROGRA~1/R/R-36~1.3/etc/x64/Makeconf” -f “C:/PROGRA~1/R/R-36~1.3/share/make/winshlib.mk” CXX=‘(CXX11) (CXX11STD)’ CXXFLAGS=‘(CXX11FLAGS)' CXXPICFLAGS='(CXX11PICFLAGS)’ SHLIB_LDFLAGS=‘(SHLIB_CXX11LDFLAGS)' SHLIB_LD='(SHLIB_CXX11LD)’ SHLIB=“file106047a54bf1.dll” WIN=64 TCLBIN=64 OBJECTS=“file106047a54bf1.o”
make would use
if test “zfile106047a54bf1.o” != “z”; then
if test -e “file106047a54bf1-win.def”; then
echo C:/RBuildTools/3.5/mingw_64/bin/g++ -shared -s -static-libgcc -o file106047a54bf1.dll file106047a54bf1-win.def file106047a54bf1.o “C:/Users/Pianobot/Documents/R/win-library/3.6/rstan/lib/x64/libStanServices.a” -L"C:/Users/Pianobot/Documents/R/win-library/3.6/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/Pianobot/Documents/R/win-library/3.6/RcppParallel/lib/x64" -ltbb -L"C:/PROGRA~1/R/R-36~1.3/bin/x64" -lR ;
C:/RBuildTools/3.5/mingw_64/bin/g++ -shared -s -static-libgcc -o file106047a54bf1.dll file106047a54bf1-win.def file106047a54bf1.o “C:/Users/Pianobot/Documents/R/win-library/3.6/rstan/lib/x64/libStanServices.a” -L"C:/Users/Pianobot/Documents/R/win-library/3.6/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/Pianobot/Documents/R/win-library/3.6/RcppParallel/lib/x64" -ltbb -L"C:/PROGRA~1/R/R-36~1.3/bin/x64" -lR ;
else
echo EXPORTS > tmp.def;
C:/RBuildTools/3.5/mingw_64/bin/nm file106047a54bf1.o | sed -n ‘s/^.* [BCDRT] / /p’ | sed -e ‘/[.]refptr[.]/d’ -e ‘/[.]weak[.]/d’ | sed ‘s/[^ ][^ ]*/“&”/g’ >> tmp.def;
echo C:/RBuildTools/3.5/mingw_64/bin/g++ -shared -s -static-libgcc -o file106047a54bf1.dll tmp.def file106047a54bf1.o “C:/Users/Pianobot/Documents/R/win-library/3.6/rstan/lib/x64/libStanServices.a” -L"C:/Users/Pianobot/Documents/R/win-library/3.6/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/Pianobot/Documents/R/win-library/3.6/RcppParallel/lib/x64" -ltbb -L"C:/PROGRA~1/R/R-36~1.3/bin/x64" -lR ;
C:/RBuildTools/3.5/mingw_64/bin/g++ -shared -s -static-libgcc -o file106047a54bf1.dll tmp.def file106047a54bf1.o “C:/Users/Pianobot/Documents/R/win-library/3.6/rstan/lib/x64/libStanServices.a” -L"C:/Users/Pianobot/Documents/R/win-library/3.6/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/Pianobot/Documents/R/win-library/3.6/RcppParallel/lib/x64" -ltbb -L"C:/PROGRA~1/R/R-36~1.3/bin/x64" -lR ;
rm -f tmp.def;
fi
fi
Error in compileCode(f, code, language = language, verbose = verbose) :
file106047a54bf1.o:file106047a54bf1.cpp:(.data$_ZZN5boost4math6detail9bessel_y0IeNS0_8policies6policyINS3_13promote_floatILb0EEENS3_14promote_doubleILb0EEENS3_14default_policyES9_S9_S9_S9_S9_S9_S9_S9_S9_S9_EEEET_SB_RKT0_E2P1[_ZZN5boost4math6detail9bessel_y0IeNS0_8policies6policyINS3_13promote_floatILb0EEENS3_14promote_doubleILb0EEENS3_14default_policyES9_S9_S9_S9_S9_S9_S9_S9_S9_S9_EEEET_SB_RKT0_E2P1]+0x0): first defined hereC:/Users/Pianobot/Documents/R/win-library/3.6/rstan/lib/x64/libStanServices.a(stan_fit.o):stan_fit.cpp:(.rdata$_ZZN5boost4math6detail9bessel_y0IeNS0_8policies6policyINS3_13promote_floatILb0EEENS3_14promote_doubleILb0EEENS3_14default_policyES9_S9_S9_S9_S9_S9_S9_S9_S9_S9_EEEET_SB_RKT0_E2Q2[_ZZN5boost4math6detail9bessel_y0IeNS0_8policies6policyINS3_13promote_floatILb0EEENS3_14promote_doubleILb0EEENS3_14default_policyES9_S9_S9_S9_S9_S9_S9_S9_S9_S9_EEEET_SB_RKT0_E2Q2]+0x0): multiple definition of `long double boost::math::detail::bessel_y0<long double, boost::ma
In addition: Warning messages:
1: Rows containing NAs were excluded from the model.
2: In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘-E’ not found
Error in sink(type = “output”) : invalid connection