# Variance-covariance matrix

8 messages
Open this post in threaded view
|

## Variance-covariance matrix

 Hi, I am looking for a R package providing with variance-covariance matrix computation of univariate time series. Please, any suggestions ? Regards, Giorgio         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Variance-covariance matrix

 On May 10, 2015, at 4:27 AM, Giorgio Garziano wrote: > Hi, > > I am looking for a R package providing with variance-covariance matrix computation of univariate time series. > > Please, any suggestions ? If you mean the auto-correlation function, then the stats package (loaded by default at startup) has facilities: ?acf # also same help page describes partial auto-correlation function #Auto- and Cross- Covariance and -Correlation Function Estimation -- David Winsemius Alameda, CA, USA ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Variance-covariance matrix

 Hi, Actually as variance-covariance matrix I mean:         http://stattrek.com/matrix-algebra/covariance-matrix.aspxthat I compute by:         data <- rnorm(10,2,1)         n <- length(data)         data.center <- scale(data, center=TRUE, scale=FALSE)         var.cov.mat <- (1/(n-1)) * data.center %*% t(data.center) -- Giorgio Garziano -----Original Message----- From: David Winsemius [mailto:[hidden email]] Sent: domenica 10 maggio 2015 21:27 To: Giorgio Garziano Cc: [hidden email] Subject: Re: [R] Variance-covariance matrix On May 10, 2015, at 4:27 AM, Giorgio Garziano wrote: > Hi, > > I am looking for a R package providing with variance-covariance matrix computation of univariate time series. > > Please, any suggestions ? If you mean the auto-correlation function, then the stats package (loaded by default at startup) has facilities: ?acf # also same help page describes partial auto-correlation function #Auto- and Cross- Covariance and -Correlation Function Estimation -- David Winsemius Alameda, CA, USA ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Variance-covariance matrix

 Hi Giorgio, For a univariate time series? Seriously? data <- rnorm(10,2,1) as.matrix(var(data)) Cheers, Tsjerk On Sun, May 10, 2015 at 9:54 PM, Giorgio Garziano < [hidden email]> wrote: > Hi, > > Actually as variance-covariance matrix I mean: > >         http://stattrek.com/matrix-algebra/covariance-matrix.aspx> > that I compute by: > >         data <- rnorm(10,2,1) >         n <- length(data) >         data.center <- scale(data, center=TRUE, scale=FALSE) >         var.cov.mat <- (1/(n-1)) * data.center %*% t(data.center) > > -- > Giorgio Garziano > > > -----Original Message----- > From: David Winsemius [mailto:[hidden email]] > Sent: domenica 10 maggio 2015 21:27 > To: Giorgio Garziano > Cc: [hidden email] > Subject: Re: [R] Variance-covariance matrix > > > On May 10, 2015, at 4:27 AM, Giorgio Garziano wrote: > > > Hi, > > > > I am looking for a R package providing with variance-covariance matrix > computation of univariate time series. > > > > Please, any suggestions ? > > If you mean the auto-correlation function, then the stats package (loaded > by default at startup) has facilities: > > ?acf > # also same help page describes partial auto-correlation function > #Auto- and Cross- Covariance and -Correlation Function Estimation > > -- > > David Winsemius > Alameda, CA, USA > > ______________________________________________ > [hidden email] mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. > -- Tsjerk A. Wassenaar, Ph.D.         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Variance-covariance matrix

 Hi Tsjerk, Yes, seriously. Time series: X = [x1, x2, x3, ....,xn] The variance-covariance matrix is V matrix:             V    = Σ x12 / (N-1) Σ x1 x2 / (N-1) . . . Σ x1 xn / (N-1) Σ x2 x1 / (N-1) Σ x22 / (N-1) . . . Σ x2 xn / (N-1) . . . . . . . . . . . . Σ xn x1 / (N-1) Σ xn x2 / (N-1) . . . Σ xn2 / (N-1) Reference: “Time series and its applications – with R examples”, Springer,      \$7.8 “Principal Components” pag. 468, 469 Cheers, Giorgio From: Tsjerk Wassenaar [mailto:[hidden email]] Sent: domenica 10 maggio 2015 22:11 To: Giorgio Garziano Cc: [hidden email] Subject: Re: [R] Variance-covariance matrix Hi Giorgio, For a univariate time series? Seriously? data <- rnorm(10,2,1) as.matrix(var(data)) Cheers, Tsjerk On Sun, May 10, 2015 at 9:54 PM, Giorgio Garziano <[hidden email]> wrote: Hi, Actually as variance-covariance matrix I mean:         http://stattrek.com/matrix-algebra/covariance-matrix.aspxthat I compute by:         data <- rnorm(10,2,1)         n <- length(data)         data.center <- scale(data, center=TRUE, scale=FALSE)         var.cov.mat <- (1/(n-1)) * data.center %*% t(data.center) -- Giorgio Garziano -----Original Message----- From: David Winsemius [mailto:[hidden email]] Sent: domenica 10 maggio 2015 21:27 To: Giorgio Garziano Cc: [hidden email] Subject: Re: [R] Variance-covariance matrix On May 10, 2015, at 4:27 AM, Giorgio Garziano wrote: > Hi, > > I am looking for a R package providing with variance-covariance matrix computation of univariate time series. > > Please, any suggestions ? If you mean the auto-correlation function, then the stats package (loaded by default at startup) has facilities: ?acf # also same help page describes partial auto-correlation function #Auto- and Cross- Covariance and -Correlation Function Estimation -- David Winsemius Alameda, CA, USA ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code. -- Tsjerk A. Wassenaar, Ph.D.         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Variance-covariance matrix

 Hi Giorgio, This is for a multivariate time series. x1 is variable 1 of the observation vector x, x2, variable 2, etc. If you need x(i) and x(i+1), etc, then you're looking for the autocovariance/autocorrelation matrix, which is a quite different thing (and David showed the way). You can easily see that you don't have N-1 degrees of freedom per entry, because you have fewer 'observations' for larger lag times. Cheers, Tsjerk On Sun, May 10, 2015 at 10:25 PM, Giorgio Garziano < [hidden email]> wrote: >  Hi Tsjerk, > > > > Yes, seriously. > > > > Time series: > > > > X = [x1, x2, x3, ....,xn] > > > > The variance-covariance matrix is V matrix: > > > > *            V*    = > > Σ *x*12 / (N-1) > > Σ *x*1 *x*2 / (N-1) > > . . . > > Σ *x*1 xn / (N-1) > > Σ *x*2 *x*1 / (N-1) > > Σ *x*22 / (N-1) > > . . . > > Σ *x*2 *x*n / (N-1) > > . . . > > . . . > > . . . > > . . . > > Σ *x*n *x*1 / (N-1) > > Σ *x*n *x*2 / (N-1) > > . . . > > Σ *x*n2 / (N-1) > > > > > > Reference: “Time series and its applications – with R examples”, > Springer, > >      \$7.8 “Principal Components” pag. 468, 469 > > > > Cheers, > > > > Giorgio > > > > > > *From:* Tsjerk Wassenaar [mailto:[hidden email]] > *Sent:* domenica 10 maggio 2015 22:11 > > *To:* Giorgio Garziano > *Cc:* [hidden email] > *Subject:* Re: [R] Variance-covariance matrix > > > > Hi Giorgio, > > > > For a univariate time series? Seriously? > > > > data <- rnorm(10,2,1) > > as.matrix(var(data)) > > > > Cheers, > > > > Tsjerk > > > > > > On Sun, May 10, 2015 at 9:54 PM, Giorgio Garziano < > [hidden email]> wrote: > > Hi, > > Actually as variance-covariance matrix I mean: > >         http://stattrek.com/matrix-algebra/covariance-matrix.aspx> > that I compute by: > >         data <- rnorm(10,2,1) >         n <- length(data) >         data.center <- scale(data, center=TRUE, scale=FALSE) >         var.cov.mat <- (1/(n-1)) * data.center %*% t(data.center) > > -- > Giorgio Garziano > > > > -----Original Message----- > From: David Winsemius [mailto:[hidden email]] > Sent: domenica 10 maggio 2015 21:27 > To: Giorgio Garziano > Cc: [hidden email] > Subject: Re: [R] Variance-covariance matrix > > > On May 10, 2015, at 4:27 AM, Giorgio Garziano wrote: > > > Hi, > > > > I am looking for a R package providing with variance-covariance matrix > computation of univariate time series. > > > > Please, any suggestions ? > > If you mean the auto-correlation function, then the stats package (loaded > by default at startup) has facilities: > > ?acf > # also same help page describes partial auto-correlation function > #Auto- and Cross- Covariance and -Correlation Function Estimation > > -- > > David Winsemius > Alameda, CA, USA > > ______________________________________________ > [hidden email] mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. > > > > > > -- > > Tsjerk A. Wassenaar, Ph.D. > -- Tsjerk A. Wassenaar, Ph.D.         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.