Library: | xplore |
Macro: | gls | |
Description: | Computes the Generalized Least Squares estimate for the coefficients of a linear model when the errors have as covariance matrix sigma^2 * om. |
Usage: | b = gls (x, y{, om}) | |
Input: | ||
x | n x p x d1 x ... x dn array | |
y | n x 1 x d1 x ... x dn array | |
om | optional, n x n x d1 x ... x dn array | |
Output: | ||
b | p x 1 x d1 x ... x dn array |
library("xplore") randomize(1964) n = 50 x = matrix(n)~normal(n,2) beta = #(10, 2, 3) u = 0.5 * normal(n) y = x*beta .+ u b = gls (x, y) b
Contents of b [1,] 9.97 [2,] 1.9116 [3,] 3.0123
library("xplore") randomize(1964) n = 50 x = matrix(n)~normal(n,2) beta = #(10, 2, 3) covar = (0.5.*x[,2] .+ 0.3.*x[,3]).^2 y = x*beta .+ sqrt(covar).*u b2 = gls (x, y, diag(covar)) b2
Contents of b2 [1,] 9.9977 [2,] 1.9946 [3,] 3.0093
Library: | xplore |