[R] Getting forecast values using DCC GARCH fit

2017-06-06 Thread Dhivya Narayanasamy
Hi, I am trying to fit a multivariate time series model using DCC GARCH model and forecast it. The data looks like this: > head(datax) x vibration_x Speed 1 2017-05-16 17:53:00 -0.132 421.4189 2 2017-05-16 17:54:00 -0.296 1296.8882 3 2017-05-16 17:55:00 -

[R] Plot MArginal distribution in the correct place

2017-06-06 Thread Pedro páramo
Hi all, I have this code, but the marginal distribution plot doesn´t appear aligned with the left plot. I think could be something about layout or par() mar. The code was programmed by me time ago. Can anyone help me to get the marginal distribution on the center (more higher centered) id.txt

Re: [R] Determining which.max() within groups

2017-06-06 Thread Bert Gunter
cumsum() seems to be what you need. This can probably be done more elegantly, but ... out <- aggregate(Q ~ wyr, data = Daily, which.max) tbl <- table(Daily$wyr) out$Q <- out$Q + cumsum(c(0,tbl[-length(tbl)])) out ## yields wyr Q 1 1990 4 2 1991 6 3 1992 9 4 1993 15 5 1994 18 I leave the

[R] Determining which.max() within groups

2017-06-06 Thread Morway, Eric
Using the dataset below, I got close to what I'm after, but not quite all the way there. Any suggestions appreciated: Daily <- read.table(textConnection(" Date wyrQ 1911-04-01 1990 4.530695 1911-04-02 1990 4.700596 1911-04-03 1990 4.898814 1911-04-04 1990 5.097032 1911-04-05 1991 5.2

Re: [R] Force argument to have quotes

