1

I am trying to run the following code but it throws an error in last line. Can anybody tell me what I am doing wrong? I took the code from an article, it goes well until I cook the model with dynr.cook() function.

The article is as follows:

What’s for dynr: A Package for Linear and Nonlinear Dynamic Modeling in R by Lu Ou+, Michael D. Hunter+, and Sy-Miin Chow:

# install.packages("dynr")
library(dynr)

data("EMG")

EMGdata <- dynr.data(EMG, id = 'id', time = 'time',
  observed = 'iEMG', covariates = 'SelfReport')

recMeas <- prep.measurement(
  values.load = rep(list(matrix(1, 1, 1)), 2),
  values.int = list(matrix(4, 1, 1), matrix(3, 1, 1)),
  params.int = list(matrix('mu_1', 1, 1), matrix('mu_2', 1, 1)),
  values.exo = list(matrix(0, 1, 1), matrix(1, 1, 1)),
  params.exo = list(matrix('fixed', 1, 1), matrix('beta_2', 1, 1)),
  obs.names = c('iEMG'),
  state.names = c('eta'),
  exo.names = c("SelfReport"))

head(EMG)

recDyn <- prep.matrixDynamics(
  values.exo = list(matrix(1, 1, 1), matrix(1, 1, 1)),
  params.exo = list(matrix('zeta1', 1, 1), matrix('zeta_2', 1, 1)),
  values.dyn = list(matrix(.1, 1, 1), matrix(.5, 1, 1)),
  params.dyn = list(matrix('phi_1', 1, 1), matrix('phi_2', 1, 1)),
  covariates = 'eta' , isContinuousTime = FALSE)

recNoise <- prep.noise(values.latent = matrix(1, 1, 1),
  params.latent = matrix('dynNoise', 1, 1),
  values.observed = matrix(0, 1, 1), params.observed = matrix('fixed', 1, 1))

recReg <- prep.regimes(values = matrix(c(0.7, -1, 0, 0), 2, 2),
  params = matrix(c('c11', 'c21', 'fixed', 'fixed'), 2, 2))

recIni <- prep.initial(
  values.inistate = matrix(0, 1, 1),
  params.inistate = matrix('fixed', 1, 1),
  values.inicov = matrix(1, 1, 1),
  params.inicov = matrix('fixed', 1, 1),
  values.regimep = c(1, 0),
  params.regimep = c('fixed', 'fixed'))
Oi, Chap! I found 1 regime for 'values.inistate'  but 2 regimes elsewhere, so I extended the initial states to match.
If this is what you wanted, all is sunshine and puppy dogs.
Oi, Chap! I found 1 regime for 'values.inicov'  but 2 regimes elsewhere, so I extended the initial covariances to match.
If this is what you wanted, all is sunshine and puppy dogs

rsmod <- dynr.model(dynamics = recDyn, measurement = recMeas,
  noise = recNoise, initial = recIni, regimes = recReg,
  data = EMGdata, outfile = "RSLinearDiscreteYang.c")

yum <- dynr.cook(rsmod)

Setting PKG_CPPFLAGS to -I"/include" 
Setting PKG_LIBS to -L"/lib/x64" -lgsl -lgslcblas 
Compilation argument:
 C:/PROGRA~1/R/R-36~1.1/bin/x64/R CMD SHLIB RSLinearDiscreteYang.c 2> RSLinearDiscreteYang.c.err.txt 
Warning message:
In system(cmd) : 'make' not found

ERROR(s) during compilation: source code errors or compiler configuration errors!

Program source:
  1: #include <math.h>
Error in CompileCode(code, language, verbose, libLFile) : 
  Compilation ERROR, function(s)/method(s) not created! Warning message:
In system(cmd) : 'make' not found
yuri
  • 3,182
  • 2
  • 16
  • 26
Ali
  • 11
  • 2
  • Do you have [Rtools](https://cran.r-project.org/bin/windows/Rtools/) installed by any chance? – Roman Luštrik Dec 24 '19 at 18:21
  • Should I install it using `install.packages("Rtools")` command – Ali Dec 25 '19 at 03:54
  • when I downloaded and install, it says an older version of Rtools is already installed but I replaced it but still have error, Moroever there was a red message also in `prep.initial()` function , it may not be warning and may not be error but it appears in red font in R, I have just edited that in my question, if you could fin it appears after `prep.initial()` function – Ali Dec 25 '19 at 04:41
  • [This question](https://stackoverflow.com/questions/53279685/r-make-not-found-when-installing-a-r-package-from-local-tar-gz) seems to have a similar problem and it was solved by installing Rtools. I would suspect you do not have PATH set. I hope you restarted R after installing Rtools. – Roman Luštrik Dec 26 '19 at 19:42

0 Answers0