Hi all I have been searching on the web in vain. I want to include a dummy variable in my ARIMA model. Let's say that I want to make an AR(1) model for X including a dummy variable which should be 1 for observation 4,5,6 and zero otherwise (let's say that there is 50 observations in total). How do I make that? This does the trick but seems inefficient: dummy<-c(rep(0,3), rep(1,3), rep(0,44)) Thx in advance Best regards /Mikael [[alternative HTML version deleted]]
Inline. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." Clifford Stoll On Thu, Feb 26, 2015 at 8:02 AM, Mikael Olai Milh?j <mikaelmilhoj at gmail.com> wrote:> Hi all > > I have been searching on the web in vain. I want to include a dummy > variable in my ARIMA model. Let's say that I want to make an AR(1) model > for X including a dummy variable which should be 1 for observation 4,5,6 > and zero otherwise (let's say that there is 50 observations in total). How > do I make that?You don't, really. 1. Go through an R tutorial so that you understand the concept of factors and how they are used in R modeling. 2. fact <- factor( (1:50) %in% (4:6)) Cheers, Bert> > This does the trick but seems inefficient: dummy<-c(rep(0,3), rep(1,3), > rep(0,44)) > > Thx in advance > > Best regards > /Mikael > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.
Hi. First of all, thx. But when using in arima(...xreg=fact,...) then fact should be a vector and not a factor variable? Maybe I should have been more clear in my first mail, sorry. Or else I have to dig deeper into factors. /Mikael On Thu, Feb 26, 2015 at 5:17 PM, Bert Gunter <gunter.berton at gene.com> wrote:> Inline. > > Cheers, > Bert > > Bert Gunter > Genentech Nonclinical Biostatistics > (650) 467-7374 > > "Data is not information. Information is not knowledge. And knowledge > is certainly not wisdom." > Clifford Stoll > > > > > On Thu, Feb 26, 2015 at 8:02 AM, Mikael Olai Milh?j > <mikaelmilhoj at gmail.com> wrote: > > Hi all > > > > I have been searching on the web in vain. I want to include a dummy > > variable in my ARIMA model. Let's say that I want to make an AR(1) model > > for X including a dummy variable which should be 1 for observation 4,5,6 > > and zero otherwise (let's say that there is 50 observations in total). > How > > do I make that? > > You don't, really. > > 1. Go through an R tutorial so that you understand the concept of > factors and how they are used in R modeling. > > 2. fact <- factor( (1:50) %in% (4:6)) > > Cheers, > Bert > > > > > This does the trick but seems inefficient: dummy<-c(rep(0,3), rep(1,3), > > rep(0,44)) > > > > Thx in advance > > > > Best regards > > /Mikael > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. >[[alternative HTML version deleted]]
Have a look at the caschrono package. 
There's an excellent associated book by the author of the package -Yves
Aragon- but it's in French; if you don't read French, the package
documentation is very clear.
Jos?
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Mikael Olai
Milh?j
Sent: 26 February 2015 16:03
To: r-help at r-project.org
Subject: [R] Dummy variable in ARIMA
Hi all
I have been searching on the web in vain. I want to include a dummy variable in
my ARIMA model. Let's say that I want to make an AR(1) model for X including
a dummy variable which should be 1 for observation 4,5,6 and zero otherwise
(let's say that there is 50 observations in total). How do I make that?
This does the trick but seems inefficient: dummy<-c(rep(0,3), rep(1,3),
rep(0,44))
Thx in advance
Best regards
/Mikael
	[[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.
Age UK Group
Age UK is a registered charity and company limited by guarantee, (registered
charity number 1128267, registered company number 6825798) Registered office:
Tavis House, 1-6 Tavistock Square, London WC1H 9NA.
For the purposes of promoting Age UK Insurance, Age UK is an Appointed
Representative of Age UK Enterprises Limited. Age UK Enterprises Limited is
authorised and regulated by the Financial Conduct Authority.
Charitable Services are offered through Age UK (the Charity) and commercial
products and services are offered by the Charity?s subsidiary companies. The Age
UK Group comprises of Age UK, and its subsidiary companies and charities,
dedicated to improving the lives of people in later life. Our network includes
the three national charities Age Cymru, Age NI and Age Scotland and more than
160 local Age UK charities.
This email and any files transmitted with it are confide...{{dropped:11}}