similar to: cor() and lagged ts objects

Displaying 20 results from an estimated 10000 matches similar to: "cor() and lagged ts objects"

2003 Nov 11
1
cor
Greetings: It would seem to me that the three arguments "a", "c" and "p" ought to produce the same result with a data frame that doesn't have any missing data which is not the case. What am I doing wrong or what don't I understand? > tmp <- data.frame(vol,con,mot,esp,pri,sec) > tmp vol con mot esp pri sec 1 1.00 120 90 78 21 1 2 0.50
2012 Oct 11
2
ccf(x,y) vs. cor() of x and lagged values of y
Hi I'm computing the correlation between two time-series x_t and y_t-1 (time-series lagged using the lag(y,-1) function) using the cor() function and the returned value is different from the value of ccf() function at the same lag. Any ideas why this is so? Thanks in advance for any hints. Mihnea [[alternative HTML version deleted]]
2005 Jul 23
2
cor(X) with P-Value
Friends I am new to R (and statistics) so am struggling a bit. Briefly... I am interested in getting the P-Value from cor(X) where X is a matrix. I have found cor.test. Verbosely... I have 4 vectors and can generate the corellation matrix... > cor(cbind(X1, X2, X3, X4)) X1 X2 X3 X4 X1 1.00000000 -0.06190365 -0.156972795 0.182547517 X2
2009 Jun 14
1
time function behavior for ts class objects
Hi all- I am trying to use the time function for ts class objects and do not understand the return value. I want to use it to set up a time trend in arima fits. It does not seem to return a correct linear sequence that matches the underlying time series. I am running: R version 2.8.1 (2008-12-22). For example: R> ## create a time series R> x <- rnorm(24) R> (xts <-
2007 Dec 03
1
cor(data.frame) infelicities
In using cor(data.frame), it is annoying that you have to explicitly filter out non-numeric columns, and when you don't, the error message is misleading: > cor(iris) Error in cor(iris) : missing observations in cov/cor In addition: Warning message: In cor(iris) : NAs introduced by coercion It would be nicer if stats:::cor() did the equivalent *itself* of the following for a data.frame:
2012 Feb 16
3
Converting ts into xts and subsetting
Greetings, I would like to subset observations in a time series using xts, after converting from ts to xts. X=ts(1:100, frequency=12, start=c(1976)) X2=as.xts(X) X2["1984"] The output: Feb 1984 98 Mar 1984 99 Apr 1984 100 What happened to January? The index is always one month off, with X2["1976-01"] giving me Feb 1976. Should I set the time using something else
2012 Apr 12
4
Definition of "lag" is opposite in ts and xts objects!
Example: Will ts objects be obsolete or modified? > a [,1] 1983 Q1 2.747365190 1983 Q2 2.791594762 1983 Q3 -0.009953715 1983 Q4 -0.015059485 1984 Q1 -1.190061246 1984 Q2 -0.553031799 1984 Q3 0.686874720 1984 Q4 0.953911035> lag(a,4) [,1] 1983 Q1 NA 1983 Q2 NA 1983 Q3 NA 1983 Q4 NA 1984 Q1 2.747365190 1984 Q2
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 Nov 10
1
Need something like multiple plots in ts.plot but then change x values
Hi: I need to plot two data sets and then I need to change labels of xaxis. I can manage to achieve something like it with this: x<-data.frame(a=c(1,2,3,4,5),b=c(2,4,6,8,10)) y<-data.frame(a=c(3,4,5),b=c(1.5,2,2.5)) xts <- ts(x$b,start=x$a[1]) yts <- ts(y$b,start=y$a[1]) ts.plot(xts,yts,col=c("red","blue")) But ts.plot does not allow to change x labels. Besides,
2006 Aug 24
2
Why are lagged correlations typically negative?
Recently, I was working with some lagged designs where a vector of observations at one time was used to predict a vector of observations at another time using a lag 1 design. In the work, I noticed a lot of negative correlations, so I ran a simple simulation with 2 matched points. The crude simulation example below shows that the correlation can be -1 or +1, but interestingly if you do this
2006 Sep 04
1
merge files after cor.test
Dear All, Suppose I have 2 files: # first one : testid.csv A B C D E > (id<- read.table ("testid.csv",col.name=c("id"))) id 1 A 2 B 3 C 4 D 5 E # second file is the result file I calculate from cor.text, which shows the correlation coefficient. > cor.value.t 1 2 3 4 5 1 1.0000000 0.2156213 0.31000492
2015 Nov 11
2
Problema con la lectura de datos
?Hola, A mí me funciona la importación directa. Previamente he guardado la hoja de Excel en .csv (separado por ";"). Y hago sin problemas la correlación entre dos variables (las dos primeras). > datIn <- read.csv("Variables.csv", header=T, as.is=T, sep=";", dec=",") > head(datIn) EMPRESAS AA AB AC AD AE AF AG AH AI
2015 Nov 11
2
Problema con la lectura de datos
Hola. He estado viendo los datos que adjuntas en el correo. Al ser un fichero Excel xlsx ¿por qué no lo abres directamente? Te aconsejaría la librería openxlsx (si no la has usado nunca , instálala con install.packages(?openxlsx?)) Este es el código que he ejecutado y los resultados que obtengo: library(openxlsx) dat <- read.xlsx("Variables.xlsx") str(dat) Que produce:
2015 Nov 11
4
Problema con la lectura de datos
Has probado con cor(datos,use="pairwise.complete.obs") ??? > From: valeagui en outlook.es > To: cof en qualityexcellence.es; r-help-es en r-project.org > Date: Wed, 11 Nov 2015 15:13:55 +0000 > Subject: Re: [R-es] Problema con la lectura de datos > > Hola Carlos, muchas gracias....pero hago exactamente lo mismo que tu..y al intentar de hacer la matriz de
2007 Nov 07
1
(no subject)
hello, i am a bit of a statistical neophyte and currently trying to make some sense of confidence intervals for correlation coefficients. i am using the cor.test() function. the documentation is quite terse and i am having trouble tieing up the output from this function with stuff that i have read in the literature. so, for example, i make two sequences and calculate the correlation coefficient:
2009 Jul 07
1
cor vs cor.test
Hi, I am trying to use R for some survey analysis, and need to compute the significance of some correlations. I read the man pages for cor and cor.test, but I am confused about - whether these functions are intended to work the same way - about how these functions handle NA values - whether cor.test supports 'use = complete.obs'. Some example output may explain why I am confused:
2010 Jul 05
1
Linux-Windows problem
Dear All, I faced the following problem. With the same data.frame the results are different under Linux and Windows. Could you help on this topic? Thanks in advance, Ildiko Linux: > d = read.csv("CRP.csv") > d$drugCode = as.numeric(d$drug) > cor(d, use="pairwise.complete.obs") PATIENT BL.CRP X24HR.CRP X48HR.CRP drug drugCode PATIENT NA
2024 Jul 25
1
please help generate a square correlation matrix
?s 17:39 de 25/07/2024, Yuan Chun Ding via R-help escreveu: > Hi R users, > > I generated a square correlation matrix for the dat dataframe below; > dat<-data.frame(g1=c(1,0,0,1,1,1,0,0,0), > g2=c(0,1,0,1,0,1,1,0,0), > g3=c(1,1,0,0,0,1,0,0,0), > g4=c(0,1,0,1,1,1,1,1,0)) > library("Hmisc") > dat.rcorr =
2015 Nov 11
2
Problema con la lectura de datos
Si lo has guardado como csv separado por comas: Abre con cualquier editor el fichero: mira separador de listas y separador de decimal, supongamos que sea "; " para las listas (esto depende de tu configuración regional) y "." para los decimales (es como lo tienes en tu fichero) entonces dat<-read.csv("Variables.csv", header=T, sep=";",
2007 Jul 05
1
cor() and cor.test() (PR#9781)
Hello, I am trying to make a correlation matrix in R using cor() and also to get the p-value for each correlation using cor.test(). I can't get these commands to work. I'm getting errors like the following: cor(Pollution, Wet.days) Error in inherits(x, "data.frame") : Object "Wet.days" not found cor("Pollution", "Wet.days") Error in