View previous topic :: View next topic |
Author |
Message |
Eli W
Joined: 01 Feb 2005 Posts: 402
|
Posted: Sun Jun 01, 2008 11:14 pm Post subject: Calculating adjusted plus/minus |
|
|
I finally took a stab at calculating adjusted plus/minus on my own, and it wasn't as hard as I anticipated. I wrote up some instructions partly as a reminder to myself for the future, and partly because I thought some other adventurous souls might be interested in calculating it on their own. But be warned - you need a pretty fast computer and Excel 2007 (it can probably be done with some other programs but the method I describe won't work with Excel 2003 because of its column limit).
http://www.countthebasket.com/blog/2008/06/01/calculating-adjusted-plus-minus/ _________________ Eli W. (formerly John Quincy)
CountTheBasket.com |
|
Back to top |
|
|
Mountain
Joined: 13 Mar 2007 Posts: 1527
|
Posted: Mon Jun 02, 2008 11:56 am Post subject: |
|
|
Now that you have the method down, do you think you will apply the full measure of it to calculating adjusted +/- for lineups (or pairs or triplets) eventually? |
|
Back to top |
|
|
Eli W
Joined: 01 Feb 2005 Posts: 402
|
Posted: Mon Jun 02, 2008 2:01 pm Post subject: |
|
|
Probably. _________________ Eli W. (formerly John Quincy)
CountTheBasket.com |
|
Back to top |
|
|
Ben
Joined: 13 Jan 2005 Posts: 266 Location: Iowa City
|
Posted: Tue Jun 03, 2008 1:24 am Post subject: |
|
|
That's great! I'm looking forward to see what you do with it. |
|
Back to top |
|
|
Eli W
Joined: 01 Feb 2005 Posts: 402
|
|
Back to top |
|
|
Mountain
Joined: 13 Mar 2007 Posts: 1527
|
Posted: Wed Jun 04, 2008 12:26 am Post subject: |
|
|
Thank you. |
|
Back to top |
|
|
Ben
Joined: 13 Jan 2005 Posts: 266 Location: Iowa City
|
|
Back to top |
|
|
Ilardi
Joined: 15 May 2008 Posts: 265 Location: Lawrence, KS
|
Posted: Wed Jun 04, 2008 1:46 pm Post subject: |
|
|
That's some very nice work. I had a similar method in mind for the offensive/defensive splits when Aaron B. and I work on them later this summer, but also plan to try instead a multivariate regression approach - i.e., one that models offensive and defensive efficiency as simultaneous dependent variables (that is, two dv's in the same model). That would seem to have the advantage of parsimony (one step) and would provide a direct estimate of the error term for each component, and I can't really think of a downside, can you? |
|
Back to top |
|
|
Scott S
Joined: 10 Feb 2008 Posts: 46 Location: East Rutherford, NJ
|
Posted: Sun Jul 06, 2008 8:15 pm Post subject: |
|
|
I can't seem to get my csv file to import into R. Every time I try it gives me the following message:
Error in file(file, "r") : cannot open the connection
In addition: Warning message:
In file(file, "r") :
cannot open file 'doc/adj0708.csv': No such file or directory
I have R-2.7.1 and have tried saving the csv file in many of the folders in the "R-2.7.1" folder and changed the name in my command accordingly for each (The file for the above command was saved in the location "C:\Program Files\R\R-2.7.1\doc". There was no "files" folder I could find in this version.) If it isn't obvious already, I have never used R before, so I apologize for my ignorance and would greatly appreciate any help or guidance you could offer. Thanks a ton. |
|
Back to top |
|
|
Ed Küpfer
Joined: 30 Dec 2004 Posts: 787 Location: Toronto
|
Posted: Sun Jul 06, 2008 8:20 pm Post subject: |
|
|
The easiest way to import data into R from a spreadsheet is to copy the data in the spreadsheet and use this function in R:
Code: | newdata <- read.table('clipboard' , sep=',' , head=T) |
Here you are telling R to copy the data from the clipboard. the "sep" part is saying that it is comma seprated data -- when I copy stuff from excel, I write for tab separated data. The "head=" part is telling R that the column names are in the data (TRUE) or not (FALSE). _________________ ed |
|
Back to top |
|
|
Eli W
Joined: 01 Feb 2005 Posts: 402
|
Posted: Sun Jul 06, 2008 8:35 pm Post subject: |
|
|
Hmm, thanks for catching that. I must have created the "files" directory on my own and forgot that it wasn't automatically created when R is installed.
If Ed's method doesn't work I would suggest trying to use the full path to the CSV file, making sure to use forward slashes instead of back-slashes.
Code: | adj0708 <- read.csv(file="c:/directoryname/adj0708.csv") |
Another option is to do it in two steps by first setting the working directory where the file is saved and then loading it.
Code: | setwd("c:/directoryname")
adj0708 <- read.csv(file="adj0708.csv") |
|
|
Back to top |
|
|
gcampbe2
Joined: 08 Jul 2008 Posts: 24 Location: around Detroit, MI
|
Posted: Wed Jul 09, 2008 5:36 pm Post subject: Eli |
|
|
great work! enjoy reading a lot of your stuff, Keep up the awesome ideas! _________________ Al Jefferson: I knew there was a possibility that if I tried to go for the max, I could possibly hurt my teammates down the road... |
|
Back to top |
|
|
Ben F.
Joined: 07 Mar 2005 Posts: 391
|
Posted: Thu Jul 17, 2008 4:01 pm Post subject: |
|
|
So I decided to try out Eli's method and I run into a problem with R that I wonder if anyone could help me out with: when I paste in the regression formula, it's too long, so it cuts off the lines after a certain amount of characters and then generates errors because of it. For example, it would do something where it would cut off the 0 from the end of one of the player codes, move it to the next line, and then say "Error: unexpected numeric constant in 0".
What am I doing wrong? |
|
Back to top |
|
|
Ed Küpfer
Joined: 30 Dec 2004 Posts: 787 Location: Toronto
|
Posted: Thu Jul 17, 2008 4:36 pm Post subject: |
|
|
Try pasting the formula into a text editor, then copying that and pasting it into R. R will not cut off lines for length like Excel -- I'm guessing that the cut-off issue is taking place before you get to R. _________________ ed |
|
Back to top |
|
|
Eli W
Joined: 01 Feb 2005 Posts: 402
|
Posted: Thu Jul 17, 2008 4:42 pm Post subject: |
|
|
This could be an issue with newer versions of R. When I paste the formula into R 2.5.1 I don't have any issues, but when I do the same in 2.7.1 I encounter the error that you mention. I'm not sure what the solution is. |
|
Back to top |
|
|
|