[R] doubt with auto.arima
hello, i have a doubt with this function, i need get the returns values because i have to save in a variables,something like this: Invernadero<-ts(x2) test<-auto.arima(x2) x2.pred.ar31<-predict(arima(x2,order=c(p,d,q)),n.ahead=10)$pred can i get "p","d" and "q" from "auto.arima"?this is my question. I hope have explained well, A regards. -- View this message in context: http://r.789695.n4.nabble.com/doubt-with-auto-arima-tp469p469.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] doubt with auto.arima
hello, i have a doubt with this function, i need get the returns values because i have to save in a variables,something like this: Invernadero<-ts(x2) test<-auto.arima(x2) x2.pred.ar31<-predict(arima(x2,order=c(p,d,q)),n.ahead=10)$pred can i get "p","d" and "q" from "auto.arima"?this is my question. I hope have explained well, A regards. -- This message was sent on behalf of yonosoyelme...@hotmail.com at openSubscriber.com http://www.opensubscriber.com/message/r-help@r-project.org/11277758.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Arguments
hello,I would like to ask a question,Is there any way to pass arguments to a script?I have this code: Invernadero<-read.table(file.choose(),header=T,sep=",") attach(Invernadero) names(Invernadero) Invernadero<-ts(Invernadero<-argument) //Here introduce the argument plot(Hora,Invernadero,main=arguemtn,xlab="Tiempo",ylab=argument) Thanks for your attention,I hope your answers. Cheers, Ignacio. -- View this message in context: http://old.nabble.com/Arguments-tp26539736p26539736.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re adline()
Is that what I did is to link it directly, then I click on it and I was launching the console run,but try it another way, what I did was use vectors and so I saved it.So we can conclude the issue,thank you very much indeed for your help Cheers Ignacio. JorisMeys wrote: > > I run your script from the windows console (evidently), and as said, I > can't reproduce your error. Can you give me the exact command you use > to run it from the windows console? > > Cheers > Joris > > On Tue, Nov 24, 2009 at 7:33 PM, yonosoyelmejor > wrote: >> >> Sure,but my problem is that the script is run from the console >> windows,therefore I believe that the cat or readline doesn´t work... >> >> JorisMeys wrote: >>> >>> I can't reproduce the error you have. With me, it runs all fine. In >>> fact, readline apparently flushes automatically, as I didn't have to >>> use the flush.console() at all. >>> >>> test.r >>> --- >>> cat("1- 24horas\n") >>> cat("2- 12horas\n") >>> cat("3- 8horas\n") >>> selection<-readline(prompt="\nSelecciona numero de horas:") >>> >>> if(selection=="1"){ >>> cat("Selection1\n") >>> } >>> if(selection=="2"){ >>> cat("Selection2\n") >>> } >>> if(selection=="3"){ >>> cat("Selection3\n") >>> } >>> >>> source("G:/Temp/test.r") # load the saved script "test.r" >>> >>> >>> You can try to look at ?announce (package odfWeave) instead of cat and >>> flush.console, but I have the slight impression there is something >>> else going wrong. >>> >>> Cheers >>> Joris >>> >>> >>> On Tue, Nov 24, 2009 at 11:10 AM, yonosoyelmejor >>> wrote: >>>> >>>> I put that before selection but Nothing happened...I don´t know because >>>> when >>>> I executed the code, in the console doesn´t show cat("1-24hours)...and >>>> neither asked me Select numers of hours from de line or readline... >>>> >>>> Peter Dalgaard wrote: >>>>> >>>>> yonosoyelmejor wrote: >>>>>> Hello, I would like to ask you a question.I have a program in R and I >>>>>> use >>>>>> the >>>>>> readline method to ask the user some things,but i don´t use the R >>>>>> console >>>>>> but I use Win console then not appear what I put.I put the code as >>>>>> you >>>>>> look >>>>>> for: >>>>>> >>>>>> cat("1- 24horas\n") >>>>>> cat("2- 12horas\n") >>>>>> cat("3- 8horas\n") >>>>>> selection<-readline(prompt="\nSelecciona numero de horas:") >>>>>> >>>>>> if(selection=="1"){ >>>>>> prediccion=exp(x.reconstruida[1441:1450]) >>>>>> } >>>>>> if(selection=="2"){ >>>>>> prediccion=exp(x.reconstruida[720:729]) >>>>>> } >>>>>> if(selection=="3"){ >>>>>> prediccion=exp(x.reconstruida[481:491]) >>>>>> } >>>>>> >>>>>> write.table(prediccion,"C:\\Temp\\prePrueba.txt",quote=F,row.names=F,append=T,col.names=F) >>>>>> >>>>>> >>>>>> //end of code. >>>>>> >>>>>> Excuse me but my English is bad, i hope explained me well, >>>>>> >>>>>> A greeting, >>>>>> Ignacio. >>>>>> >>>>>> >>>>> >>>>> I think this is a matter of flushing the console before the readline >>>>> call. See ?flush.console >>>>> >>>>> -pd >>>>> >>>>> -- >>>>> O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B >>>>> c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K >>>>> (*) \(*) -- University of Copenhagen Denmark Ph: (+45) >>>>> 35327918 >>>>> ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) >>>>> 35327907 >>>>> >>>>> __ >>>>>
Re: [R] Method
You are right,but I´ll explain,my code creates a time series,after some transformations I need to make a prediction,which predicts 10values using the above,then written in a file,I put the code to see if it looks better: # TODO: Add comment # # Author: Ignacio2 ### library(TSA) library(tseries) Invernadero<-read.table(file.choose(),header=T,sep=",") attach(Invernadero) names(Invernadero) Invernadero<-ts(Invernadero<-Temp..Ext) plot(Hora,Invernadero,main="Temperatura Ext. Invernadero",xlab="Tiempo",ylab="Temperatura Ext.") x = log(Invernadero) #Estabilizar la varianza varianza<-function(x) { ((length(x)-1)/length(x))*var(x) }#para saber la varianza varianza(x) varianza(Invernadero) x1<-diff(x,lag=60) adf.test(x1) x2<-diff(x1,lag=1) adf.test(x2) mean(x2) # La función “ar” permite seleccionar automáticamente “el #mejor modelo #autorregresivo: ar(x2) orden <- ar(x2)$order #con esto obtenemos el orden seleccionado no toda la informacion #AIC(arima(x2,order=c(8,0,0)),arima(x2,order=c(31,0,0))) # Predicción: x2.pred.ar31<-predict(arima(x2,order=c(orden,0,0)),n.ahead=10)$pred # Errores de predicción: x2.err.ar31<-predict(arima(x2,order=c(orden,0,0)),n.ahead=10)$se plot(x2.err.ar31) #deshacer cambios x.completada<-c(x2,x2.pred.ar31) xinv1<-diffinv(x.completada,lag=1,xi=x1[1]) xinv2<-diffinv(xinv1,lag=60,xi=x[1:60]) x.reconstruida<-ts(xinv2,frequency=60) # Comprobación de que la reconstrucción fue correcta: yy<-x-x.reconstruida[1:length(x)] # esto para Hora8 ## yy debe ser una serie de 0’s plot(yy) # Las predicciones para los minutos siguientes de la serie #original son: #prediccion = exp(x.reconstruida[481:491]) #en nuestro caso pondriamos los minutos a saber. prediccion = exp(x.reconstruida[length(x)+1:length(x)+9]) ###This is what I do not work, we still need to be reusable by if I change the number of elements write.table(prediccion,"C:\\Temp\\prePrueba.txt",quote=F,row.names=F,append=T,col.names=F) Sarah Goslee wrote: > > If the last position of your vector is 1440, what do you expect to get > from 1440 + 1??? > And you certainly need some parentheses in there if you expect to get a > range of > values from your vector. > > Perhaps you need some subtraction? > > And no, we still can't tell exactly what you want. If this doesn't > answer your question, > make a reproducible example with a short vector, your code that > doesn't work, and > the _result you expect to get_ so we can help you. > > Sarah > > On Tue, Nov 24, 2009 at 1:44 PM, yonosoyelmejor > wrote: >> >> I use length(myVector),but when i want to use for example >> exp(x.reconstruida[length(myVector)+1:length(myVector)+9]), I need that >> function returns the number of last element,would then: >> >> if the last position of my vector is 1440 >> >> exp(x.reconstruida[1440+1:1440+9] >> >> This is what I need, I hope having explained, >> >> A gretting, >> Ignacio. >> > > > -- > Sarah Goslee > http://www.functionaldiversity.org > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- View this message in context: http://old.nabble.com/Method-tp26493442p26509891.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Method
Your suspicions were correct, I just try and works perfectly. Thank you very much for your help, :- Greetings, Ignacio. William Dunlap wrote: > > Message- >> From: r-help-boun...@r-project.org >> [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius >> Sent: Tuesday, November 24, 2009 12:22 PM >> To: yonosoyelmejor >> Cc: r-help@r-project.org >> Subject: Re: [R] Method >> >> >> On Nov 24, 2009, at 1:44 PM, yonosoyelmejor wrote: >> >> > >> > I use length(myVector),but when i want to use for example >> > exp(x.reconstruida[length(myVector)+1:length(myVector)+9]), I need > > This may have nothing to do with your original problem, > but I suspect that expression should be >exp(x.reconstruida[(length(myVector)+1):(length(myVector)+9)]) > or, equivalently, >exp(x.reconstruida[length(myVector)+(1:9)]) > (where the parentheses around 1:9 are not required but often > helpful for understanding). > > Compare >> 5+1:5+10 >[1] 16 17 18 19 20 >> (5+1):(5+10) > [1] 6 7 8 9 10 11 12 13 14 15 > > Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com > >> > that >> > function returns the number of last element,would then: >> > >> > if the last position of my vector is 1440 >> > >> > exp(x.reconstruida[1440+1:1440+9] > > Again, (1440+1):(1440+9) or 1440+(1:9). > >> >> So that should give you (assuming that you close the expression) a >> vector of values, "e" raised to a vector from elements 1441 to 1449, >> if such elements have already been defined and are numeric. >> > >> > This is what I need, I hope having explained, >> >> I do not think you have explained well enough. What is >> "x.reconstruida"? Does it have a longer length than myVector? >> >> Things would be much clearer if you made a small example (not 1440 >> elements long, maybe 10?). >> >> -- >> David >> > >> > A gretting, >> > Ignacio. >> > >> > Johannes Graumann-2 wrote: >> >> >> >> myVector <- c(seq(10),23,35) >> >> length(myVector) >> >> myVector[length(myVector)] >> >> >> >> it's unclear to me which of the two you want ... >> >> >> >> HTH, Joh >> >> >> >> yonosoyelmejor wrote: >> >> >> >>> >> >>> Hello, i would like to ask you another question. Is exist >> >>> anymethod to >> >>> vectors that tells me the last element?That is to say,I have a >> >>> vector, I >> >>> want to return the position of last element. I hope having >> >>> explained. >> >>> >> >>> A greeting, >> >>> Ignacio. >> >> >> >> __ >> >> R-help@r-project.org mailing list >> >> https://stat.ethz.ch/mailman/listinfo/r-help >> >> PLEASE do read the posting guide >> >> http://www.R-project.org/posting-guide.html >> >> and provide commented, minimal, self-contained, reproducible code. >> >> >> >> >> > >> > -- >> > View this message in context: >> http://old.nabble.com/Method-tp26493442p26499919.html >> > Sent from the R help mailing list archive at Nabble.com. >> > >> > __ >> > R-help@r-project.org mailing list >> > https://stat.ethz.ch/mailman/listinfo/r-help >> > PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> > and provide commented, minimal, self-contained, reproducible code. >> >> David Winsemius, MD >> Heritage Laboratories >> West Hartford, CT >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- View this message in context: http://old.nabble.com/Method-tp26493442p26510040.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Method
I use length(myVector),but when i want to use for example exp(x.reconstruida[length(myVector)+1:length(myVector)+9]), I need that function returns the number of last element,would then: if the last position of my vector is 1440 exp(x.reconstruida[1440+1:1440+9] This is what I need, I hope having explained, A gretting, Ignacio. Johannes Graumann-2 wrote: > > myVector <- c(seq(10),23,35) > length(myVector) > myVector[length(myVector)] > > it's unclear to me which of the two you want ... > > HTH, Joh > > yonosoyelmejor wrote: > >> >> Hello, i would like to ask you another question. Is exist anymethod to >> vectors that tells me the last element?That is to say,I have a vector, I >> want to return the position of last element. I hope having explained. >> >> A greeting, >> Ignacio. > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- View this message in context: http://old.nabble.com/Method-tp26493442p26499919.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re adline()
Sure,but my problem is that the script is run from the console windows,therefore I believe that the cat or readline doesn´t work... JorisMeys wrote: > > I can't reproduce the error you have. With me, it runs all fine. In > fact, readline apparently flushes automatically, as I didn't have to > use the flush.console() at all. > > test.r > --- > cat("1- 24horas\n") > cat("2- 12horas\n") > cat("3- 8horas\n") > selection<-readline(prompt="\nSelecciona numero de horas:") > > if(selection=="1"){ > cat("Selection1\n") > } > if(selection=="2"){ > cat("Selection2\n") > } > if(selection=="3"){ > cat("Selection3\n") > } > > source("G:/Temp/test.r") # load the saved script "test.r" > > > You can try to look at ?announce (package odfWeave) instead of cat and > flush.console, but I have the slight impression there is something > else going wrong. > > Cheers > Joris > > > On Tue, Nov 24, 2009 at 11:10 AM, yonosoyelmejor > wrote: >> >> I put that before selection but Nothing happened...I don´t know because >> when >> I executed the code, in the console doesn´t show cat("1-24hours)...and >> neither asked me Select numers of hours from de line or readline... >> >> Peter Dalgaard wrote: >>> >>> yonosoyelmejor wrote: >>>> Hello, I would like to ask you a question.I have a program in R and I >>>> use >>>> the >>>> readline method to ask the user some things,but i don´t use the R >>>> console >>>> but I use Win console then not appear what I put.I put the code as you >>>> look >>>> for: >>>> >>>> cat("1- 24horas\n") >>>> cat("2- 12horas\n") >>>> cat("3- 8horas\n") >>>> selection<-readline(prompt="\nSelecciona numero de horas:") >>>> >>>> if(selection=="1"){ >>>> prediccion=exp(x.reconstruida[1441:1450]) >>>> } >>>> if(selection=="2"){ >>>> prediccion=exp(x.reconstruida[720:729]) >>>> } >>>> if(selection=="3"){ >>>> prediccion=exp(x.reconstruida[481:491]) >>>> } >>>> >>>> write.table(prediccion,"C:\\Temp\\prePrueba.txt",quote=F,row.names=F,append=T,col.names=F) >>>> >>>> >>>> //end of code. >>>> >>>> Excuse me but my English is bad, i hope explained me well, >>>> >>>> A greeting, >>>> Ignacio. >>>> >>>> >>> >>> I think this is a matter of flushing the console before the readline >>> call. See ?flush.console >>> >>> -pd >>> >>> -- >>> O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B >>> c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K >>> (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 >>> ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 >>> >>> __ >>> R-help@r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> PLEASE do read the posting guide >>> http://www.R-project.org/posting-guide.html >>> and provide commented, minimal, self-contained, reproducible code. >>> >>> >> >> -- >> View this message in context: >> http://old.nabble.com/Readline%28%29-tp26476979p26493350.html >> Sent from the R help mailing list archive at Nabble.com. >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- View this message in context: http://old.nabble.com/Readline%28%29-tp26476979p26499915.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Method
Hello, i would like to ask you another question. Is exist anymethod to vectors that tells me the last element?That is to say,I have a vector, I want to return the position of last element. I hope having explained. A greeting, Ignacio. -- View this message in context: http://old.nabble.com/Method-tp26493442p26493442.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re adline()
I put that before selection but Nothing happened...I don´t know because when I executed the code, in the console doesn´t show cat("1-24hours)...and neither asked me Select numers of hours from de line or readline... Peter Dalgaard wrote: > > yonosoyelmejor wrote: >> Hello, I would like to ask you a question.I have a program in R and I use >> the >> readline method to ask the user some things,but i don´t use the R console >> but I use Win console then not appear what I put.I put the code as you >> look >> for: >> >> cat("1- 24horas\n") >> cat("2- 12horas\n") >> cat("3- 8horas\n") >> selection<-readline(prompt="\nSelecciona numero de horas:") >> >> if(selection=="1"){ >> prediccion=exp(x.reconstruida[1441:1450]) >> } >> if(selection=="2"){ >> prediccion=exp(x.reconstruida[720:729]) >> } >> if(selection=="3"){ >> prediccion=exp(x.reconstruida[481:491]) >> } >> >> write.table(prediccion,"C:\\Temp\\prePrueba.txt",quote=F,row.names=F,append=T,col.names=F) >> >> >> //end of code. >> >> Excuse me but my English is bad, i hope explained me well, >> >> A greeting, >> Ignacio. >> >> > > I think this is a matter of flushing the console before the readline > call. See ?flush.console > > -pd > > -- >O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B > c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K > (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 > ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- View this message in context: http://old.nabble.com/Readline%28%29-tp26476979p26493350.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Re adline()
Hello, I would like to ask you a question.I have a program in R and I use the readline method to ask the user some things,but i don´t use the R console but I use Win console then not appear what I put.I put the code as you look for: cat("1- 24horas\n") cat("2- 12horas\n") cat("3- 8horas\n") selection<-readline(prompt="\nSelecciona numero de horas:") if(selection=="1"){ prediccion=exp(x.reconstruida[1441:1450]) } if(selection=="2"){ prediccion=exp(x.reconstruida[720:729]) } if(selection=="3"){ prediccion=exp(x.reconstruida[481:491]) } write.table(prediccion,"C:\\Temp\\prePrueba.txt",quote=F,row.names=F,append=T,col.names=F) //end of code. Excuse me but my English is bad, i hope explained me well, A greeting, Ignacio. -- View this message in context: http://old.nabble.com/Readline%28%29-tp26476979p26476979.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.