Re: [R] Create an AR(1) covariance matrix

From: Peter Dalgaard <P.Dalgaard_at_biostat.ku.dk>
Date: Fri, 11 May 2007 16:55:09 +0200

Dimitris Rizopoulos wrote:
> 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
>
>

Hmm, I'd rather use

x <- diag(5)
x <- sigma * rho^abs(row(x)-col(x))

    -p

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard_at_biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-help_at_stat.math.ethz.ch mailing list
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.
Received on Fri 11 May 2007 - 15:03:51 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 11 May 2007 - 15:31:36 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.