search for: mylag

Displaying 5 results from an estimated 5 matches for "mylag".

Did you mean: myflag
2007 Jul 12
2
lead
Hi, is there any function in R that shifts elements of a vector to the opposite direction of what Lag() of the Hmisc package does? (something like, Lag(x, shift = -1) ) Thanks Zava -------------------------------------------------------- This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}
2011 Aug 04
2
Efficient way of creating a shifted (lagged) variable?
...in SPSS it's just a few letters (like LAG()). Here is what I've written but I wonder. It works - but maybe there is a very simple way of doing it in R that I could not find? I need the same for "lead" (opposite of lag). Any hint is greatly appreciated! ### The function I created: mylag <- function(x,max.lag=1){ # x has to be a 1-column data frame temp<-as.data.frame(embed(c(rep(NA,max.lag),x[[1]]),max.lag+1))[2:(max.lag+1)] for(i in 1:length(temp)){ names(temp)[i]<-paste(names(x),".lag",i,sep="") } return(temp) } ### Running mylag...
2012 Sep 17
2
Problem with Stationary Bootstrap
Dear R experts,   I'm running the following stationary bootstrap programming to find the parameters estimate of a linear model:     X<-runif(10,0,10) Y<-2+3*X a<-data.frame(X,Y) coef<-function(fit){   fit <- lm(Y~X,data=a)    return(coef(fit)) }  result<- tsboot(a,statistic=coef(fit),R = 10,n.sim = NROW(a),sim = "geom",orig.t = TRUE)   Unfortunately, I got this
2009 Sep 18
1
lapply - value changes as parameters to function?
...eSize=TestSamples , Iterations=TestIterations ) which fails down lower complaining that what it's receiving for Lookback isn't an integer: > x = list(seq(5:20)) > ResultList = lapply(x, DoAvgCalcs, IndexData, Lookback=x, SampleSize=TestSamples , Iterations=TestIterations ) Error in MyLag(df$Close, Lookback) : (list) object cannot be coerced to type 'integer' > Can someone suggest how to do this correctly? Thanks, Mark
2009 Sep 09
3
lag a data.frame column?
Sometimes it's the simple things... Why doesn't this lag X$x by 3 and place it in X$x1? (i.e. - Na's in the first 3 rows and then values showing up...) The help page does talk about time series. If lag doesn't work on data.frame columns then what would be the right function to use to lag by a variable amount? Thanks, Mark X=data.frame(x=seq(1:10)) X$x1=lag(X$x, 3) X