similar to: using function from specific packages

Displaying 20 results from an estimated 20000 matches similar to: "using function from specific packages"

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
2009 Mar 21
1
How to avoid switching on input type?
Hi, I need some help improving this ugly code I wrote. I would like to shift forward a zoo object, matrix, ts, or list by "shift" items (default 1) and fill the holes with 0's. The code below works, but it looks ugly. I could write a function lag.zerofill() which calls the two functions below depending on the class() of the item passed in, but that feels very unlike R. What is
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 <-
2009 Oct 22
1
Error in link in Rd file stops package installation
With a pretty recent version of R 2.11.0 (devel,unstable, svn 50178) on Linux I could not install version 1.5-8 of zoo (the current on on CRAN): % R-devel CMD INSTALL -l Rlib3 zoo * installing *source* package 'zoo' ... ** R ** inst ** preparing package for lazy loading ** help *** installing help indices converting help for package 'zoo' finding
2008 Mar 02
1
question on lag.zoo
Hi Guys, I'm using zoo package now. I found lag is not doing what I assumed. > x <- zoo(11:21) > z <- zoo(1:10, yearqtr(seq(1959.25, 1961.5, by = 0.25)), frequency = 4) > x 1 2 3 4 5 6 7 8 9 10 11 11 12 13 14 15 16 17 18 19 20 21 > lag(x) 1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 > z 1959 Q2 1959 Q3 1959 Q4 1960 Q1 1960 Q2 1960 Q3 1960 Q4
2009 Mar 21
4
Problem with zoo and rbind() converting matrix to vector
require( zoo ) inp <- c( 5, 9, 4, 2, 1 ); m <- zoo( cbind( inp ), as.Date("2003-02-01") + (0:(length(inp)-1))); dim( m ) # [1] 5 1 dim( m[1,,drop=FALSE] ) # [1] 1 1 - ok dim( lag( m, -1 )) # [1] 4 1 - ok dim( rbind( m[1,,drop=FALSE], lag(m,-1) )) # NULL - converted from zoo matrix to zoo vector!?!? # any way to keep the last line as a zoo matrix??? -- View this message in
2009 Jul 24
1
Lag representation in ccf() while zoo object is used?
Dear All, I have 2 time-series data sets and would like to check the cross correlation. These data sets were set as a zoo object, called data, and in general look like: V1 V2 2007-01-01 00:00:00 0.0 0.176083 2007-01-01 01:00:00 0.0 0.176417 2007-01-01 02:00:00 0.0 0.175833 2007-01-01 03:00:00 0.0 0.175833 2007-01-01
2009 Apr 15
2
shift/lag when merge zoo
Hello alltogheter, I have a little problem regarding merging to zoo series. I want to merge two zoo series to reduce the timegaps between the stamps. I use the following code: data.test <- as.POSIXct(seq(data.input01[1,1],data.input01[nrow(data.input01),1],900),tz="GMT") data.troughput01 <- as.zoo(data.input01$V2) index(data.troughput01) <-
2008 Aug 17
2
grangertest/lmtest ... what am I doing wrong ?
Dear Achim, R Users, What am I doing wrong in this example ? a<-zoo(rnorm(100),order.by=1:100) b<-lag(a) regr<-na.exclude(merge(a,b)) plot(regr) grangertest(regr[,1],regr[,2],3) > a<-zoo(rnorm(100),order.by=1:100) > b<-lag(a) > regr<-na.exclude(merge(a,b)) > plot(regr) > grangertest(regr[,1],regr[,2],3) Error in solve(vc[ovar, ovar]) : subscript out of bounds
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
2008 Oct 21
3
R Help
Hi, I have the following code and am using R 2.7.2: JIBqq <- (Jqrt.IB[2:length(Jqrt.IB)]/Jqrt.IB[1:(length(Jqrt.IB)-1)])-1 JIBqq <- cbind(zoo(JIBqq, Jqrt.time[2:length(Jqrt.time)])) y.JIBqq <- merge(JIBqq,lag(JIBqq,-1)) > y.JIBqq JIBqq lag(JIBqq, -1) 2004-06-30 0.003318909 NA 2004-09-30 -0.028536136 0.003318909
2009 Oct 12
1
Using diff, ifelse on zoo object
Hi, I'm having an issue when using diff and ifelse on a zoo object..... x.Date <- as.Date("2003-02-01") + c(1, 3, 7, 9, 14) - 1 x <- zoo(rnorm(5), x.Date) x.POS <- c(0,0,0,1,1) x<- merge(x,x.POS) x x x.POS 2003-02-01 -0.1858136 0 2003-02-03 -1.3188533 0 2003-02-07 0.2709794 0 2003-02-09 -1.4915262 1 2003-02-14
2006 Oct 28
1
labelling of horizontal axis in acf function
this one is not a false alarm like my previous message. i have cut and paste the code below so if anyone could run it would be appreciated. basically, my question is why the horizontal axis of the acf plot is labelled with such huge numbers when the labels should be 1 through 10 since may lag.max = 10 ? i looked at the cdoe of acf but it was pretty much beyond me. i think it has something to
2009 Feb 03
1
How to show variables used in lm function call?
Hello R users, I am new to R and am wondering if anyone can help me out with the following issue: I wrote a function to build ts models using different inputs, but when R displays the call for a model, I cannot tell which variables it is using because it shows the arguments instead of the real variables passed to the function. (e.g Call: lm(formula = dyn(dep ~ lag(dep, -1) + indep)) --->
2013 Feb 26
1
problem with nested loops
Each of the data sets contains monthly observations on price indices for 7 countries. I use the fitted values from reg1 in the reg2 model. The interior loop executes without error as long as I explicitly specify the data set, i.e. data=dat70. However the code fails to execute if I specify the model in the form of the commented line, i. e reg1 <-dynlm(form1,data=Dnames[j]) I get the following
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).
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
2011 Nov 30
2
forecasting linear regression from lagged variable
I'm currently working with 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 <-
2007 Oct 18
2
How to avoid conversion to factors (data frame to zoo)
Hi all, I was trying to convert a data frame to a zoo object so I can use some time series functions like lag(). But it seems then everything became a factor, so I have to convert it back to numeric to run the correct regressions. Is there a way to avoid it? Here is an example: ############################# a <- data.frame(nn =as.character(c("a", "b", "c",
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}}