Zhiqiu Hu
2013-Jan-09 21:45 UTC
[R] How to estate the correlation between two autocorrelated variables
Dear R users, In my data, there are two variables t1 and t2. For each observation of t1 and t2, two location indicators (x, y) were provided. The data format is # x y t1 t2 Since the both t1 and t2 are depended on x and y, t1 and t2 are autocorrelated variables. My question is how to calculate the correlation between t1 and t2 by taking into account the structure of residual variance caused by x and y. Seemly, the gls function in nlme/R package might can be used for the purpose. However, I failed to figure out how to use the function for my data. I appreciate your kind help providing an example code for the above data format. Please also let me know if there is any other more suitable R package for the analysis. Best regards, Zhiqiu [[alternative HTML version deleted]]
Nordlund, Dan (DSHS/RDA)
2013-Jan-09 22:16 UTC
[R] How to estate the correlation between two autocorrelated variables
> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Zhiqiu Hu > Sent: Wednesday, January 09, 2013 1:45 PM > To: r-help at r-project.org > Subject: [R] How to estate the correlation between two autocorrelated > variables > > Dear R users, > > In my data, there are two variables t1 and t2. For each observation of > t1 > and t2, two location indicators (x, y) were provided. > > The data format is > # x y t1 t2 > > Since the both t1 and t2 are depended on x and y, t1 and t2 are > autocorrelated variables. My question is how to calculate the > correlation > between t1 and t2 by taking into account the structure of residual > variance > caused by x and y. Seemly, the gls function in nlme/R package might can > be > used for the purpose. However, I failed to figure out how to use the > function for my data. I appreciate your kind help providing an example > code > for the above data format. Please also let me know if there is any > other > more suitable R package for the analysis. > > Best regards, > > Zhiqiu >If you want the partial correlation between t1 and t2 given x and y, then look at the pcor() function in the ppcor package. Hope this is helpful, Dan Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204
Apparently Analagous Threads
- Partial correlation test
- R code to reproduce (while studying) Bates & Watts 1988
- inquire a statistical terms
- Theoretical confidence regions for any non-symmetric bivariate statistical distributions
- Correlation among correlation matrices cor() - Interpretation