Displaying 20 results from an estimated 2412 matches for "lags".
Did you mean:
flags
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:
> set.seed(1)
> x <- rep(c(rep(0, 4), 9), len=9)
> y <-
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...
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 lag(x,-h) when doing re...
2011 Oct 06
1
Coefficients for lagged plm model variables not calculated
...hat I just can't figure out.
I am using the plm package to conduct a panel analysis - although I am not
sure if the problem is arising as a result of the plm package 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 th...
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
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,
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 <- iris
x$Species = NULL
x$Pet...
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().
....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 construct a time series model, it is often useful to
have the lags matrix. This is available with embed(ts,k) but the time
series class disappears. So it would be nice that the argument k of
lag() also admit values of length >1, which would give the same result
as embed() but keep the class. In his wish list of 1 January 2008 (point
8), Gabor Grothendieck s...
2006 Feb 15
1
question about the results given by the Box.test?
...ndom) since a check of its ACF shows it to
be so (signifant correlation only at lag 1, decays
very quickly to zero).
But I am not sure how to interpret the ljung-box
result given by R.
To check for randomness of residuals, should the
p-value be small or large? How small and how large?
And at what lags should I check for the randomness of
the residuals? Is a p-value > 0.05 (or < 0.05) enough?
What if I have a very large p-value of 0.9796 at lag
1, but its value is 0.0139 at lag 8?
For example, here's what I got for the first 10 lags
of the residuals I'm testing:
------------------...
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 message...
2008 Apr 04
1
Problems with Unit Root testing using ur.df function
...ter)).
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 the function via the following:
test <- ur.df(y, type = "none", lags = 1)
Am I doing this correctly?
When I then type in
test()
it comes back with
Error: could not find function "test"
When I type in
a <- summary(test)
It comes back with
> a
Length Class Mode
1 character character
I just want it to provide summary st...
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, k=5))),(cor(r2[-
c(1151,1150,1149,114...
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}}