Problems with rstan::stan_model

So I am currently running this code in R.

use_data ← au.data[au.data$date >=“1983-03-31”,]

au.inflation ← use_data$inflation
au.inflation.expectations ← use_data$inflation.expectations
au.labour.costs.growth ← use_data$labour.costs.growth
au.unemployment ← use_data$unemployment
au.imports.price.growth ← use_data$imports.price.growth
au.oil.price.change ← use_data$oil.price.change
au.dummy ← use_data$dummy
N ← length(au.unemployment)
stancode ← rstan::stan_model(“nairu_model.stan”, verbose = FALSE)

However, when I run the last line I get a bunch of errors as follows:
make cmd is
make -f “C:/Users/AnthonyM/AppData/Local/Programs/R/R-43~1.1/etc/x64/Makeconf” -f “C:/Users/AnthonyM/AppData/Local/Programs/R/R-43~1.1/share/make/winshlib.mk” -f “C:/Users/AnthonyM/OneDrive/Documents/.R/Makevars.win” CXX=‘(CXX14) (CXX14STD)’ CXXFLAGS=‘(CXX14FLAGS)' CXXPICFLAGS='(CXX14PICFLAGS)’ SHLIB_LDFLAGS=‘(SHLIB_CXX14LDFLAGS)' SHLIB_LD='(SHLIB_CXX14LD)’ SHLIB=“file2ce02a17e32.dll” WIN=64 TCLBIN= OBJECTS=“file2ce02a17e32.o”

make would use
if test “zfile2ce02a17e32.o” != “z”; then
if test -e “file2ce02a17e32-win.def”; then
echo g++ -std=c++1y -shared -s -static-libgcc -o file2ce02a17e32.dll file2ce02a17e32-win.def file2ce02a17e32.o -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib" -L"C:/Users/AnthonyM/AppData/Local/Programs/R/R-43~1.1/bin/x64" -lR ;
g++ -std=c++1y -shared -s -static-libgcc -o file2ce02a17e32.dll file2ce02a17e32-win.def file2ce02a17e32.o -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib" -L"C:/Users/AnthonyM/AppData/Local/Programs/R/R-43~1.1/bin/x64" -lR ;
else
echo EXPORTS > tmp.def;
C:/RBuildTools/4.2/mingw64/bin/nm file2ce02a17e32.o | sed -n ‘s/^.* [BCDRT] / /p’ | sed -e ‘/[.]refptr[.]/d’ -e ‘/[.]weak[.]/d’ | sed ‘s/[^ ][^ ]*/“&”/g’ >> tmp.def;
echo g++ -std=c++1y -shared -s -static-libgcc -o file2ce02a17e32.dll tmp.def file2ce02a17e32.o -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib" -L"C:/Users/AnthonyM/AppData/Local/Programs/R/R-43~1.1/bin/x64" -lR ;
g++ -std=c++1y -shared -s -static-libgcc -o file2ce02a17e32.dll tmp.def file2ce02a17e32.o -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib" -L"C:/Users/AnthonyM/AppData/Local/Programs/R/R-43~1.1/bin/x64" -lR ;
rm -f tmp.def;
fi
fi

Note I have the latest Rstan and StanHeaders package. Do you guys have any idea why this could be happening?

Can you post the full output from running:

example(stan_model, package="rstan", run.dontrun=T)

Sure, see below the output from running the following code:

Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) :
C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: file50082add5b74.o:file50082add5b74.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D0Ev[_ZN3tbb8internal26task_scheduler_observer_v3D0Ev]+0x1c): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: file50082add5b74.o:file50082add5b74.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x1c): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: file50082add5b74.o:file50082add5b74.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x37): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: file50082add5b74.o:file50082add5b74.cpp:(.text$_ZN3tbb10interface

Bit confused what is going on here.

Try reinstalling from source:

install.packages(c("rstan","StanHeaders"),type = "source")

Tried this and reran the following:

stancode ← rstan::stan_model(“nairu_model.stan”, verbose = FALSE)
make cmd is
make -f “C:/Users/AnthonyM/AppData/Local/Programs/R/R-43~1.1/etc/x64/Makeconf” -f “C:/Users/AnthonyM/AppData/Local/Programs/R/R-43~1.1/share/make/winshlib.mk” -f “C:/Users/AnthonyM/OneDrive/Documents/.R/Makevars.win” CXX=‘(CXX14) (CXX14STD)’ CXXFLAGS=‘(CXX14FLAGS)' CXXPICFLAGS='(CXX14PICFLAGS)’ SHLIB_LDFLAGS=‘(SHLIB_CXX14LDFLAGS)' SHLIB_LD='(SHLIB_CXX14LD)’ SHLIB=“file1cfc137462.dll” WIN=64 TCLBIN= OBJECTS=“file1cfc137462.o”

make would use
if test “zfile1cfc137462.o” != “z”; then
if test -e “file1cfc137462-win.def”; then
echo g++ -std=c++1y -shared -s -static-libgcc -o file1cfc137462.dll file1cfc137462-win.def file1cfc137462.o -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib" -L"C:/Users/AnthonyM/AppData/Local/Programs/R/R-43~1.1/bin/x64" -lR ;
g++ -std=c++1y -shared -s -static-libgcc -o file1cfc137462.dll file1cfc137462-win.def file1cfc137462.o -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib" -L"C:/Users/AnthonyM/AppData/Local/Programs/R/R-43~1.1/bin/x64" -lR ;
else
echo EXPORTS > tmp.def;
C:/RBuildTools/4.2/mingw64/bin/nm file1cfc137462.o | sed -n ‘s/^.* [BCDRT] / /p’ | sed -e ‘/[.]refptr[.]/d’ -e ‘/[.]weak[.]/d’ | sed ‘s/[^ ][^ ]*/“&”/g’ >> tmp.def;
echo g++ -std=c++1y -shared -s -static-libgcc -o file1cfc137462.dll tmp.def file1cfc137462.o -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib" -L"C:/Users/AnthonyM/AppData/Local/Programs/R/R-43~1.1/bin/x64" -lR ;
g++ -std=c++1y -shared -s -static-libgcc -o file1cfc137462.dll tmp.def file1cfc137462.o -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib" -L"C:/Users/AnthonyM/AppData/Local/Programs/R/R-43~1.1/bin/x64" -lR ;
rm -f tmp.def;
fi
fi
Error in compileCode(f, code, language = language, verbose = verbose) :
C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: file1cfc137462.o:file1cfc137462:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D0Ev[_ZN3tbb8internal26task_scheduler_observer_v3D0Ev]+0x1c): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: file1cfc137462.o:file1cfc137462:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x1c): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: file1cfc137462.o:file1cfc137462:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x37): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: file1cfc137462.o:file1cfc137462:(.text$ZN3tbb10interface623task_scheduler_observerD0Ev[
Error in sink(type = “output”) : invalid connection

NOTE, after installing from the source (older version) and then reupdating to the newer version the stan_model code works now!

THANKS! :)