2017-06-06 Thread Nordlund, Dan (DSHS/RDA)
Bert has suggested there are better ways to do what you want. But if you want to continue down the path you have started and you want to decide whether to quote based on the variable Class, something like this might work for you myOptions <- with(myFunction1Vals, paste(Argument, ifelse(Class

[R] Revolutions blog: May 2017 roundup

2017-06-06 Thread David Smith via R-help
Since 2008, Microsoft (formerly Revolution Analytics) staff and guests have written about R every weekday at the Revolutions blog (http://blog.revolutionanalytics.com) and every month I post a summary of articles from the previous month of particular interest to readers of r-help. In case you miss

Re: [R] Force argument to have quotes

2017-06-06 Thread Bert Gunter
Harold: As a general rule, if you are using eval(parse(...)) you are doing it poorly in R; cf library("fortunes") fortune(106) Why is something like this not suitable: fun1 <- function(a1,a2,a3 = c("hi","by")) { cat(a3,a1+a2,"\n") } > fun1 (1,2) hi by 3 > fun1(1,2, a3 = "whoopee") whoopee 3

Re: [R] Force argument to have quotes

2017-06-06 Thread Boris Steipe
If I understand you correctly what you are really asking is how to embed quotes in a string so that it can be parse()'d as an expression. The answer would be: escape the quotes. R > myOptions <- "Hello" R > eval(parse(text = paste( "print(", myOptions, ")" ))) Error in print(Hello) : object 'H

Re: [R] Subject: glm and stepAIC selects too many effects

2017-06-06 Thread Bert Gunter
See package "glmnet". -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Jun 6, 2017 at 8:10 AM, Ravi Varadhan wrote: > More principled would be to

Re: [R] Subject: glm and stepAIC selects too many effects

2017-06-06 Thread Ravi Varadhan
More principled would be to use a lasso-type approach, which combines selection and estimation in one fell swoop! Ravi From: Ravi Varadhan Sent: Tuesday, June 6, 2017 10:16 AM To: r-help@r-project.org Subject: Subject: [R] glm and stepAIC selects too many effec

Re: [R] integrating 2 lists and a data frame in R

2017-06-06 Thread Bogdan Tanasa
Thank you Bert for your suggestion ;). On Tue, Jun 6, 2017 at 8:19 AM, Bert Gunter wrote: > Simple matrix indexing suffices without any fancier functionality. > > ## First convert M and N to character vectors -- which they should > have been in the first place! > > M <- sort(as.character(M[,1]))

Re: [R] integrating 2 lists and a data frame in R

2017-06-06 Thread Bert Gunter
Simple matrix indexing suffices without any fancier functionality. ## First convert M and N to character vectors -- which they should have been in the first place! M <- sort(as.character(M[,1])) N <- sort(as.character(N[,1])) ## This could be a one-liner, but I'll split it up for clarity. res

[R] Force argument to have quotes

2017-06-06 Thread Doran, Harold
I am writing a program where non-technical R users will read in a config file and the config file will then parse the arguments found within the config and pass them to respective functions. I'm having trouble (efficiently) writing a piece of code to retain quotation marks around the argument wh

Re: [R] integrating 2 lists and a data frame in R

2017-06-06 Thread Bogdan Tanasa
Thank you David. Using xtabs operation simplifies the code very much, many thanks ;) On Tue, Jun 6, 2017 at 7:44 AM, David Winsemius wrote: > > > On Jun 6, 2017, at 4:01 AM, Jim Lemon wrote: > > > > Hi Bogdan, > > Kinda messy, but: > > > > N <- data.frame(N=c("n1","n2","n3","n4")) > > M <- data

Re: [R] integrating 2 lists and a data frame in R

2017-06-06 Thread David Winsemius
> On Jun 6, 2017, at 4:01 AM, Jim Lemon wrote: > > Hi Bogdan, > Kinda messy, but: > > N <- data.frame(N=c("n1","n2","n3","n4")) > M <- data.frame(M=c("m1","m2","m3","m4","m5")) > C <- data.frame(n=c("n1","n2","n3"), m=c("m1","m1","m3"), I=c(100,300,400)) > MN<-as.data.frame(matrix(NA,nrow=lengt

Re: [R] integrating 2 lists and a data frame in R

2017-06-06 Thread Bogdan Tanasa
Thank you David for the code, as I am learning about xtabs operation. That works great too ;) On Tue, Jun 6, 2017 at 7:34 AM, David L Carlson wrote: > Here's another approach: > > N <- data.frame(N=c("n1","n2","n3","n4")) > M <- data.frame(M=c("m1","m2","m3","m4","m5")) > C <- data.frame(n=c("n1

Re: [R] integrating 2 lists and a data frame in R

2017-06-06 Thread David L Carlson
Here's another approach: N <- data.frame(N=c("n1","n2","n3","n4")) M <- data.frame(M=c("m1","m2","m3","m4","m5")) C <- data.frame(n=c("n1","n2","n3"), m=c("m1","m1","m3"), I=c(100,300,400)) # Rebuild the factors using M and N C$m <- factor(as.character(C$m), levels=levels(M$M)) C$n <- factor(as.c

Re: [R] integrating 2 lists and a data frame in R

2017-06-06 Thread Bogdan Tanasa
Thank you Jim ! On Tue, Jun 6, 2017 at 4:01 AM, Jim Lemon wrote: > Hi Bogdan, > Kinda messy, but: > > N <- data.frame(N=c("n1","n2","n3","n4")) > M <- data.frame(M=c("m1","m2","m3","m4","m5")) > C <- data.frame(n=c("n1","n2","n3"), m=c("m1","m1","m3"), > I=c(100,300,400)) > MN<-as.data.frame(mat

[R] Subject: glm and stepAIC selects too many effects

2017-06-06 Thread Ravi Varadhan
If AIC is giving you a model that is too large, then use BIC (log(n) as the penalty for adding a term in the model). This will yield a more parsimonious model. Now, if you ask me which is the better option, I have to refer you to the huge literature on model selection. Best, Ravi [[

Re: [R] integrating 2 lists and a data frame in R

2017-06-06 Thread Jim Lemon
Hi Bogdan, Kinda messy, but: N <- data.frame(N=c("n1","n2","n3","n4")) M <- data.frame(M=c("m1","m2","m3","m4","m5")) C <- data.frame(n=c("n1","n2","n3"), m=c("m1","m1","m3"), I=c(100,300,400)) MN<-as.data.frame(matrix(NA,nrow=length(N[,1]),ncol=length(M[,1]))) names(MN)<-M[,1] rownames(MN)<-N[,1]

Re: [R] Error in readRDS(dest) SOLVED

2017-06-06 Thread Patrick Connolly
On Wed, 31-May-2017 at 10:05AM -0400, Martin Morgan wrote: |> On 05/31/2017 04:38 AM, Patrick Connolly wrote: |> >When I check out those directories in a terminal, there's a big diffrence: |> > |> >With R-3.4.0 |> >~ > ll /tmp/RtmpFUhtpY |> >total 4 |> >drwxr-xr-x 2 hrapgc hrapgc 4096 May 31 10:4