faprior<-function(y){ # This function estimates the mean (yb) and the background # observable error covariance (c) of the prior distribution # of y given by y~N(yb,c) # # USAGE: faprior(y) # # INPUT: # y -> n x q data matrix containing q observable time series # # OUTPUTS: # yb -> 1 x q matrix containing the column means of y # c -> q x q observable state covariance matrix # # Authors: Caio Coelho # David Stephenson # # Calculate column means of y and store in yb (1 x q) yb <- t(apply(y, 2, mean)) # # # Estimates observable state covariance matrix (c) - biased estimate 1/N # c <- var(y)*(nrow(y)-1)/nrow(y) list(yb = yb, c = c) }