Skip to content

Commit a8c95bb

Browse files
committed
docs: update OLS now intercept (aka constant) returned first
1 parent 2a245bb commit a8c95bb

File tree

1 file changed

+21
-33
lines changed

1 file changed

+21
-33
lines changed

lib/PDL/Stats/GLM.pd

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -418,67 +418,57 @@ Usage:
418418
pdl> p "$_\t@{[$m{$_} =~ /^\n*(.*?)\n*\z/s]}\n" for sort keys %m
419419

420420
# 2 persons' ratings, each fitted with 3 "different" models
421-
422-
F
423-
[
421+
F [
424422
[ 38.314159 25.087209]
425423
[ 38.314159 25.087209]
426424
[ 38.314159 25.087209]
427425
]
428426

429427
# df is the same across dv and iv models
430-
431428
F_df [2 7]
432-
F_p
433-
[
429+
F_p [
434430
[0.00016967051 0.00064215074]
435431
[0.00016967051 0.00064215074]
436432
[0.00016967051 0.00064215074]
437433
]
438434

439-
R2
440-
[
435+
R2 [
441436
[ 0.9162963 0.87756762]
442437
[ 0.9162963 0.87756762]
443438
[ 0.9162963 0.87756762]
444439
]
445440

446-
b
447-
[ # linear quadratic constant
441+
b [ # constant linear quadratic
448442
[
449-
[ 0.99015152 -0.056818182 0.66363636] # person 1
450-
[ 0.18939394 0.022727273 1.4] # person 2
443+
[ 0.66363636 0.99015152 -0.056818182] # person 1
444+
[ 1.4 0.18939394 0.022727273] # person 2
451445
]
452446
[
453-
[ 0.49507576 -0.028409091 0.66363636]
454-
[ 0.09469697 0.011363636 1.4]
447+
[ 0.66363636 0.49507576 -0.028409091]
448+
[ 1.4 0.09469697 0.011363636]
455449
]
456450
[
457-
[ 0.33005051 -0.018939394 0.66363636]
458-
[ 0.063131313 0.0075757576 1.4]
451+
[ 0.66363636 0.33005051 -0.018939394]
452+
[ 1.4 0.063131313 0.0075757576]
459453
]
460454
]
461455

462456
# our novice modeler realizes at this point that
463457
# the 3 models only differ in the scaling of the IV coefficients
464-
465-
ss_model
466-
[
458+
ss_model [
467459
[ 20.616667 13.075758]
468460
[ 20.616667 13.075758]
469461
[ 20.616667 13.075758]
470462
]
471463

472-
ss_residual
473-
[
464+
ss_residual [
474465
[ 1.8833333 1.8242424]
475466
[ 1.8833333 1.8242424]
476467
[ 1.8833333 1.8242424]
477468
]
478469

479-
ss_total [22.5 14.9]
480-
y_pred
481-
[
470+
ss_total [22.5 14.9]
471+
y_pred [
482472
[
483473
[0.66363636 1.5969697 2.4166667 3.1227273 ... 4.9727273]
484474
...
@@ -1446,8 +1436,7 @@ Usage:
14461436
# suppose this is a person's ratings for top 10 box office movies
14471437
# ascending sorted by box office
14481438

1449-
pdl> p $y = qsort ceil( random(10) * 5 )
1450-
[1 1 2 2 2 2 4 4 5 5]
1439+
pdl> $y = pdl '[1 1 2 2 2 2 4 4 5 5]'
14511440

14521441
# construct IV with linear and quadratic component
14531442

@@ -1459,19 +1448,18 @@ Usage:
14591448

14601449
pdl> %m = $y->ols( $x )
14611450

1462-
pdl> p "$_\t$m{$_}\n" for sort keys %m
1451+
pdl> p "$_\t@{[$m{$_} =~ /^\n*(.*?)\n*\z/s]}\n" for sort keys %m
14631452

14641453
F 40.4225352112676
14651454
F_df [2 7]
14661455
F_p 0.000142834216344756
14671456
R2 0.920314253647587
14681457

1469-
# coeff linear quadratic constant
1470-
1471-
b [0.21212121 0.03030303 0.98181818]
1472-
b_p [0.32800118 0.20303404 0.039910509]
1473-
b_se [0.20174693 0.021579989 0.38987581]
1474-
b_t [ 1.0514223 1.404219 2.5182844]
1458+
# coeff constant linear quadratic
1459+
b [0.981818 0.212121 0.030303]
1460+
b_p [0.039910 0.328001 0.203034]
1461+
b_se [0.389875 0.201746 0.021579]
1462+
b_t [2.518284 1.051422 1.404218]
14751463
ss_model 19.8787878787879
14761464
ss_residual 1.72121212121212
14771465
ss_total 21.6

0 commit comments

Comments
 (0)