File: variances.R

package info (click to toggle)
r-cran-lava 1.8.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,816 kB
  • sloc: sh: 13; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 625 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
### Return position of variance elements in the parameter vector (without mean parameters)
### Optimization constraints are needed on these parameters
##' @export
variances <- function(x,mean=FALSE) {
##  if (is.null(x$parpos))
##    x$parpos <- parpos(x)
  x$parpos <- parpos(Model(x),mean=TRUE)
  res <- diag(x$parpos$P)[which(diag(index(x)$P0)==1)]
  if (!mean) {
    return(res - index(x)$npar.mean)
  }
  return(res)
}
## And the off-diagonal (covariance) parameters
##' @export
offdiags <- function(x,mean=FALSE) {
  parpos <- parpos(x,mean=mean)
  pp <- parpos$P
  pp[lower.tri(pp)][(index(x)$P0)[lower.tri(pp)]==1]
}