Library: | stats |
See also: | linregstep linregfs2 linregopt gls linregfs linregres doglm |
Quantlet: | linregbs | |
Description: | linregbs computes a backward elimination of a multiple linear regression model. |
Usage: | {b,bse,bstan,bpval} = linregbs (x, y, colname{, opt}) | |
Input: | ||
x | n x p x d1 x ... x dn array | |
y | n x 1 x d1 x ... x dn array | |
colname | string vector | |
opt | scalar | |
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 |
library("stats") setenv("outputstringformat", "%s") x1 = #(7,1,11,11,7,11,3,1,2,21,1,11,10) x2 = #(26,29,56,31,52,55,71,31,54,47,40,66,68) x3 = #(6,15,8,8,6,9,17,22,18,4,23,9,8) x4 = #(60,52,20,47,33,22,6,44,22,26,34,12,12) x = x1~x2~x3~x4 y = #(78.5,74.3,104.3,87.6,95.9,109.2,102.7,72.5) y = y|#(93.1,115.9,83.8,113.3,109.4) colname=string("X %.f",1:cols(x)) opt = linregopt("Fout", 3.9) {beta,se,betastan,p} = linregbs(x,y,colname,opt)
Contents of string [1,] Out : X 3 Contents of string [1,] Out : X 4 Contents of Removal [ 1,] Backward Elimination [ 2,] ------------------------------- [ 3,] F-to-remove 3.90 [ 4,] probability of F-to-remove 0.94 [ 5,] [ 6,] Step Multiple R R^2 F SigF Variable(s) [ 7,] 1 0.9911 0.9824 111.479 0.000 Out: none [ 8,] 2 0.9911 0.9823 166.823 0.000 Out: X 3 [ 9,] 3 0.9893 0.9787 229.504 0.000 Out: X 4 [10,] [11,] Variable removed at Step Number 3 = X 4 Contents of ANOVA [ 1,] [ 2,] A N O V A SS df MSS F-test P-value [ 3,] _________________________________________________________________________ [ 4,] Regression 2657.859 2 1328.929 229.504 0.0000 [ 5,] Residuals 57.904 1e+01 5.790 [ 6,] Total Variation 2716 12 226.314 [ 7,] [ 8,] Multiple R = 0.98928 [ 9,] R^2 = 0.97868 [10,] Adjusted R^2 = 0.97441 [11,] Standard Error = 2.40634 Contents of Summary [1,] Variables in the Equation for Y: [2,] [3,] [4,] PARAMETERS Beta SE StandB t-test P-value Variable [5,] __________________________________________________________________________________ [6,] b[ 0,]= 52.5773 2.2862 0.0000 22.9980 0.0000 Constant [7,] b[ 1,]= 1.4683 0.1213 0.5741 12.1047 0.0000 X 1 [8,] b[ 2,]= 0.6623 0.0459 0.6850 14.4424 0.0000 X 2