Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: stats
See also: gls linregfs linregres 0glm doglm

Macro: linreg
Description: linreg computes the Generalized Least Squares estimate for the coefficients of a linear model.

Usage: {b,bse,bstan,bpval} = linreg (x, y{,opt, om})
Input:
x n x p x d1 x ... x dn array
y n x 1 x d1 x ... x dn array
opt string vector
om n x n x d1 x ... x dn array
Output:
b p x 1 x d1 x ... x dn array
bse p x 1 x d1 x ... x dn array
bstan p x 1 x d1 x ... x dn array
bpval p x 1 x d1 x ... x dn array

Note:

Example:
library("stats")
setenv("outputstringformat", "%s")    
randomize(1964)
n = 500
x = normal(n,3)
beta = #(10, 2, 3)
u = 0.5 * normal(n) 
y = x*beta .+ u
{beta,se,betastan,p} = linreg(x,y)  
Result:
Contents of out
[ 1,] 
[ 2,] A  N  O  V  A                   SS      df     MSS       F-test   P-value
[ 3,] _________________________________________________________________________
[ 4,] Regression                 61494.937     3 20498.312   80164.745   0.0000
[ 5,] Residuals                    126.828   496     0.256
[ 6,] Total Variation            61621.765   499   123.491
[ 7,] 
[ 8,] Multiple R      = 0.99897
[ 9,] R^2             = 0.99794
[10,] Adjusted R^2    = 0.99793
[11,] Standard Error  = 0.50567
[12,] 
[13,] 
[14,] PARAMETERS         Beta         SE         StandB        t-test   P-value
[15,] ________________________________________________________________________
[16,] b[ 0,]=         -0.0058       0.0227       0.0000        -0.254   0.6001
[17,] b[ 1,]=         10.0019       0.0215       0.9501       465.977   0.0000
[18,] b[ 2,]=          1.9906       0.0221       0.1839        90.263   0.0000
[19,] b[ 3,]=          3.0249       0.0231       0.2667       130.817   0.0000
Example:
library("stats")
randomize(1964)
n = 50
x = normal(n,3)
beta = #(10, 2, 3)
u = 0.5 * normal(n) 
y = x*beta .+ u
covar = (0.5.*x[,2] .+ 0.3.*x[,3]+ 0.2*x[,1]).^2
y = x*beta .+ sqrt(covar).*u
{beta,se,betastan,p} = linreg(x, y,"nointercept"|"display"|"omega",diag(covar))   
Result:

You see the display:
A  N  O  V  A                 SS       df     MSS      F-test     P-value
_________________________________________________________________________
Regression                 4782.570     3  1594.190    8526.286   0.0000
Residuals                     8.601    46     0.187
Total Variation            4846.290    49    98.904
Multiple R      = 0.99340
R^2             = 0.98685
Adjusted R^2    = 0.99811
Standard Error  = 0.43240
PARAMETERS         Beta        SE         StandB      t-test      P-value
_________________________________________________________________________
b[ 1,]=         10.0297      0.0643       0.9793      155.865     0.0000
b[ 2,]=          2.0544      0.0518       0.2452       39.661     0.0000
b[ 3,]=          2.9838      0.0706       0.2673       42.291     0.0000  

Library: stats
See also: gls linregfs linregres 0glm doglm

Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Author: Susanne Hannappel 961122
(C) MD*TECH Method and Data Technologies, 17.8.2000