YOhio asked me why I haven't done any geek statistical posts in honor of the upcoming season. Lack of inspiration I guess. However, I am thinking I should help make geeky statistical analysis easier for the masses.
So here you go. My computer model program. Right now it is a raw margin of victory model but it is easy to change. I hope you find it useful YOhio. All you need is this program and the list of 1A and 1AA teams and the scores. It is not the fastest thing ever since it just using perl and not very efficient (in multiple ways) but it is only like a 40 seconds run time on a good computer.
Teams
Scores 2008
So here you go. My computer model program. Right now it is a raw margin of victory model but it is easy to change. I hope you find it useful YOhio. All you need is this program and the list of 1A and 1AA teams and the scores. It is not the fastest thing ever since it just using perl and not very efficient (in multiple ways) but it is only like a 40 seconds run time on a good computer.
Teams
Scores 2008
Code:
#!/usr/bin/perl
use Statistics::Regression;
open (FILE,"team.txt") or die "Can't open; $!\n";
$_ = <FILE>;
my %t;
my %team;
my $i = 0;
while (<FILE>) {
my ($tname) = split("\n",$_);
$tname =~ s/\s+$//;
$team{"$i"} = $tname;
$t{$tname} = $i++;
}
close (FILE);
my $skip = "244";
my $yvar = "mov";
my @xvar = ("hf");
foreach $key (sort keys %t) {
if ($t{$key} != $skip) {
push(@xvar,$t{$key});
}
}
my $reg = Statistics::Regression->new( "Computer Model",\@xvar);
open (FILE,"score_08.txt") or die "Can't open; $!\n";
$_ = <FILE>;
my %wins;
my %loses;
while (<FILE>) {
my $net = substr($_,72,1);
$net =~ s/\s+$//;
my $visitor = substr($_,10,27);
$visitor =~ s/\s+$//;
my $home = substr($_,41,27);
$home =~ s/\s+$//;
my $scored = substr($_,37,3);
my $allowed = substr($_,68,3);
my $mov = abs($scored - $allowed);
my $win = "h";
if ($scored > $allowed) {
$win = "v";
}
my $hf = 1;
if ($net ne "" && $net ne " ") {
$hf = 0;
}
elsif ($win eq "v") {
$hf = -1;
}
# Adjustments to neutral fields
if (($home eq "Kent St" && $visitor eq "Boston College")
|| ($home eq "Washington St" && $visitor eq "Oklahoma St")
|| ($home eq "Colorado" && $visitor eq "Florida St")) {
my $hf = 1;
if ($win eq "v") {
$hf = -1;
}
}
if (($home eq "Arkansas" && $visitor eq "Louisiana-Monroe")) {
my $hf = -1;
if ($win eq "v") {
$hf = 1;
}
}
# End adjustments to neutral fields
if ($t{$visitor} ne "" && $t{$home} ne "") {
if ($win eq "h") {
my $xvar = $t{$home};
$wins{$xvar} += 1;
$xvar = $t{$visitor};
$loses{$xvar} += 1;
}
else {
my $xvar = $t{$home};
$loses{$xvar} += 1;
$xvar = $t{$visitor};
$wins{$xvar} += 1;
}
my @x = ($hf);
foreach $key (sort keys %t) {
if ($t{$key} != $skip) {
if ($key eq $home) {
if ($win eq "h") {
push(@x,1);
}
else {
push(@x,-1);
}
}
elsif ($key eq $visitor) {
if ($win eq "v") {
push(@x,1);
}
else {
push(@x,-1);
}
}
else {
push(@x,-0);
}
}
}
$reg->include($mov,\@x);
}
}
my @theta = $reg->theta();
sort @tmp = sort {$a <=> $b} @theta;
my $rmin = $tmp[0];
my %r;
$r{$skip} = 0.0;
for (my $i = 1; $i < $#xvar; ++$i) {
$r{$xvar[$i]} = $theta[$i] - $rmin;
}
print "NCAA Football: 2008\n";
print "Computer Rating Model: Margin of Victory (RAW)\n";
print "Only Division 1A and 1AA games used\n\n";
printf("%-5s %-22s %7s %3s %3s\n","Rank","Team","Rating","W","L");
my $i = 1;
foreach $key (sort {$r{$b} <=> $r{$a}} keys %r) {
printf("%-5d %-22s %7.3f %3d %3d\n",$i++,$team{$key},$r{$key},$wins{$key},
$loses{$key});
}
Comment