reduce sum is not available on the rstan on CRAN. You can try the experimental version below or use cmdstanr
remotes::install_git("https://github.com/stan-dev/rstan", subdir = "StanHeaders", ref = "experimental")
remotes::install_git("https://github.com/stan-dev/rstan", subdir = "rstan/rstan", ref = "experimental")