Hello everyone,<br>I'm working to get some predictions using ARIMA model in R. This is the code I'm using, at it works as expected:<br><br><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">
library(TSA)<br>load(' path... /R/i686-pc-linux-gnu-library/2.14/TSA/data/airpass.rda')<br>show(airpass)<br>m <- arima(airpass,order=c(0,1,12),seasonal=list(order=c(0,1,1),period=24))<br>m<br>plot(m,n.ahead=72,xlab='Time',type='o',ylab='Passengers')<br>
abline(h=0)<br></blockquote><br>I use example data from the TSA package, and the prediction is plotted well.<br>The issue is that what I really want is use it within a bigger C++ project, so I need to use RInside package. I've tested every example of RInside, and it seems perfectly operative in my machine.<br>
I have programmed it like this:<br><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">//Ejemplo que carga los datos airpass.rda del package TSA y realiza una prediccion ARIMA sobre ellos<br>
#include <RInside.h> // for the embedded R via RInside<br>int main(int argc, char *argv[]) {<br> RInside R(argc, argv); // create an embedded R instance<br> std::string evalstr = "library(TSA); load(' ...path... /R/i686-pc-linux-gnu-library/2.14/TSA/data/airpass.rda'); show(airpass);"; //Cargamos la libreria TSA necesaria y el archivo de datos<br>
R.parseEvalQ(evalstr);<br> std::string evalstr2 = "m <- arima(airpass,order=c(0,1,12),seasonal=list(order=c(0,1,1),period=24)); m"; //Calculo de la prediccion sobre los datos. Coeficientes manualmente precalculados<br>
R.parseEvalQ(evalstr2);<br> std::string evalstr3 = "plot(m,n.ahead=72,xlab='Tiempo',type='o',ylab='Pasajeros'); abline(h=0)"; //Dibujamos los datos y la prediccion.<br> R.parseEvalQ(evalstr3);<br>
std::string evalstr4 = "cat('AIC del modelo:\n'); m$aic"; //Muestra el estimador de bondad AIC<br> R.parseEvalQ(evalstr4);<br><br> exit(0);<br>}<br></blockquote><div>(The comments are in spanish, sorry)<br>
When I run this code, the output of the first evalstr is the same that in R. TSA & airpass are loaded correctly. But the next line seems not to work.<br>It tooks several seconds calculating arima model, but it the problem is that "m" command to show the model produces no output, the same that "m$aic". With "no output" I mean nothing (including any error).<br>
I can't get the graphic too, but I know that maybe I would have to plot to a file to get it work. The problem is that I also get no error. This is the output of my code (there are some warning lines at the beginning, but the rest of examples always worked with the same lines):<br>
<blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">During startup - Warning messages:<br>1: Setting LC_CTYPE failed, using "C" <br>2: Setting LC_COLLATE failed, using "C" <br>
3: Setting LC_TIME failed, using "C" <br>4: Setting LC_MESSAGES failed, using "C" <br>5: Setting LC_PAPER failed, using "C" <br>6: Setting LC_PAPER failed, using "C" <br>7: Setting LC_MEASUREMENT failed, using "C" <br>
Loading required package: leaps<br>Loading required package: locfit<br>Loading required package: akima<br>Loading required package: lattice<br>locfit 1.5-6 2010-01-20 <br>Loading required package: mgcv<br>This is mgcv 1.7-9. For overview type 'help("mgcv-package")'.<br>
Loading required package: tseries<br>Loading required package: quadprog<br>Loading required package: zoo<br><br>Attaching package: 'zoo'<br><br>The following object(s) are masked from 'package:base':<br><br>
as.Date, as.Date.numeric<br><br><br>Attaching package: 'TSA'<br><br>The following object(s) are masked from 'package:stats':<br><br> acf, arima<br><br>The following object(s) are masked from 'package:utils':<br>
<br> tar<br><br> Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec<br>1960 112 118 132 129 121 135 148 148 136 119 104 118<br>1961 115 126 141 135 125 149 170 170 158 133 114 140<br>1962 145 150 178 163 172 178 199 199 184 162 146 166<br>
1963 171 180 193 181 183 218 230 242 209 191 172 194<br>1964 196 196 236 235 229 243 264 272 237 211 180 201<br>1965 204 188 235 227 234 264 302 293 259 229 203 229<br>1966 242 233 267 269 270 315 364 347 312 274 237 278<br>
1967 284 277 317 313 318 374 413 405 355 306 271 306<br>1968 315 301 356 348 355 422 465 467 404 347 305 336<br>1969 340 318 362 348 363 435 491 505 404 359 310 337<br>1970 360 342 406 396 420 472 548 559 463 407 362 405<br>
1971 417 391 419 461 472 535 622 606 508 461 390 432<br>AIC del modelo:<br></blockquote><div> </div><div>I have tried everything that came to my mind, and I have no more ideas! I think I have explained my best, hope somebody can help me with this.<br>
Sorry if I made some language mistake ;) Thank you very much!<br></div></div>