Skip to content
Prev 115555 / 398500 Next

Create an AR(1) covariance matrix

one option is the following:

times <- 1:5
rho <- 0.5
sigma <- 2
###############
H <- abs(outer(times, times, "-"))
V <- sigma * rho^H
p <- nrow(V)
V[cbind(1:p, 1:p)] <- V[cbind(1:p, 1:p)] * sigma
V


I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Rick DeShon" <deshon at msu.edu>
To: <r-help at stat.math.ethz.ch>
Sent: Friday, May 11, 2007 4:29 PM
Subject: [R] Create an AR(1) covariance matrix
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm