[R] dummy variable

peter dalgaard pdalgd at gmail.com
Sun Jul 22 17:34:48 CEST 2012


On Jul 22, 2012, at 14:45 , Rui Barradas wrote:

> Hello,
> 
> See if this is it.
> 
> 
> returns <- rnorm(10)
> dummy <- ifelse(returns < 0, -1, 0)


Sara had "1 if results are negative", so lose the minus. It is easier just to say 

dummy <- as.numeric(returns < 0)

-pd

> 
> 
> Hope this helps
> 
> Rui Barradas
> 
> Em 22-07-2012 08:53, saraberta escreveu:
>> Hi,
>> i need a little help! i must create a dummy variable to insert as external
>> regressor in the variance equation of a garch model; this dummy is referred
>> to the negative sign of returns of an asset, so it has to be 1 when returns
>> are negative and 0 when they are positive, and in my model the dummy is
>> multiplied by another time series, the daily range. (have i explained
>> well?!)
>> thank's a lot
>> sara
>> 
>> 
>> 
>> --
>> View this message in context: http://r.789695.n4.nabble.com/dummy-variable-tp4637347.html
>> Sent from the R help mailing list archive at Nabble.com.
>> 
>> ______________________________________________
>> R-help at 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 at 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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list