search for: lag1

Displaying 20 results from an estimated 26 matches for "lag1".

Did you mean: flag1
2008 Aug 11
3
Peoblem with nls and try
...control(maxiter = 100000),trace = TRUE) print (summary(nlmod2)) coeff<-coefficients(nlmod2) c<-coeff["c"] A<-coeff["A"] B<-coeff["B"] e<-coeff["e"] k<-coeff["k"] summary(nlmod2) plot(P1) lines(P1[,1],nlmod2,lwd=2,col=2) lag1 <- e-(2/k) print(lag1) abline(v=lag1,col=4) print("nlmod2") { pdf(file= "Lag_estimation.pdf" ) plot(P1[,1],predict(nlmod2),xlab='Time',ylab='ThT normalizate',main="Lag estimetion",type='l', col=1) lines(P1, col=8) abline(v=lag1,col=4)...
2011 Nov 30
2
forecasting linear regression from lagged variable
...some time series data with the xts package, and would like to generate a forecast 12 periods into the future. There are limited observations, so I am unable to use an ARIMA model for the forecast. Here's the regression setup, after converting everything from zoo objects to vectors. hire.total.lag1 <- lag(hire.total, lag=-1, na.pad=TRUE) lm.model <- lm(hire.total ~ case.total + hire.total.lag1) hire.total is a monthly historical time series from Jan 2010 to Oct 2011. hire.total.lag1 is the same time series, lagged 1 period backwards. case.total is a monthly historical time series from...
2013 Apr 26
1
Regression coefficients
Hi all, I have run a ridge regression as follows: reg=lm.ridge(final$l~final$lag1+final$lag2+final$g+final$g+final$u, lambda=seq(0,10,0.01)) Then I enter : select(reg) and it returns: modified HKB estimator is 19.3409 modified L-W estimator is 36.18617 smallest value of GCV at 10 I think it means...
2008 Jan 17
1
acf lag1 value
Hi R, I have doubt. >x= c(4,5,6,3,2,4,5) >acf(x,plot=F,lag.max=1) Autocorrelations of series 'x', by lag 0 1 1.000 0.182 But if I actually calculate the autocorrelation at lag1 I get, >cor(x[-1],x[-length(x)]) [1] 0.1921538 Even in excel I get 0.1921538 value. So, I want to know what the 'acf' function is calculating here.... Thanks in advance, Shubha Karanth This e-mail may contain confidential and/or privileged i...{{dropped:13}}
2002 Jun 20
1
Possible bug with glm.nb and starting values (PR#1695)
...a bug, the documentation is inaccurate, or I'm missing something (or some combination of the above). An example: ________________________________________________________________ library(MASS) y<-c(7,5,4,7,5,2,11,5,5,4,2,3,4,3,5,9,6,7,10,6, 12,6,3,5,3,9,13,0,6,1,2,0,1,0,0,4,5,1,5,3,3,4) lag1<-c(0,7,5,4,7,5,2,11,5,5,4,2,3,4,3,5,9,6,7,10,6, 12,6,3,5,3,9,13,0,6,1,2,0,1,0,0,4,5,1,5,3,3) lag2<-c(0,0,7,5,4,7,5,2,11,5,5,4,2,3,4,3,5,9,6,7,10,6, 12,6,3,5,3,9,13,0,6,1,2,0,1,0,0,4,5,1,5,3) lag3<-c(0,0,0,7,5,4,7,5,2,11,5,5,4,2,3,4,3,5,9,6,7,10,6, 12,6,3,5,3,9,13,0,6,1,2,0,1,0,0,4,5,1,5)...
2012 Feb 03
1
A question on Unit Root Test using "urca" toolbox
...ag.1 + 1 + z.diff.lag) Residuals: Min 1Q Median 3Q Max -2.43555 -0.63440 -0.03048 0.53522 2.84237 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.238631 0.137262 1.739 0.084944 z.lag.1 -0.153030 0.061841 -2.475 0.014881 z.diff.lag1 0.011463 0.090330 0.127 0.899252 z.diff.lag2 0.008764 0.089850 0.098 0.922479 z.diff.lag3 0.149529 0.088930 1.681 0.095546 z.diff.lag4 -0.349870 0.088847 -3.938 0.000145 (Intercept) . z.lag.1 * z.diff.lag1 z.diff.lag2 z.diff.lag3 . z.diff.lag4 *** --- Signif. codes: 0 ?***?...
2013 Apr 27
1
Selecting ridge regression coefficients for minimum GCV
Hi all, I have run a ridge regression as follows: reg=lm.ridge(final$l~final$lag1+final$lag2+final$g+final$u, lambda=seq(0,10,0.01)) Then I enter : select(reg) and it returns: modified HKB estimator is 19.3409 modified L-W estimator is 36.18617 smallest value of GCV at 10 I think it means that it...
2012 Mar 19
1
Lag based on Date objects with non-consecutive values
...07-05","%Y-%m-%d"),by="day", length=10), Dis1=rnorm(5, 1,10) ) df <- rbind(df1,df2); df ## A function to lag the variable by a specified number of days lag.day <- function (lag.by, data) { c(rep(NA,lag.by), head(data$Dis1, -lag.by)) } ## Using the function df$lag1 <- lag.day(lag.by=1, data=df); df ## returns this data frame Date Dis1 lag1 1 1967-06-05 1.146405 NA 2 1967-06-06 9.732887 1.146405 3 1967-06-07 -9.279462 9.732887 4 1967-06-08 7.856646 -9.279462 5 1967-06-09 5.494370 7.856646 6 1967-06-15 5.070176 5.494...
2018 Mar 25
3
Take average of previous weeks
Dear all, I have weekly data by city (variable citycode). I would like to take the average of the previous two, three, four weeks (without the current week) of the variable called value. This is what I have tried to compute the average of the two previous weeks; df = df %>% mutate(value.lag1 = lag(value, n = 1)) %>% mutate(value .2.previous = rollapply(data = value.lag1, width = 2, FUN = mean, align = "right", fill = NA,...
2004 Oct 29
2
lag variable addition to data frame question
...ate #lagged variables #of this without using as.ts(). Is #there a more effient way of doing this than#below and #without using a recursive loop such as #for( i in 1:obs)x.lag[i]= x[(i-1)] 1.here is the way i am doing the lag now x=c(3,2,3,2,1,1,1,2,1,2,1,3...1) obs=length(x) x.nolag=x[2:obs] x.lag1=x[1:(obs-1)] my.new=cbind(x.nolag,x.lag1) #since my data frame must line up my orginal x values to other columns I also # add the following x.fill= cbind(0,0) # as named the above cell lines up my factor to other factors in my data frame, #since I had chopped off the first x observation to crea...
2012 Dec 03
2
How to rename the columns of as.table
...G -0.087313283 -0.039602008 -0.036173594 -0.052246520 -0.059179674 -0.041706488 0.031601299 H I J -0.005105154 0.016379572 0.058881676 Now i don't want the names A,B,C,D ..... etc, but i want to rename it with : Lag1, Lag2, Lag3 ... I know that it can be done with fix(autocorrelazione1), but i need somthing in the initial formula. I tried with dnn=list.names("lag1" , .... , "lag10") but the names remain the same. Some help? Thanks guys -- View this message in context: http://r.789695.n4.n...
2005 Aug 13
1
How to make a lagged variable in panel data?
....15947390 10 1984 2 -0.46585116 11 1980 3 -0.29052635 12 1981 3 -0.27109203 13 1982 3 -0.76168164 14 1983 3 0.02294361 15 1984 3 2.22828032 What I'd like to do is to make a lagged wage for each person, i.e., I should get an additional variable A$wage.lag1: > A year person wage wage.lag1 1 1980 1 0.17923212 NA 2 1981 1 0.25610292 0.17923212 3 1982 1 0.50833655 0.25610292 4 1983 1 -0.42448395 0.50833655 5 1984 1 0.49233532 -0.42448395 6 1980 2 -0.499...
2008 May 22
1
How to account for autoregressive terms?
...ion,c("RET2")]) indep.ret3 &lt;- ts(data.df[selection,c("RET3")]) indep.ret4 &lt;- ts(data.df[selection,c("RET4")]) indep.ret5 &lt;- ts(data.df[selection,c("RET5")]) d&lt;-ts.union(dep,indep.ret1,indep.ret2,indep.ret3,indep.ret4,indep.ret5,dep.lag1=lag(dep,-1),dep.lag2=lag(dep,-2),dep.lag3=lag(dep,-3)) fit1 &lt;- lm(dep~indep.ret1+indep.ret2+indep.ret3+indep.ret4+indep.ret5+dep.lag1+dep.lag2+dep.lag3,data=d) summary(fit1) #coeftest(fit1,vcov=NeweyWest) 2) using armaFit: fit2&lt;-armaFit(dep~ar(3),xreg=ts(data.df[selection,c("RET...
2018 Mar 25
0
Take average of previous weeks
...by city (variable citycode). I would like to take the > average of the previous two, three, four weeks (without the current week) > of the variable called value. > > This is what I have tried to compute the average of the two previous weeks; > > df = df %>% > mutate(value.lag1 = lag(value, n = 1)) %>% > mutate(value .2.previous = rollapply(data = value.lag1, > width = 2, > FUN = mean, > align = "right", >...
2018 Mar 26
1
Take average of previous weeks
...ke to take the > > average of the previous two, three, four weeks (without the current week) > > of the variable called value. > > > > This is what I have tried to compute the average of the two previous > weeks; > > > > df = df %>% > > mutate(value.lag1 = lag(value, n = 1)) %>% > > mutate(value .2.previous = rollapply(data = value.lag1, > > width = 2, > > FUN = mean, > > align = "right", > >...
1999 May 06
0
matrix weirdness
I am using R on unix version 63.0 I am doing an image plot of the following data file: ================================ lag1 lag2 cif2d 0.000 0.000 NaN 0.000 1.000 0.500000 0.000 2.000 0.489831 0.000 3.000 0.492986 0.000 4.000 0.493409 0.000 5.000 0.492727 0.000 6.000 0.494485 1.000 0.000 0.500000 1.000 1.000 NaN 1.000 2.000 0.495098 1.000 3.000 0.489831 1.000 4.000 0.492986 1.000 5.000 0.493409 1.000 6.000 0....
1999 May 06
0
image weirdness
I am using R 63.0. Now let's try this simple image plot. Here is the data file: ============================ lag1 lag2 cif2d 1 1 11 1 2 12 1 3 13 2 1 21 2 2 22 2 3 23 3 1 31 3 2 32 3 3 33 ==================== data<-read.table("~/r/rt/data/unif/junk.out",header=TRUE) x<-unique(data$lag1) y<-unique(data$lag2) z<-matrix(data$cif2d,length(y),length(x)) At this point, see the z matrix: >...
2008 Jul 06
1
Different Autocorrelation using R and other softwares
...onsistency in the autocorrelation from R with SPSS/Minitab. I have tried a dataset x with 20 data (1-20) and ask R to give the autocorrelation of different lags using the command < acf(x, lag.max=100, type = "correlation"), However while SPSS and Minitab give the same answers (0.85 for lag1), R gives 0.3688 which is much smaller. Obviously, the answers from SPSS/Minitab are correct by verifying in Excel. Is R using another definition in calculating the traditional autocorrelation for a time-series? Thanks for your attention. Would be very grateful if anyone can help. Yinny Scho...
2013 Apr 30
0
Ridge regression
Hi all, I have run a ridge regression on a data set 'final' as follows: reg=lm.ridge(final$l~final$lag1+final$lag2+final$g+final$u, lambda=seq(0,10,0.01)) Then I enter : select(reg) and it returns: modified HKB estimator is 19.3409 modified L-W estimator is 36.18617 smallest value of GCV at 10 I think it means that it...
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