search for: lagged

Displaying 20 results from an estimated 2401 matches for "lagged".

Did you mean: ragged
2005 Mar 05
4
How to use "lag"?
Is it possible to fit a lagged regression, "y[t]=b0+b1*x[t-1]+e", using the function "lag"? If so, how? If not, of what use is the function "lag"? I get the same answer from y~x as y~lag(x), whether using lm or arima. I found it using y~c(NA, x[-length(x)])). Consider the following: >...
2008 May 02
2
Extract lags from a formula
Hi folks! How do I extract lags from a formula? An example: mod.eq<-formula(x~lag(x,-1)+lag(x,-2)) > mod.eq x ~ lag(x, -1) + lag(x, -2) > mod.eq[1] "~"() > mod.eq[2] x() > mod.eq[3] lag(x, -1) + lag(x, -2)() I'm trying to extract the lags into a vector that would be simply [1,2]. How do I do this? I'm using the dyn package to do dynamic
2010 Jan 02
2
help with for loop
Dear useRs, I want to write a function that generates all the possible combinations of diff(). Example: If my vector has length 5, I need the diff() until lag=4 -> c(diff(my.vec), diff(my.vec, lag=2), diff(my.vec, lag=3), diff(my.vec, lag=4)) If it has length 4, I need until lag=3 -> c(diff(my.vec), diff(my.vec, lag=2), diff(my.vec, lag=3)) So, it must be until lag=(length(my.vec)-1).
2012 Mar 19
1
Lag based on Date objects with non-consecutive values
Hello all, I need to figure out a way to lag a variable in by a number of days without using the zoo package. I need to use a remote R connection that doesn't have the zoo package installed and is unwilling to do so. So that is, I want a function where I can specify the number of days to lag a variable against a Date formatted column. That is relatively easy to do. The problem arises when I
2012 Jan 10
1
Lag() and lag()
lag is a very confusing function i try to plot lag(x,-h) and y , the results are the same figures for all the h lags. then i saw online people use lag(x,-h) as xreg in arima that won't work in my eyes if lag function is consistent, isnce it returns the same value for all the lags i don't know in which occasion people will use this function besides I suppose Lag(x,h) is the same as
2011 Oct 06
1
Coefficients for lagged plm model variables not calculated
...or something more general. I am trying to run a fixed effects model with effects over time and individual. The model has various lags, and the problem is that these lags do not seem to always be taken into account when the plm model is calculated (i.e no coefficients are calculated for some of the lagged regressors when >summary(plm.object) is called). I have used exactly the same ".txt" file before, with exactly the same code, bar the name of the model objects, successfully. If I use <lm> instead of <plm> it also will usually take into account the lagged regressors when p...
2011 Aug 04
2
Efficient way of creating a shifted (lagged) variable?
Hello! I have a data set: set.seed(123) y<-data.frame(week=seq(as.Date("2010-01-03"), as.Date("2011-01-31"),by="week")) y$var1<-c(1,2,3,round(rnorm(54),1)) y$var2<-c(10,20,30,round(rnorm(54),1)) # All I need is to create lagged variables for var1 and var2. I looked around a bit and found several ways of doing it. They all seem quite complicated - while 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...
2010 Jul 21
1
The opposite of "lag"
Hello! I have a data frame A (below) with a grouping factor (group). I take my DV and create the new, lagged DV by applying the function lag.it (below). It works fine. A <- data.frame(year=rep(c(1980:1984),3), group= factor(sort(rep(1:3,5))), DV=c(rnorm(15))) lag.it <- function(x) { DV <- ts(x$DV, start = x$year[1]) idx <- seq(length = length(DV)) DVs <- cbind(DV, lag(DV, -1))[idx,]...
2010 Jul 31
1
Lags and Differences of zoo Objects
Hi, I'm struggling to understand the documentation. ?lag.zoo x - a "zoo" object. k, lag - the number of lags (in units of observations). Note the sign of k behaves as in lag. differences - an integer indicating the order of the difference. What does the above line actually mean? I've tried a few settings on sample data but can't figure out what it is doing. x <-
2013 Mar 05
2
Issues when using interaction term with a lagged variable
Hi there! Today I tried to estimate models using both plm and pgmm functions, with an interaction between X1 and lag(X2, 1). And I notice two issues. Let "Y=b_1 * X_1 + b_2 * X_2 + b_3 * X_1 * x_2 + e" be our model. 1) When using plm, I got different results when I coded the interaction term with I(X1 * lag(X2, 1)) and when I just saved this multiplication X1 * lag(X2, 1) in a
2006 Jun 13
3
Multiple lag.plots per page
Hi, I'm trying to plot several lag.plots on a page, however the second plot replaces the first one (although it only takes up the upper half as it should): par(mfrow=c(2,1)) a<-sin(1:100) b<-cos(1:100) lag.plot(a) lag.plot(b) What's the trick to this? I'm using R 2.2.1 (2005-12-20 r36812) on Ubuntu Linux. Thanks, Gad -- Gad Abraham Department of Mathematics and
2011 Aug 01
1
ivreg and structural change
Hello, I am looking for some help with this question: how could I test structural breaks in a instrumental variablesĀ“s model? For example, I was trying to do something with my model with three time series. tax_ivreg <- ivreg(l_y ~ l_x2 + l_x1+ dl_y | lag(l_x2, -1)+lag(l_x2, -2)+ lag(l_x1, -1)+lag(l_x1, -2)+lag(l_y, -1)+lag(l_y, -2), data=tax1) summary(tax_ivreg) ## after estimating it,
2005 Aug 18
1
How do I make a Sweave + latex table out of this ?
Dear list, I have a table that I would like to convert to latex for inclusion into a Sweave file. > round(ftable(prop.table(xtabs(~agemF + votcat + Type , data=work),margin=2))*100,1) Type Voiced Voiceless unaspirated Voiceless aspirated agemF votcat 18 - 24 Prevoiced 2.6 8.7
2008 Jan 31
1
Feature request: about lag(), which.min() and cat().
Hello I'm only user of R and have many little knowledge in programming but I permit to send you some whishes/suggestions for R. which.min like which(), which.min() should also include an argument arr.ind. Note that one can have it with which(a==min(a), arr.ind=TRUE) but if there is a reason to build a special function which.min, why not add also this nice argument? lag() If one wants to
2006 Feb 15
1
question about the results given by the Box.test?
Hello, I am using the Ljung Box test in R to compute if the resiudals of my fitted model is random or not. I am not sure though what the results mean, I have looked at various sources on the internet and have come up with contrasting explanations (mainly because these info deal with different program languages, like SAS, SPSS, etc). I know that my residuals should appropriate white noise( is
2011 Sep 20
2
ARIMA - Skipping intermediate lags
Hello, I am a new R user. I am trying to use the arima command, but I have a question on intermediate lags. I want to run in R the equivalent Stata command of ARIMA d.yyy, AR(5) MA(5 7). This would tell the program I am interested in AR lag 5, MA lag 5, and MA lag 7, all while skipping the intermediate lags of AR 1-4, and MA 1-4, 6. Is there any way to do this in R? Thank you. -- View this
2008 Apr 04
1
Problems with Unit Root testing using ur.df function
Hi All, I'm new to R and am trying to run a unit root test on the vector "y" (a time series of inflation (i.e. changes in the Consumer Price Index quarter on quarter)). I've run the Augmented-Dickey-Fuller Test below (R's URCA package). It gives me an error that it cannot find the function ur.df unless I comment out the third last line of code (see below). I try to call
2012 Dec 03
2
How to rename the columns of as.table
Hello guys .. I would like to have some help about as.table . I made a table with the autocorrelations of the returns whit 10 lags and i get this : autocorrelazione2 <- as.table(c((cor(r2[-1151,],lag(r2))),(cor(r2[- c(1151,1150),],lag(r2, k=2))),(cor(r2[- c(1151,1150,1149),],lag(r2, k=3))),(cor(r2[- c(1151,1150,1149,1148),],lag(r2, k=4))),(cor(r2[- c(1151,1150,1149,1148,1147),],lag(r2,
2012 Nov 01
2
Subsetting year range
Hi, I have a panel data set that I am trying to subset. I am trying to keep values for years >=1960. The full set is from 1940 to 2000. I tried a few things, but none worked. Here are a couple that I am trying to use. TableAPS1 <- subset(TableAP, year => 1959) TableAPS1 <- TableAP[ which(year > 1959),] It would be really nice if someone can point out what I am doing wrong
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}}