similar to: series at low freq expanded into high freq

Displaying 20 results from an estimated 20000 matches similar to: "series at low freq expanded into high freq"

2009 Jun 18
3
Replace zeroes in vector with nearest non-zero value
Folks, If I have a vector such as the following: x <- c(0, -1, -1, -1, 0, 0, 1, -1, 1, 0) and I want to replace the zeroes by the nearest non-zero number to the left, is there a more elegant way to do this than the following loop? y <- x for (i in 2 : length(x)) { if (y[i] == 0) { y[i] <- y[i - 1] } } > y [1] 0 -1 -1 -1 -1 -1 1 -1 1 1 You can see the
2009 Mar 27
2
adding matrices with common column names
folks, if i have three matrices, a, b, cc with some colnames in common, and i want to create a matrix which consists of the common columns added up, and the other columns tacked on, what's a good way to do it? i've got the following roundabout code for two matrices, but if the number of matrices increases, then i'm a bit stymied. > a <- matrix(1:20,ncol=4); colnames(a) <-
2008 Nov 05
2
matrix indexing and update
Folks, I have a matrix: set.seed(123) a <- matrix(rnorm(100), 10) And a vector: b <- rnorm(10) Now, I want to switch the signs of those rows of a corresponding to indices in b whose values exceed the 75 %-ile of b which(b > quantile(b)[4]) [1] 2 6 10 so I want, in effect: a[2, ] <- -a[2, ] a[6, ] <- -a[6, ] a[10, ] <- -a[10, ] I thought I could do a[which(b >
2009 Mar 02
2
Goldbach partitions code
Folks, I put up a brief note describing my naive attempts to compute Goldbach partitions, starting with a brute-force approach and refining progressively. http://jostamon.blogspot.com/2009/02/goldbachs-comet.html I'd welcome your suggestions on improvements, alternatives, other optimisations, esp. to do with space vs time tradeoffs. Is this an example interesting enough for
2010 Jan 20
1
min and max operations on matrix
Folks, I've got a matrix x as follows: > x <- matrix(c(1,2,3,5,3,4,3,2,1), ncol = 3, byrow = TRUE) > x [,1] [,2] [,3] [1,] 1 2 3 [2,] 5 3 4 [3,] 3 2 1 In each row of x, I want to replace the minimum value by -1, the maximum value by +1 and all other values by 0. So in the above case I want to end up as follows: [,1] [,2] [,3] [1,] -1 0
2008 Jul 02
5
multiplication question
folks, is there a clever way to compute the sum of the product of two vectors such that the common indices are not multiplied together? i.e. if i have vectors X, Y, how can i compute Sum (X[i] * Y[j]) i != j where i != j also, what if i wanted Sum (X[i] * Y[j] * R[i, j]) i != j where R is a matrix? thanks, murali
2007 Mar 29
1
creating conditional list of elements
Sorry to plague the list, but I think I got the answer. The following would do: > signalList <- list(tradingRules$Signal[tradingRules$Enabled]) [[1]] > length(signalList) [1] 2 Now my problem is shifted: I have the Signal column in the original data frame referring to actual matrices previously created in R. That is, bar_signal and cif_signal are extant matrices. What I need is the
2009 Dec 22
1
Using zoo() to aggregate daily data to monthly means
I am trying to get monthly means for a daily data series using zoo(). I have found an odd problem, that seems to be caused by zoo()'s handling of leap years. Here's my R script with 2 methods (freq=365, 366) for aggregating the daily data to monthly series: library(zoo) J_link <- "http://www.ijis.iarc.uaf.edu/seaice/extent/plot.csv" JAXA_data <- read.table(J_link,
2009 Apr 15
2
From daily series to monthly and viceversa
I have the following daily exchange rate series (from january 1st 1996 to december 31st 2008) and I want to obtain them monthly series from it. I've read about the 'zoo' library but I'm not getting it how to do it. These are the data (left column day-month-year, right column the index) 31/12/1993 1,12509 03/01/1994 1,12509 04/01/1994 1,12558 05/01/1994 1,1258 06/01/1994 1,12596
2010 Aug 11
2
Sweeping a zoo series
Given a long zoo matrix, the goal is to "sweep" out a statistic from the entire length of the sequences. longzoomatrix<-zoo(matrix(rnorm(720),ncol=6),as.yearmon(outer(1900,seq(0,length=120)/12,"+"))) cnames<-c(12345,23456,34567,45678,56789,67890) colnames(longzoomatrix)<-cnames longzoomatrix[1:24,] 12345 23456 34567 45678
2011 Oct 27
2
Simple time series question with zoo
New user here. My goal is pull daily averages from a long dataset. I've been working with some code I got from this list from https://stat.ethz.ch/pipermail/r-help/2009-March/191302.html The code how I have been using it is as follows: library(zoo) library(chron) DB<-read.table("/Users/me/Desktop/R/data.csv", sep=",", header=TRUE, as.is =TRUE) z<-zoo(LTER6$temp,
2010 Jul 12
3
How to create sequence in month
Hi all, can anyone please guide me how to create a sequence of months? Here I have tried following however couldn't get success > library(zoo) > seq(as.yearmon("2010-01-01"), as.yearmon("2010-03-01"), by="1 month") Error in del/by : non-numeric argument to binary operator What is the correct way to do that? Thanks for your time.
2007 Sep 19
3
Row-by-row regression on matrix
Folks, I have a 3000 x 4 matrix (y), which I need to regress row-by-row against a 4-vector (x) to create a matrix lm.y of intercepts and slopes. To illustrate: y <- matrix(rnorm(12000), ncol = 4) x <- c(1/12, 3/12, 6/12, 1) system.time(lm.y <- t(apply(y, 1, function(z) lm(z ~ x)$coefficient))) [1] 44.72 18.00 69.52 NA NA Takes more than a minute to do (and I need to do many
2007 Feb 13
2
Computing stats on common parts of multiple dataframes
Folks, I have three dataframes storing some information about two currency pairs, as follows: R> a EUR-USD NOK-SEK 1.23 1.33 1.22 1.43 1.26 1.42 1.24 1.50 1.21 1.36 1.26 1.60 1.29 1.44 1.25 1.36 1.27 1.39 1.23 1.48 1.22 1.26 1.24 1.29 1.27 1.57 1.21 1.55 1.23 1.35 1.25 1.41 1.25 1.30 1.23 1.11 1.28 1.37 1.27 1.23 R> b EUR-USD NOK-SEK 1.23 1.22 1.21 1.36 1.28 1.61 1.23 1.34 1.21 1.22
2007 Sep 20
1
Time series graphs, question about using zoo
Hi, Can you tell me what is the meaning for "tail, 1" in "aggregate"? I also want to get some similar graph, but the data is not time series data. Suppose here is my data one, I want a graph with x-axis is just the index(1:9). The graph plot all the variable A, B,C,D. So there should be 4 lines for each graph. For the A line, at each time point, the letter A should be on
2010 Jun 17
1
Help with interpolation of time series
I'm quite new to R. I have a time series of annual state population estimates from census.gov, and I'd like to get a time series of monthly estimates, by a nonlinear interpolation. How can I do this in R? Thanks! [[alternative HTML version deleted]]
2017 Oct 06
2
Time series: xts/zoo object at annual (yearly) frequency
Hi, I'd like to make a time series at an annual frequency. > a<-xts(x=c(2,4,5), order.by=c("1991","1992","1993")) Error in xts(x = c(2, 4, 5), order.by = c("1991", "1992", "1993")) : order.by requires an appropriate time-based object > a<-xts(x=c(2,4,5), order.by=1991:1993) Error in xts(x = c(2, 4, 5), order.by =
2012 Aug 03
1
How can I read time series data to create zoo objects if I have two title lines?
Hello, This is a standard example in which I read the time series data from a csv file and create a zoo object: x0 <- read.csv(file="CPI.csv", header=TRUE) time_0<-as.yearmon("1981-01")+(0:371)/12 x0zoo<-zoo(x0, time_0) The data look like this: TIME CPI CPI_food CPI_Clothes CPI_House CPI_Rent 198101 62.1 55.34 103.45 65.24 61.43 198102 63.16 56.95
2010 Nov 23
2
Plot two zoo object with different indexes
Dear R community, I have the following two zoo objects: MONTHLY CPI > plot(z) > par("usr") [1] 1977.76333 2011.15333 70.39856 227.03744 > z=zooreg(cpius$Value,as.yearmon("1979-11"),frequency=12) > str(z) ?zooreg? series from Nov 1979 to Oct 2010 Data: num [1:372] 76.2 77 77.8 78.5 79.5 80.3 81.1 82 82 82.6 ... Index: Class 'yearmon' num [1:372]
2012 Feb 20
2
stats on transitions from one state to another
Folks, I'm trying to get stats from a matrix for each transition from one state to another. I have a matrix x as below. structure(c(0, 2, 2, 2, 0, 0, 0, 1, 1, 1, 1, 2, 2, 1, 1, 1, 0, 0, 2, 2, 0.21, -0.57, -0.59, 0.16, -1.62, 0.18, -0.81, -0.19, -0.76, 0.74, -1.51, 2.79, 0.41, 1.63, -0.86, -0.81, 0.39, -1.38, 0.06, 0.84, 0.51, -1, -1.29, 2.15, 0.39, 0.78, 0.85, 1.18, 1.66, 0.9, -0.94,