Page 2 of 3

Re: Setting Up Excel File for RAPM

Posted: Sun Aug 07, 2016 8:15 am
by permaximum
It appears you didn't use lambda.min or you made a miscalculation at cross-validation stage. Because RAPM values are too high thanks to your small lambda value. As for the list I don't remember 2009's RAPM but I can say it's not correct. Some names just shouldn't be there at the top.

Re: Setting Up Excel File for RAPM

Posted: Sun Aug 07, 2016 11:56 pm
by KwameBeanJordan
permaximum wrote:It appears you didn't use lambda.min or you made a miscalculation at cross-validation stage. Because RAPM values are too high thanks to your small lambda value. As for the list I don't remember 2009's RAPM but I can say it's not correct. Some names just shouldn't be there at the top.
Here's the code I used. I think it did use the Correct lambda. Maybe the issue is that my version of RStudio is earlier than what glmnet was constructed for (I think)? Although I read that wouldn't be a problem.

Note: The csv I imported was the matrix of 1s, -1s, and 0s with two columns containing the "margin of victory" and the possessions played during each stint.

Code: Select all


> Marg=data$Margin
> Poss=data$Poss
> data$Margin=NULL
> data$Poss=NULL
> x=data.matrix(data)
> lambda=cv.glmnet(x, Marg, weights=Poss, nfolds=10)
> lambda.min=lambda$lambda.min
> ridge=glmnet(x, Marg, family=c("gaussian"), Poss, alpha=0, standardize=FALSE, lambda=lambda.min)
> coef(ridge, s=lambda.min)

If there's typos it's probably because I couldn't directly copy my code. I have to type it in using my phone since my internet is currently not working.

Re: Setting Up Excel File for RAPM

Posted: Mon Aug 08, 2016 8:41 am
by permaximum
It's been a very long time but If I remember correct, you're doing it wrong. You should suppose to use one formula to find the best lambda and player coefficients according to that. It should be like;

file = read.table "("c:\.......\file.csv", sep=";" , header="TRUE")
x = as.matrix(file[c('P1","P2",P3"....."P-LAST")]) or x = data.matrix(file[1:length(file)-2])
y = as.matrix(file[c("Margin")])
Poss = file$Poss

and after those comes the juicy part;

fit = cv.glmnet (x, y, alpha=0, weights=Poss, nfolds=10, standardize=FALSE, parallel = TRUE (multi-threading to reduce time to calculate))

to get the results on screen simply;

coef(fit, s="lambda.min")

Re: Setting Up Excel File for RAPM

Posted: Mon Aug 08, 2016 9:34 am
by mystic
permaximum wrote:Unfortunately as you know only glmnet provides weighted ridge regression in R.
Indeed, I'm not aware of a package besides glmnet which would allow weighted ridge regression. But you could still write down the equations and then solve it (the matrix package contains a function solve()), and you can get quite easily weighted ridge regression. Though, you have to have an understanding of matrix algebra in order to come up with the correct equations as well as creating the necessary matrices.
KwameBeanJordan wrote: Yeah, thanks a ton, that guide is very useful. Last night it took several hours for me to set up a single excel file due to computing times. Using the formulas in that guide it took just a couple of minutes. Not to mention it's very thorough and could be used by some with absolutely no knowledge of Excel.
Eli Witus did a wonderful job explaining it, as you said, even someone without any knowledge of Excel should be able to get it done with that guide.
permaximum wrote:There are some serious wrong information on that guide. I can't remember atm but it will lead to wrong results if you try to calculate RAPM.
Well, it is a guide to calculate APM ... and the main purpose of that link is to help creating the necessary csv-file, and I don't see anything wrong with that.

Re: Setting Up Excel File for RAPM

Posted: Mon Aug 08, 2016 9:36 am
by mystic
KwameBeanJordan wrote:

Code: Select all


> Marg=data$Margin
> Poss=data$Poss
> data$Margin=NULL
> data$Poss=NULL
> x=data.matrix(data)
> lambda=cv.glmnet(x, Marg, weights=Poss, nfolds=10)
> lambda.min=lambda$lambda.min
> ridge=glmnet(x, Marg, family=c("gaussian"), Poss, alpha=0, standardize=FALSE, lambda=lambda.min)
> coef(ridge, s=lambda.min)

Couple of notes:

Use the parallel option for cv.glmnet. Install the package doParallel first, then use this code:

Code: Select all

library(doParallel)
registerDoParallel(x)
lambda=cv.glmnet(..., parallel=TRUE ...)
The x is the number of CPU cores you want to assign to the task.

The Marg and Poss should be a column (just using data$Poss will put it into a row), therefore use: Poss<-data.matrix(Poss) and Marg<-data.matrix(Marg) before you run cv.glmnet and glmnet. The default for family is gaussian, therefore you don't need to specify it again. alpha=0 and standardize=FALSE should be used for the cv.glmnet as well.

Your code would then look like this:

Code: Select all

library(doParallel)
registerDoParallel(x)
library(glmnet)
data<-read.csv(" ... ")
Marg<-data$Margin
Poss<-data$Poss
Marg<-data.matrix(Marg)
Poss<-data.matrix(Poss)
data$Margin=NULL
data$Poss=NULL
x<-data.matrix(data)
lambda<-cv.glmnet(x, Marg, Poss, nfolds=10, alpha=0, standardize=FALSE, parallel=TRUE)
lambda.min<-lambda$lambda.min
ridge<-glmnet(x, Marg, Poss, alpha=0, standardize=FALSE, lambda=lambda.min)
coef(ridge, s=lambda.min)

Re: Setting Up Excel File for RAPM

Posted: Mon Aug 08, 2016 10:18 am
by permaximum
mystic wrote: Couple of notes:

Use the parallel option for cv.glmnet. Install the package doParallel first, then use this code:

Code: Select all

library(doParallel)
registerDoParallel(x)
lambda=cv.glmnet(..., parallel=TRUE ...)
The x is the number of CPU cores you want to assign to the task.

The Marg and Poss should be a column (just using data$Poss will put it into a row), therefore use: Poss<-data.matrix(Poss) and Marg<-data.matrix(Marg) before you run cv.glmnet and glmnet. The default for family is gaussian, therefore you don't need to specify it again. alpha=0 and standardize=FALSE should be used for the cv.glmnet as well.

Your code would then look like this:

Code: Select all

library(doParallel)
registerDoParallel(x)
library(glmnet)
data<-read.csv(" ... ")
Marg<-data$Margin
Poss<-data$Poss
Marg<-data.matrix(Marg)
Poss<-data.matrix(Poss)
data$Margin=NULL
data$Poss=NULL
x<-data.matrix(data)
lambda<-cv.glmnet(x, Marg, Poss, nfolds=10, alpha=0, standardize=FALSE, parallel=TRUE)
lambda.min<-lambda$lambda.min
ridge<-glmnet(x, Marg, Poss, alpha=0, standardize=FALSE, lambda=lambda.min)
coef(ridge, s=lambda.min)
Ah, yes. I forgot you need to install doParallel for multi-threading to work. I remember it now. However, there is one thing that's useful which is missing in that code and also I can give an another hint. First you should have "require(doParallel)" despite having library(doParallel) in the beginning of the code. Just before using cv.glmnet i had to force R to require doParallel for cv.glmnet to use it properly.

There's also a good hint I can give about doParallel package. I made extensive testing for that package and I found out that hyper-threading is also useful but you have to register total cores (virtual+real)-1 for the max performance. I suppose one core is dedicated to other tasks.

So, in the example code above, if you have a quad-core processor without hyper-threading you use;

library(doParallel)
library(glmnet)
data...
x...
y...
poss...
require(doParallel)
registerDoParallel("max cores [virtual+real] - 1) and immediately after that
fit <- cv.glmnet

to make it simpler;

For quad-core processor with hyper-threading;

require(doParallel)
registerDoParallel(7)
cv.glmnet

For dual core processor with hyper-threading;

require(doParallel)
registerDoParallel(3)
cv.glmnet

For quad core processor without hyperthreading;

require(doParallel)
registerDoParallel(3)
cv.glmnet

There should be nothing between these 3 lines of code.

Edit:

Also I don't think weight function requires a matrix. Just using file$poss should be sufficient. It was always sufficient for me.

As for the guide, when I have enough time I'll read it again and point out the errors in that article because I tried to learn how to calculate APM or RAPM by reading that article first and eventually found out the problems.

Re: Setting Up Excel File for RAPM

Posted: Mon Aug 08, 2016 7:50 pm
by KwameBeanJordan
permaximum wrote:It's been a very long time but If I remember correct, you're doing it wrong. You should suppose to use one formula to find the best lambda and player coefficients according to that. It should be like;

file = read.table "("c:\.......\file.csv", sep=";" , header="TRUE")
x = as.matrix(file[c('P1","P2",P3"....."P-LAST")]) or x = data.matrix(file[1:length(file)-2])
y = as.matrix(file[c("Margin")])
Poss = file$Poss
mystic wrote: Your code would then look like this:

Code: Select all

library(doParallel)
registerDoParallel(x)
library(glmnet)
data<-read.csv(" ... ")
Marg<-data$Margin
Poss<-data$Poss
Marg<-data.matrix(Marg)
Poss<-data.matrix(Poss)
data$Margin=NULL
data$Poss=NULL
x<-data.matrix(data)
lambda<-cv.glmnet(x, Marg, Poss, nfolds=10, alpha=0, standardize=FALSE, parallel=TRUE)
lambda.min<-lambda$lambda.min
ridge<-glmnet(x, Marg, Poss, alpha=0, standardize=FALSE, lambda=lambda.min)
coef(ridge, s=lambda.min)
I reran the regression according to both your corrections and got a much higher lambda at around 2.7. The results also seem more reasonable:

Code: Select all

Name	RAPM
Paul, Chris	5.275976983
Odom, Lamar	5.073821655
James, LeBron	5.033201553
Allen, Ray	4.22423023
Bonner, Matt	3.972326084
Kidd, Jason	3.932779143
Iguodala, Andre	3.696990518
Garnett, Kevin	3.561093178
Ming, Yao	3.529510141
Hilario, Nene	3.515124457
Wade, Dwayne	3.365774096
Murray, Ronald (Flip)	3.329632878
Anthony, Carmelo	3.071744865
Johnson, Joe	2.969285615
Hinrich, Kirk	2.887989465
Rondo, Rajon	2.714367802
Nelson, Jameer	2.624768933
Foster, Jeff	2.568814393
Wallace, Ben	2.471004136
Hill, Grant	2.401869087
Roy, Brandon	2.391516242
Pierce, Paul	2.391005649
West, Delonte	2.370528114
Hayes, Jarvis	2.347129758
Telfair, Sebastian	2.329014937
Redd, Michael	2.257762059
Parker, Anthony	2.240588375
Bryant, Kobe	2.229271282
Gasol, Pau	2.194691253
Magloire, Jamaal	2.166087476
Wallace, Gerald	2.158449102
Granger, Danny	1.993742507
Millsap, Paul	1.983146564
Aldridge, LaMarcus	1.971000011
Chandler, Tyson	1.956286447
Bosh, Chris	1.943638828
Bell, Charlie	1.883009011
Moon, Jamario	1.871993344
Young, Thaddeus	1.867106036
Udoka, Ime	1.827949931
Battier, Shane	1.82444409
Jones, James	1.798260477
Andersen, Chris	1.783504172
Kirilenko, Andrei	1.764822627
Ilgauskas, Zydrunas	1.710890419
Blake, Steve	1.707167703
Douglas-Roberts, Chris	1.697365387
Wallace, Rasheed	1.690916406
Lewis, Rashard	1.659451318
Jaric, Marko	1.629804092
Walton, Luke	1.607110383
Varejao, Anderson	1.545474372
Turiaf, Ronny	1.530345001
Collins, Mardy	1.516962023
Singleton, James	1.50026132
Stoudemire, Amare	1.492465883
Bogut, Andrew	1.450861658
Powe, Leon	1.442351925
Bynum, Will	1.439000446
Artest, Ron	1.432279862
Batum, Nicolas	1.418330937
Turkoglu, Hedo	1.387162797
Billups, Chauncey	1.381252875
Johnson, Amir	1.376134035
Bass, Brandon	1.344842504
Afflalo, Arron	1.317384578
Davis, Baron	1.293230773
Okafor, Emeka	1.287578274
Howard, Dwight	1.287320385
Jefferson, Al	1.28268736
Przybilla, Joel	1.278384174
Foye, Randy	1.250741946
Anderson, Ryan	1.243877471
Oden, Greg	1.237565231
Najera, Eduardo	1.23477749
Finley, Michael	1.181743184
Cardinal, Brian	1.175177271
Fisher, Derek	1.167544682
Hollins, Ryan	1.159909399
West, David	1.132034632
Nesterovic, Rasho	1.119797989
Wafer, Von	1.113874138
Nocioni, Andres	1.056517471
Brown, Kwame	1.044601553
Smith, J.R.	1.04054892
Mason, Roger	0.996415958
O'Neal, Shaquille	0.990799924
Smith, Josh	0.979703632
Songaila, Darius	0.964335537
Mbah a Moute, Luc	0.957187703
Williams, Deron	0.95093138
Herrmann, Walter	0.940769797
Robinson, Nate	0.894317924
Price, Ronnie	0.868263082
Amundson, Louis	0.862052259
Milicic, Darko	0.858577739
Stojakovic, Peja	0.8519609
Barnes, Matt	0.807415866
Okur, Mehmet	0.805244744
Brown, Devin	0.742266693
Williams, Mo	0.716075527
Gibson, Daniel	0.713549726
Ford, T.J.	0.69190453
Allen, Tony	0.686010357
Korver, Kyle	0.656476948
Noah, Joakim	0.643649799
Blatche, Andray	0.641997116
McDyess, Antonio	0.613042511
Weaver, Kyle	0.606193284
Felton, Raymond	0.604161355
Young, Nick	0.538051341
Jack, Jarrett	0.534309192
Radmanovic, Vladimir	0.519180092
Scola, Luis	0.517841212
Scalabrine, Brian	0.5095269
Lopez, Brook	0.496325181
Knight, Brevin	0.496224338
Sessions, Ramon	0.488703529
Thompson, Jason	0.478720734
Carter, Vince	0.466964216
Thomas, Tim	0.456963209
Fernandez, Rudy	0.451576201
Nowitzki, Dirk	0.446743053
Buckner, Greg	0.446052772
Parker, Tony	0.443926994
Randolph, Zach	0.442390193
Graham, Stephen	0.433787934
Duncan, Tim	0.386465826
Battie, Tony	0.384118884
Harpring, Matt	0.342518235
Evans, Maurice	0.340952569
Morrow, Anthony	0.32276373
Blount, Mark	0.320502338
Dudley, Jared	0.307074934
Balkman, Renaldo	0.305764052
Brewer, Corey	0.281691919
House, Eddie	0.276283147
Martin, Kenyon	0.272946508
Gordon, Ben	0.263555665
Brooks, Aaron	0.247821088
Dalembert, Samuel	0.243441333
Davis, Glen	0.24269767
Stuckey, Rodney	0.234925458
Wright, Brandan	0.230161929
Lue, Tyronn	0.226866347
Marion, Shawn	0.224015996
Williams, Sean	0.218287607
Carter, Anthony	0.213940519
Hibbert, Roy	0.153045946
Udrih, Beno	0.149706161
Lee, David	0.149151609
Harrington, Al	0.14688585
Perkins, Kendrick	0.131813326
Szczerbiak, Wally	0.115070026
Ollie, Kevin	0.11500807
Richardson, Quentin	0.098984759
Posey, James	0.098722849
Jeffries, Jared	0.09781343
Allen, Malik	0.0569847
McGrady, Tracy	0.055930068
Pavlovic, Sasha	0.052746734
Ely, Melvin	0.049379609
Rush, Kareem	0.049160779
Jackson, Stephen	0.04859115
Dragic, Goran	0.040587247
Alexander, Joe	0.027850415
Deng, Luol	0.02759031
Haywood, Brendan	0.013559506
Hill, George	0.004829527
Williams, Shelden	-0.00478377
Graham, Joey	-0.033031048
Bynum, Andrew	-0.033141984
Maggette, Corey	-0.038914141
Humphries, Kris	-0.043973621
Redick, J.J.	-0.049499722
Conley, Mike	-0.062614073
Ellis, Monta	-0.071705287
Randolph, Anthony	-0.116716356
Dampier, Erick	-0.119535565
Ross, Quinton	-0.121565233
Simmons, Bobby	-0.125904667
Wright, Julian	-0.139099933
Mason, Desmond	-0.141206662
Pachulia, Zaza	-0.167846679
Webster, Martell	-0.204418461
Lee, Courtney	-0.208134794
Douby, Quincy	-0.208491068
Quinn, Chris	-0.242888034
Horford, Al	-0.248262617
Miller, Andre	-0.249135516
Wright, Antoine	-0.250230831
Gray, Aaron	-0.256026221
Augustin, D.J.	-0.2593994
Green, Willie	-0.276622522
Ratliff, Theo	-0.303313009
Boone, Josh	-0.304763229
Nash, Steve	-0.305915391
Vujacic, Sasha	-0.313366131
Rose, Malik	-0.314240322
Calderon, Jose	-0.320238712
Harris, Devin	-0.327493815
Thomas, Kurt	-0.33293073
Law, Acie	-0.338318798
Westbrook, Russell	-0.34377885
Terry, Jason	-0.349776836
Barea, Jose	-0.359838724
Ginobili, Manu	-0.360178163
Peterson, Morris	-0.36431216
Prince, Tayshaun	-0.366808602
Bell, Raja	-0.385058137
Williams, Marvin	-0.386566308
Jackson, Bobby	-0.404318021
Bogans, Keith	-0.412316304
Watson, C.J.	-0.426078778
Brewer, Ronnie	-0.468610677
Cook, Daequan	-0.482972089
Warrick, Hakim	-0.514665641
Moore, Mikki	-0.52281451
Duhon, Chris	-0.52544872
Diaw, Boris	-0.528079594
Miles, C.J.	-0.543358691
Carney, Rodney	-0.544250493
Arthur, Darrell	-0.579646463
Azubuike, Kelenna	-0.592277511
Lopez, Robin	-0.610144241
Haslem, Udonis	-0.61142441
Belinelli, Marco	-0.613696258
Brand, Elton	-0.627559621
Butler, Caron	-0.628257422
Oberto, Fabricio	-0.642247098
Jamison, Antawn	-0.661603328
Ukic, Roko	-0.667015867
Jianlian, Yi	-0.672854509
Beasley, Michael	-0.69699721
Atkins, Chucky	-0.698684075
Evans, Reggie	-0.706939723
Johnson, Anthony	-0.709769759
Villanueva, Charlie	-0.711599498
Krstic, Nenad	-0.716381829
Stevenson, DeShawn	-0.727729724
Maxiell, Jason	-0.738812975
Chalmers, Mario	-0.740755031
Smith, Joe	-0.790774786
Elson, Francisco	-0.793874384
Mobley, Cuttino	-0.799388915
Collison, Nick	-0.799807903
Taylor, Mike	-0.826360485
Diop, DeSagana	-0.882134414
Howard, Josh	-0.884099476
Gay, Rudy	-0.922790263
Koufos, Kosta	-0.924837564
O'Neal, Jermaine	-0.930617091
Landry, Carl	-0.940623157
Brown, Shannon	-0.979825745
Gasol, Marc	-1.019754007
Love, Kevin	-1.036138134
Crittenton, Javaris	-1.036443549
Outlaw, Travis	-1.03646695
Kapono, Jason	-1.049963861
Diawara, Yakhouba	-1.059521492
Ariza, Trevor	-1.061220129
Jefferson, Richard	-1.062829882
Watson, Earl	-1.070543452
Diener, Travis	-1.080322561
Hassell, Trenton	-1.090462199
Dixon, Juan	-1.090532085
Mayo, O.J.	-1.104138695
Rose, Derrick	-1.104671384
Sefolosha, Thabo	-1.108579159
Biedrins, Andris	-1.108973856
Murphy, Troy	-1.124723811
Boozer, Carlos	-1.14217288
Speights, Marreese	-1.142897543
Farmar, Jordan	-1.145672265
Stackhouse, Jerry	-1.148975323
Kaman, Chris	-1.156625382
Marbury, Stephon	-1.174525421
Jones, Fred	-1.234787885
Bibby, Mike	-1.242708328
Miller, Mike	-1.258231256
Armstrong, Hilton	-1.263850263
Alston, Rafer	-1.265370262
Barbosa, Leandro	-1.278132019
McGuire, Dominic	-1.321570286
Gomes, Ryan	-1.327877452
Bowen, Bruce	-1.33160371
Green, Jeff	-1.331991087
Marks, Sean	-1.335314879
Hamilton, Richard	-1.345865777
Ridnour, Luke	-1.378356551
Pietrus, Mickael	-1.385391149
Barry, Brent	-1.424404057
Smith, Craig	-1.443554974
Solomon, Willie	-1.453419488
Daniels, Marquis	-1.456946439
Hughes, Larry	-1.496320479
Vaughn, Jacque	-1.507981611
Hayes, Chuck	-1.512215992
Rodriguez, Sergio	-1.522115559
Wilcox, Chris	-1.526107205
Chandler, Wilson	-1.555176517
Williams, Louis	-1.560962428
Jones, Solomon	-1.562426491
Green, Gerald	-1.572902536
Martin, Kevin	-1.591578108
Kleiza, Linas	-1.595776271
Howard, Juwan	-1.600168048
Gortat, Marcin	-1.619098034
Wilkins, Damien	-1.632988167
Lowry, Kyle	-1.714934575
Brown, Bobby	-1.715025888
Crawford, Jamal	-1.724582489
Gordon, Eric	-1.734612668
Camby, Marcus	-1.735346744
Novak, Steve	-1.749993291
Thomas, Tyrus	-1.767915402
Gooden, Drew	-1.800687707
McCants, Rashad	-1.847115485
Miller, Brad	-1.860979738
Gadzuric, Dan	-1.892600491
Mohammed, Nazr	-1.895789589
Bargnani, Andrea	-1.980003655
Anthony, Joel	-1.980849979
George, Devean	-1.999876814
Greene, Donte	-2.011720614
Skinner, Brian	-2.046345167
Bayless, Jerryd	-2.060636597
Iverson, Allen	-2.083023579
Petro, Johan	-2.100134567
Jordan, DeAndre	-2.1998268
Hickson, J.J.	-2.21897812
Jones, Dahntay	-2.226486951
Head, Luther	-2.28290574
Dooling, Keyon	-2.290185205
James, Mike	-2.401409877
Ivey, Royal	-2.452191407
Carroll, Matt	-2.467546486
Morrison, Adam	-2.468357115
Collins, Jason	-2.476127616
Richardson, Jason	-2.648870287
Davis, Ricky	-2.669782367
McGee, JaVale	-2.672761838
Hart, Jason	-2.832065911
Thornton, Al	-2.894184192
Powell, Josh	-2.923248006
Salmons, John	-3.005391596
Butler, Rasual	-3.039080422
Garcia, Francisco	-3.062098654
Frye, Channing	-3.14303404
Durant, Kevin	-3.184643102
Dunleavy, Mike	-3.563088325
Hawes, Spencer	-3.599075828
Rush, Brandon	-3.615298414
Daniels, Antonio	-3.891440723


Re: Setting Up Excel File for RAPM

Posted: Tue Aug 09, 2016 12:26 am
by KwameBeanJordan
permaximum wrote:As for the guide, when I have enough time I'll read it again and point out the errors in that article because I tried to learn how to calculate APM or RAPM by reading that article first and eventually found out the problems.
I think your right. Eli's guide uses the formula
=IF(ISNUMBER(FIND(AY$1&",",$AV2)),1,IF(ISNUMBER(FIND(AY$1&",",$AW2)),-1,0))
to determine the entries of the matrix. The problem is it will count the player with ID "8" as on the court if the player with ID "258" (or any other ID ending in "8") is on the court as can be seen in the first row once you set up the 2009 regular season matrix.

I've tried fixing this by changing it to
=IF(ISNUMBER(FIND("P"&AY$1&",",$AV2)),1,IF(ISNUMBER(FIND("P"&AY$1&",",$AW2)),-1,0))
since each player ID begins with a "P" in the cell that it searches and I believe it has worked.

Re: Setting Up Excel File for RAPM

Posted: Tue Aug 09, 2016 2:06 pm
by permaximum
The new RAPM values look reasonable. I've checked it with several other 2009 RAPM tables from other sources it's quite different but that's expected. Everyone finds somewhat similar but different RAPM values for a variety of reasons. Errors in PBP data, doing mistakes while trying to get it ready for the regression, errors at calculation stage, different lambdas and different solving methods (using different programming langues, different packages, libraries etc.) and all will lead to different results.

That's why it's crucial to share the source PBP dataset, the regression-ready data and coding steps to reproduce the results. Unfortunately none shares that. They just publish the results and update them time to time and that's it. That's why I think PER and WS have been very popular while other metrics and APM variants never gained popularity. Therefore, most don't trust these metrics.

Re: Setting Up Excel File for RAPM

Posted: Tue Aug 09, 2016 11:52 pm
by xkonk
permaximum wrote:That's why it's crucial to share the source PBP dataset, the regression-ready data and coding steps to reproduce the results. Unfortunately none shares that. They just publish the results and update them time to time and that's it.
I just want to second this thought along the lines that one of my main complaints with the forum in general is the lack of detail when people present results. Even when people describe what method or data set they used, it is rarely with enough information to verify or follow up on anything. I can understand that from the perspective of perhaps trying to get a team's attention and keeping your sweet new info proprietary, but there's certainly no reason for it to be so difficult for someone to calculate APM or RAPM at this point. There's a recent, very long thread on Win Shares for crying out loud. I hope that more explicit guidance and methods like this keep appearing.
permaximum wrote:... it's quite different but that's expected. Everyone finds somewhat similar but different RAPM values for a variety of reasons. Errors in PBP data, doing mistakes while trying to get it ready for the regression, errors at calculation stage, different lambdas and different solving methods (using different programming langues, different packages, libraries etc.) and all will lead to different results.
Could you be a little more clear about how different is "quite different"? Your list of reasons seem valid to me, but barring some fairly large differences in PBP cleaning one would hope that the rest don't lead to anything too drastic.

Re: Setting Up Excel File for RAPM

Posted: Wed Aug 10, 2016 9:40 am
by KwameBeanJordan
xkonk wrote:Could you be a little more clear about how different is "quite different"? Your list of reasons seem valid to me, but barring some fairly large differences in PBP cleaning one would hope that the rest don't lead to anything too drastic.
I could perhaps shed some light on the difference:

(1) My second run of the regression was for RS only while I believe many compute RAPM with both RS and PS data.
(2) There was an error in the setup of the matrix. It resulted in certain players (those w/ single- or two-digit IDs) being sometimes counted as on the floor when they weren't.
(3) I've tested various values for the number of folds, and though the choice of folds hasn't produced wild differences in the actual values, it can certainly rearrange the top 10.

So, I reconstructed the matrix correctly and reran the regression for a third time. I never got around to posting my third set of results, since I have been pretty busy, but I can give a brief overview. In the new results Lebron and Odom separated themselves from the rest, both at around a +7. Everyone else was not much more than a +5. Rashard Lewis jumped into the top 8 while Dwayne Wade and Kobe ranked better. Common to both my second and third runs of the regression, so not a change, is that Tim Duncan ranked poorly and not much higher than a +0.

Re: Setting Up Excel File for RAPM

Posted: Fri Aug 19, 2016 10:15 pm
by permaximum
Well, this standardize=FALSE thing made me go back to this stuff and today I had free time to start over again. I calculated 2009 RAPM from the same source and I can confirm there hasn't been a single mistake or error in the process. But I can't confirm if there are any errors in the source data from basketballvalue.com.

Code: Select all

R: 3.3.1
glmnet: 2.0.5
CV-method: 10-fold cross-validation
Lambda: 0.68
Logged RAPM value variance between lambdas 0.6 to 0.7 = +- 0.3
Edit: The result is actually generated from just a normal 10-fold cross validation because R didn't assign a new seed for each iteration in the for loop. So the CV-method is not 10-times repeated 10-fold cross validation. I corrected the CV-method that's mentioned above. For more detail and the new RAPM results check: viewtopic.php?f=2&t=9193&p=29935#p29935

Used R-Code:

Code: Select all

library(doParallel)
library(glmnet)
rapm <- read.table("c:/users/hidden/downloads/rapm2009.csv", sep=";", header=TRUE)
x <- as.matrix(rapm[c(-1,-2)])
y <- as.matrix(rapm[c("Rtg")])
lambdas = NULL
require(doParallel)
registerDoParallel(7)
for (i in 1:10)
{
    fit <- cv.glmnet(x,y,alpha=0,weights=rapm$Poss,nfolds=10,parallel=TRUE,standardize=FALSE,lambda=seq(0.6, 0.7, by=0.001))
    errors = data.frame(fit$lambda,fit$cvm)
    lambdas <- rbind(lambdas,errors)
}
lambdas <- aggregate(lambdas[, 2], list(lambdas$fit.lambda), mean)
bestindex = which(lambdas[2]==min(lambdas[2]))
bestlambda = lambdas[bestindex,1]
fit <- glmnet(x,y,alpha=0,weights=rapm$Poss,standardize=FALSE,lambda=bestlambda)
coef(fit)
RAPM results

Code: Select all

          PLAYER           ORAPM   DRAPM   RAPM   
 ------------------------ ------- ------- ------- 
  Odom, Lamar               3.88    3.11    6.99  
  James, LeBron             4.13    2.75    6.88  
  Paul, Chris               3.58    1.98    5.56  
  Ming, Yao                 1.95    2.94    4.90  
  Wade, Dwayne              3.87    0.98    4.85  
  Hinrich, Kirk             2.17    2.51    4.68  
  Lewis, Rashard            2.70    1.92    4.63  
  Garnett, Kevin            0.88    3.64    4.52  
  Bonner, Matt              2.15    2.23    4.38  
  Allen, Ray                2.55    1.82    4.38  
  Kidd, Jason               2.05    2.23    4.28  
  Smith, J.R.               2.50    1.42    3.92  
  Wallace, Ben              1.44    2.37    3.81  
  Nash, Steve               4.36   -0.62    3.73  
  Nelson, Jameer            2.25    1.47    3.73  
  Murray, Ronald (Flip)     1.91    1.74    3.65  
  Bryant, Kobe              3.29    0.31    3.61  
  West, Delonte             1.13    2.40    3.53  
  Granger, Danny            3.74   -0.31    3.43  
  Kirilenko, Andrei         1.24    2.14    3.38  
  Howard, Dwight            1.61    1.64    3.25  
  Turkoglu, Hedo            1.03    2.20    3.23  
  Hill, Grant               2.29    0.86    3.14  
  Aldridge, LaMarcus        2.87    0.26    3.14  
  Parker, Tony              2.79    0.33    3.12  
  Millsap, Paul             1.23    1.88    3.11  
  Hilario, Nene             1.97    1.11    3.08  
  Roy, Brandon              3.06   -0.03    3.03  
  Anthony, Carmelo          2.87    0.11    2.98  
  Iguodala, Andre           1.38    1.57    2.96  
  Artest, Ron               0.56    2.39    2.95  
  Jaric, Marko              0.01    2.92    2.94  
  Wallace, Rasheed          1.74    1.17    2.91  
  Blake, Steve              2.68    0.15    2.84  
  Smith, Josh               1.76    1.08    2.84  
  Rondo, Rajon              1.83    0.99    2.82  
  Noah, Joakim              1.74    1.03    2.77  
  Young, Thaddeus           0.55    2.04    2.59  
  Foster, Jeff              0.53    2.03    2.57  
  Howard, Josh              1.64    0.92    2.56  
  Moon, Jamario             0.86    1.69    2.55  
  Stojakovic, Peja          2.98   -0.44    2.53  
  Gasol, Pau                2.68   -0.16    2.52  
  Przybilla, Joel          -0.82    3.33    2.51  
  Bogut, Andrew            -1.05    3.55    2.50  
  Powe, Leon                0.83    1.63    2.46  
  Udoka, Ime                0.19    2.27    2.46  
  Johnson, Amir            -0.17    2.62    2.45  
  Bosh, Chris               2.59   -0.21    2.39  
  Nocioni, Andres           3.14   -0.77    2.37  
  Ilgauskas, Zydrunas       1.04    1.26    2.30  
  Pierce, Paul              1.09    1.17    2.27  
  Redd, Michael             3.24   -1.01    2.23  
  Johnson, Joe              2.35   -0.13    2.22  
  Fernandez, Rudy           1.27    0.82    2.09  
  Thomas, Tim               0.14    1.90    2.04  
  Wallace, Gerald           0.05    1.99    2.04  
  Telfair, Sebastian        2.42   -0.37    2.04  
  Fisher, Derek             1.56    0.48    2.03  
  Battier, Shane            0.57    1.44    2.01  
  Haddadi, Hamed            0.52    1.47    1.99  
  Harrington, Al            1.38    0.58    1.96  
  Parker, Anthony           0.66    1.29    1.95  
  Batum, Nicolas            2.19   -0.24    1.95  
  Wafer, Von                1.78    0.13    1.91  
  Chandler, Tyson           1.13    0.72    1.85  
  Martin, Kenyon            0.05    1.80    1.85  
  Hayes, Jarvis            -0.12    1.98    1.85  
  Varejao, Anderson         1.03    0.80    1.83  
  Jefferson, Al             1.22    0.58    1.79  
  West, David               1.56    0.20    1.76  
  Nowitzki, Dirk            2.04   -0.33    1.71  
  Gallinari, Danilo         1.22    0.45    1.67  
  Cardinal, Brian           1.59    0.08    1.67  
  Williams, Mo              1.23    0.41    1.64  
  Marshall, Donyell         1.76   -0.15    1.61  
  Turiaf, Ronny             2.31   -0.72    1.59  
  Okur, Mehmet              1.98   -0.41    1.57  
  Mason, Desmond            0.09    1.47    1.56  
  Gordon, Ben               2.02   -0.49    1.53  
  Oden, Greg                2.16   -0.65    1.51  
  Mason, Roger              1.09    0.40    1.49  
  Weaver, Kyle              0.67    0.80    1.47  
  Hollins, Ryan             0.12    1.36    1.47  
  Camby, Marcus            -1.45    2.89    1.44  
  Simmons, Bobby            1.53   -0.10    1.42  
  Magloire, Jamaal          0.86    0.55    1.42  
  Robinson, Nate            1.60   -0.19    1.41  
  Collins, Mardy            0.18    1.21    1.40  
  Billups, Chauncey         3.11   -1.73    1.38  
  Duncan, Tim               0.69    0.61    1.30  
  Thomas, Kurt             -0.39    1.68    1.28  
  Douglas-Roberts, Chris    0.62    0.61    1.23  
  Bynum, Will               1.27   -0.04    1.23  
  Martin, Cartier           1.01    0.21    1.22  
  Sessions, Ramon           1.41   -0.19    1.22  
  Pachulia, Zaza           -0.37    1.52    1.16  
  Williams, Deron           2.59   -1.44    1.14  
  Brown, Kwame             -0.15    1.28    1.13  
  Lee, Courtney             0.87    0.18    1.05  
  Scalabrine, Brian         0.30    0.76    1.05  
  Bynum, Andrew            -0.21    1.20    0.98  
  Scola, Luis               0.27    0.70    0.98  
  Randolph, Zach            0.56    0.40    0.96  
  Bass, Brandon             1.62   -0.67    0.95  
  House, Eddie              1.10   -0.18    0.92  
  Okafor, Emeka            -0.13    1.02    0.90  
  Foye, Randy               2.39   -1.50    0.89  
  Hamilton, Richard         0.02    0.86    0.88  
  Gibson, Daniel            0.58    0.29    0.88  
  Anderson, Ryan            0.07    0.80    0.86  
  Walton, Luke             -0.27    1.10    0.83  
  Mbah a Moute, Luc        -1.00    1.81    0.81  
  Young, Nick              -0.43    1.22    0.79  
  Songaila, Darius         -0.34    1.13    0.78  
  Miller, Brad              1.25   -0.47    0.77  
  Terry, Jason              1.21   -0.43    0.77  
  Westbrook, Russell        0.02    0.75    0.77  
  Blount, Mark              0.39    0.36    0.75  
  Thompson, Jason           0.29    0.46    0.75  
  Jack, Jarrett             1.03   -0.29    0.74  
  Blatche, Andray          -0.56    1.29    0.74  
  O'Neal, Shaquille         2.50   -1.80    0.70  
  Acker, Alex               0.36    0.32    0.68  
  Jones, James              0.49    0.17    0.66  
  Harpring, Matt           -0.53    1.16    0.64  
  Amundson, Louis           0.17    0.46    0.63  
  Mensah-Bonsu, Pops       -0.34    0.96    0.63  
  Deng, Luol               -0.79    1.41    0.61  
  Brewer, Corey            -0.38    0.99    0.61  
  Afflalo, Arron            0.69   -0.08    0.60  
  Diaw, Boris               0.22    0.37    0.59  
  Ajinca, Alexis           -0.22    0.78    0.56  
  Battie, Tony             -0.67    1.20    0.53  
  Williams, Shawne         -0.61    1.12    0.52  
  Voskuhl, Jake             0.33    0.15    0.48  
  Hunter, Othello          -0.09    0.57    0.48  
  Miller, Andre             0.72   -0.25    0.47  
  Ariza, Trevor            -0.02    0.48    0.46  
  Ross, Quinton            -1.36    1.80    0.44  
  Carter, Vince             2.43   -2.00    0.44  
  Harris, Devin             1.54   -1.11    0.43  
  Daniels, Marquis         -0.69    1.11    0.42  
  Nichols, Demetris         0.03    0.39    0.42  
  Dalembert, Samuel        -0.44    0.85    0.41  
  Murphy, Troy              2.19   -1.78    0.40  
  Knight, Brevin           -2.64    3.03    0.39  
  Arenas, Gilbert           0.36    0.03    0.39  
  Jackson, Bobby            0.70   -0.31    0.39  
  Fesenko, Kyrylo           0.50   -0.12    0.38  
  Crawford, Joe            -0.08    0.44    0.35  
  Allen, Tony              -1.81    2.16    0.35  
  Allen, Malik             -0.39    0.73    0.34  
  Hill, George             -0.38    0.72    0.34  
  Tucker, Alando            0.60   -0.26    0.34  
  Stoudemire, Amare        -0.95    1.28    0.34  
  Singleton, James         -0.70    1.03    0.33  
  Morris, Randolph          0.37   -0.04    0.33  
  Williams, Shelden        -0.29    0.60    0.32  
  Horford, Al               0.00    0.32    0.32  
  Wright, Antoine           1.89   -1.58    0.30  
  Jones, Dwayne             0.04    0.26    0.30  
  Posey, James              0.03    0.27    0.30  
  Dudley, Jared             0.83   -0.54    0.29  
  Gardner, Thomas          -0.94    1.22    0.28  
  Buckner, Greg            -0.18    0.45    0.27  
  Jackson, Stephen          1.41   -1.15    0.26  
  Humphries, Kris           0.44   -0.18    0.26  
  Bell, Raja                0.09    0.15    0.24  
  Jones, Damon              0.63   -0.40    0.23  
  Felton, Raymond          -0.52    0.75    0.23  
  Farmer, Desmon            0.40   -0.18    0.22  
  Richardson, Quentin       0.36   -0.15    0.21  
  Brown, Devin             -1.28    1.49    0.21  
  Chalmers, Mario           0.01    0.19    0.20  
  Rose, Malik              -0.40    0.60    0.20  
  Hill, Steven              0.03    0.16    0.19  
  Milicic, Darko           -0.80    1.00    0.19  
  Madsen, Mark             -0.43    0.62    0.18  
  Wright, Julian           -1.04    1.22    0.18  
  Morrow, Anthony           1.92   -1.75    0.18  
  Barnes, Matt              1.72   -1.54    0.18  
  Ahearn, Blake            -0.18    0.36    0.18  
  Samb, Cheikh             -0.40    0.56    0.17  
  Sene, Mouhamed            0.08    0.08    0.16  
  Wright, Brandan           0.23   -0.08    0.15  
  Graham, Stephen          -0.82    0.95    0.13  
  Korver, Kyle             -0.01    0.13    0.12  
  White, D.J.               0.42   -0.30    0.12  
  Williams, Jawad          -0.08    0.19    0.11  
  Udrih, Beno               0.30   -0.19    0.11  
  Villanueva, Charlie       1.33   -1.23    0.10  
  Haywood, Brendan         -0.13    0.22    0.09  
  Herrmann, Walter          0.15   -0.08    0.07  
  Andersen, Chris           0.17   -0.11    0.07  
  Lopez, Brook              0.13   -0.06    0.06  
  Williams, Marcus         -0.12    0.18    0.06  
  Marion, Shawn            -0.44    0.50    0.06  
  James, Jerome             0.00    0.04    0.04  
  Bogans, Keith             0.42   -0.40    0.02  
  Giddens, J.R.            -0.15    0.16    0.01  
  Ginobili, Manu            0.91   -0.90    0.01  
  Sims, Courtney           -0.12    0.12    0.00  
  Hibbert, Roy             -0.92    0.91   -0.01  
  Augustin, D.J.            0.43   -0.45   -0.01  
  Belinelli, Marco         -0.55    0.53   -0.02  
  Redick, J.J.              0.26   -0.30   -0.04  
  Thomas, Kenny            -0.13    0.09   -0.04  
  Peterson, Morris         -0.14    0.08   -0.05  
  Gadzuric, Dan             0.80   -0.86   -0.06  
  Williams, MarcusE         0.14   -0.20   -0.06  
  Brown, Dee               -0.09    0.03   -0.06  
  Collison, Nick           -0.84    0.78   -0.06  
  Duhon, Chris              0.33   -0.40   -0.07  
  Ruffin, Michael           0.03   -0.11   -0.08  
  Brooks, Aaron             1.17   -1.25   -0.08  
  Miles, C.J.               0.83   -0.92   -0.09  
  Stuckey, Rodney          -0.12    0.02   -0.10  
  Swift, Stromile          -0.78    0.68   -0.10  
  Diener, Travis            0.80   -0.92   -0.12  
  Boone, Josh               0.55   -0.67   -0.12  
  Pietrus, Mickael         -0.16    0.04   -0.13  
  Balkman, Renaldo         -0.60    0.47   -0.13  
  Conley, Mike             -0.88    0.75   -0.13  
  Azubuike, Kelenna        -0.38    0.24   -0.14  
  O'Bryant, Patrick        -1.61    1.47   -0.14  
  Davidson, Jermareo       -1.00    0.86   -0.15  
  Dorsey, Joey             -0.09   -0.06   -0.15  
  McRoberts, Josh          -0.12   -0.03   -0.15  
  Wright, Lorenzen         -0.61    0.46   -0.15  
  Mutombo, Dikembe          0.11   -0.26   -0.15  
  Krstic, Nenad            -0.98    0.82   -0.16  
  Hairston, Malik          -0.82    0.66   -0.16  
  Warrick, Hakim           -0.51    0.31   -0.20  
  Perkins, Kendrick         0.00   -0.20   -0.20  
  Jefferson, Dontell       -0.54    0.34   -0.20  
  Foyle, Adonal            -0.44    0.24   -0.20  
  Smith, Joe               -0.81    0.59   -0.21  
  Szczerbiak, Wally        -0.08   -0.16   -0.23  
  Claxton, Speedy          -0.12   -0.12   -0.24  
  McGrady, Tracy           -0.33    0.08   -0.25  
  McDyess, Antonio          1.22   -1.47   -0.25  
  Tolliver, Anthony        -0.43    0.17   -0.26  
  Webster, Martell         -0.03   -0.23   -0.26  
  Sharpe, Walter           -0.24   -0.02   -0.26  
  Jawai, Nathan            -0.27    0.00   -0.28  
  Brewer, Ronnie            0.30   -0.58   -0.28  
  Radmanovic, Vladimir      0.26   -0.55   -0.29  
  White, James             -0.27   -0.03   -0.29  
  Pruitt, Gabe             -1.57    1.25   -0.33  
  Brown, Shannon           -0.25   -0.08   -0.33  
  Jeffries, Jared          -0.80    0.46   -0.33  
  Curry, Eddy              -0.26   -0.09   -0.35  
  Outlaw, Travis            0.40   -0.75   -0.35  
  Baston, Maceo            -0.84    0.48   -0.35  
  Ford, T.J.               -0.07   -0.29   -0.36  
  Ager, Maurice            -0.75    0.39   -0.36  
  Williams, Sean            0.12   -0.49   -0.38  
  Barea, Jose              -0.09   -0.29   -0.38  
  Rush, Kareem              0.05   -0.44   -0.39  
  Cook, Daequan             0.68   -1.07   -0.39  
  Johnson, Trey            -0.25   -0.14   -0.40  
  Lee, David                1.38   -1.79   -0.41  
  Prince, Tayshaun          0.78   -1.19   -0.41  
  Pavlovic, Sasha           0.00   -0.43   -0.43  
  Brown, Andre             -0.34   -0.09   -0.44  
  Ratliff, Theo             0.72   -1.17   -0.44  
  Gray, Aaron              -1.07    0.63   -0.45  
  Quinn, Chris              0.36   -0.81   -0.45  
  Davis, Paul              -0.84    0.39   -0.46  
  Barbosa, Leandro          0.64   -1.10   -0.46  
  Watson, C.J.              0.79   -1.25   -0.46  
  Wright, Dorell           -0.92    0.46   -0.46  
  Law, Acie                -1.45    0.99   -0.47  
  Green, Willie            -0.04   -0.44   -0.48  
  Graham, Joey             -0.97    0.49   -0.48  
  Davis, Glen               0.56   -1.05   -0.49  
  Dragic, Goran             0.31   -0.81   -0.49  
  Finley, Michael           1.25   -1.75   -0.50  
  Johnson, Anthony         -0.86    0.36   -0.50  
  Mbenga, DJ               -0.96    0.46   -0.50  
  Ellis, Monta              0.16   -0.67   -0.51  
  Haslem, Udonis           -0.77    0.24   -0.52  
  Mobley, Cuttino          -0.35   -0.17   -0.52  
  Adams, Hassan            -0.27   -0.27   -0.54  
  Evans, Reggie             0.11   -0.65   -0.54  
  Douby, Quincy            -0.25   -0.30   -0.54  
  Elson, Francisco          0.07   -0.63   -0.56  
  Simmons, Cedric          -0.32   -0.24   -0.56  
  Lue, Tyronn              -1.60    1.04   -0.56  
  Jones, Fred               0.93   -1.49   -0.57  
  Bibby, Mike               0.80   -1.37   -0.57  
  Rose, Derrick             1.09   -1.66   -0.57  
  Randolph, Anthony         0.12   -0.71   -0.59  
  Vujacic, Sasha           -1.03    0.44   -0.59  
  Barry, Brent             -0.36   -0.24   -0.60  
  Carter, Anthony          -0.87    0.26   -0.61  
  Iverson, Allen           -1.96    1.33   -0.63  
  Swift, Robert            -0.05   -0.58   -0.63  
  Sefolosha, Thabo         -1.86    1.21   -0.65  
  Johnson, Linton          -0.56   -0.11   -0.67  
  Gasol, Marc               0.46   -1.14   -0.68  
  Butler, Caron             2.07   -2.75   -0.68  
  Gill, Eddie              -0.32   -0.37   -0.69  
  Bowen, Ryan              -0.29   -0.39   -0.69  
  Moore, Mikki             -0.57   -0.13   -0.70  
  Jefferson, Richard       -0.43   -0.26   -0.70  
  Alexander, Joe           -0.02   -0.69   -0.70  
  Ely, Melvin              -1.02    0.31   -0.71  
  Calderon, Jose            0.52   -1.26   -0.74  
  Booth, Calvin            -0.25   -0.51   -0.76  
  West, Mario              -0.76    0.00   -0.76  
  Beasley, Michael         -0.36   -0.42   -0.78  
  Carney, Rodney           -1.23    0.44   -0.78  
  Landry, Carl              0.01   -0.81   -0.79  
  Jamison, Antawn           0.64   -1.44   -0.80  
  Ollie, Kevin             -0.16   -0.65   -0.81  
  Ridnour, Luke            -1.10    0.29   -0.81  
  Brand, Elton             -2.50    1.69   -0.81  
  Koufos, Kosta            -1.19    0.37   -0.82  
  Mohammed, Nazr           -0.13   -0.70   -0.83  
  Dunleavy, Mike           -0.35   -0.55   -0.90  
  Kaman, Chris             -0.97    0.06   -0.91  
  Taylor, Mike             -0.65   -0.27   -0.92  
  Crawford, Jamal           1.90   -2.84   -0.94  
  Arthur, Darrell          -1.23    0.27   -0.96  
  Alston, Rafer            -0.88   -0.08   -0.96  
  Atkins, Chucky           -1.08    0.12   -0.96  
  Ukic, Roko               -2.02    1.05   -0.96  
  Collins, Jarron          -0.95   -0.02   -0.97  
  Biedrins, Andris         -1.04    0.07   -0.97  
  Bell, Charlie            -0.92   -0.12   -1.04  
  Green, Jeff              -0.07   -0.97   -1.05  
  Martin, Kevin             2.17   -3.23   -1.06  
  Jianlian, Yi             -0.78   -0.34   -1.12  
  Dampier, Erick           -0.85   -0.29   -1.14  
  Yue, Sun                 -0.41   -0.74   -1.14  
  Croshere, Austin         -1.13   -0.03   -1.16  
  Marbury, Stephon         -1.06   -0.13   -1.19  
  Hunter, Lindsey          -1.10   -0.10   -1.20  
  Stevenson, DeShawn       -0.47   -0.74   -1.21  
  Williams, Marvin         -0.40   -0.83   -1.23  
  Mihm, Chris              -0.77   -0.46   -1.23  
  Weems, Sonny             -1.08   -0.15   -1.24  
  Randolph, Shavlik        -0.55   -0.70   -1.25  
  Nelson, Demarcus         -1.51    0.26   -1.25  
  Diawara, Yakhouba        -1.58    0.32   -1.26  
  Livingston, Shaun        -0.44   -0.82   -1.26  
  O'Neal, Jermaine         -0.60   -0.69   -1.29  
  Maggette, Corey           0.16   -1.47   -1.30  
  Miller, Mike             -0.10   -1.24   -1.34  
  Davis, Baron             -0.91   -0.44   -1.35  
  Marks, Sean              -1.45    0.08   -1.37  
  Almond, Morris           -2.08    0.70   -1.38  
  Armstrong, Hilton        -1.76    0.37   -1.39  
  Singletary, Sean         -1.75    0.36   -1.39  
  Novak, Steve             -0.17   -1.23   -1.40  
  Rodriguez, Sergio        -1.06   -0.35   -1.42  
  Mayo, O.J.                0.55   -1.98   -1.43  
  Richardson, Jeremy       -0.99   -0.48   -1.47  
  Bowen, Bruce             -3.12    1.64   -1.47  
  Lowry, Kyle              -1.91    0.43   -1.49  
  McGuire, Dominic          0.22   -1.71   -1.49  
  Dixon, Juan              -0.96   -0.53   -1.49  
  Evans, Maurice           -0.25   -1.26   -1.52  
  Boozer, Carlos           -0.30   -1.26   -1.56  
  Speights, Marreese        0.41   -2.03   -1.62  
  Oberto, Fabricio         -1.44   -0.19   -1.62  
  Richardson, Jason         0.82   -2.45   -1.63  
  Price, Ronnie            -0.55   -1.09   -1.64  
  Vaughn, Jacque           -2.00    0.33   -1.67  
  Williams, Louis           0.18   -1.88   -1.70  
  Hayes, Chuck             -2.33    0.61   -1.72  
  Farmar, Jordan           -1.40   -0.33   -1.73  
  Pecherov, Oleksiy         0.15   -1.92   -1.77  
  Watson, Earl             -0.50   -1.28   -1.78  
  Gay, Rudy                -0.13   -1.65   -1.78  
  Kapono, Jason            -0.49   -1.31   -1.81  
  Gordon, Eric             -0.68   -1.15   -1.83  
  McCants, Rashad          -2.19    0.34   -1.86  
  Solomon, Willie          -1.54   -0.36   -1.90  
  Nesterovic, Rasho        -1.58   -0.33   -1.91  
  Chandler, Wilson         -0.51   -1.40   -1.91  
  Anthony, Joel            -1.98    0.05   -1.93  
  Cook, Brian              -1.56   -0.38   -1.94  
  Lopez, Robin             -1.14   -0.82   -1.96  
  Gooden, Drew             -2.06    0.08   -1.98  
  Stackhouse, Jerry        -1.89   -0.09   -1.99  
  Thomas, Etan             -1.12   -0.88   -2.00  
  Roberson, Anthony        -1.51   -0.50   -2.00  
  Miles, Darius            -1.84   -0.19   -2.03  
  Smith, Craig             -1.58   -0.46   -2.04  
  Bayless, Jerryd          -0.66   -1.39   -2.05  
  Kinsey, Tarence          -1.12   -0.95   -2.07  
  Maxiell, Jason           -0.38   -1.70   -2.08  
  Walker, Bill             -1.03   -1.14   -2.17  
  May, Sean                -2.07   -0.10   -2.17  
  Crittenton, Javaris      -0.09   -2.08   -2.18  
  Jones, Solomon           -1.60   -0.59   -2.19  
  Morrison, Adam           -1.09   -1.12   -2.20  
  Wilcox, Chris            -1.12   -1.11   -2.23  
  Howard, Juwan            -0.98   -1.27   -2.25  
  Wilkins, Damien          -2.14   -0.12   -2.26  
  Greene, Donte            -1.83   -0.43   -2.26  
  Love, Kevin              -1.07   -1.27   -2.34  
  Gortat, Marcin           -2.59    0.24   -2.35  
  Diogu, Ike               -0.91   -1.45   -2.36  
  Hassell, Trenton         -1.76   -0.73   -2.49  
  Green, Gerald            -2.12   -0.37   -2.49  
  Gomes, Ryan              -1.51   -1.04   -2.55  
  Hughes, Larry            -1.29   -1.33   -2.62  
  Najera, Eduardo          -2.39   -0.25   -2.64  
  Thomas, Tyrus            -2.42   -0.23   -2.64  
  Jackson, Darnell         -0.63   -2.03   -2.67  
  Banks, Marcus            -2.11   -0.56   -2.67  
  Diop, DeSagana           -0.75   -1.94   -2.68  
  Davis, Ricky             -1.34   -1.37   -2.71  
  Butler, Rasual           -1.28   -1.49   -2.77  
  Kurz, Rob                -2.49   -0.28   -2.78  
  Bargnani, Andrea         -0.09   -2.70   -2.78  
  Salmons, John             0.19   -2.99   -2.79  
  Brown, Bobby             -1.26   -1.55   -2.80  
  Jordan, DeAndre          -1.38   -1.44   -2.82  
  James, Mike              -2.28   -0.62   -2.90  
  Rush, Brandon            -1.63   -1.33   -2.96  
  Jones, Dahntay           -2.39   -0.60   -2.98  
  Ivey, Royal              -1.15   -1.85   -3.00  
  George, Devean           -1.59   -1.51   -3.10  
  Head, Luther             -0.91   -2.26   -3.17  
  Hart, Jason              -2.74   -0.49   -3.22  
  Dooling, Keyon           -0.73   -2.51   -3.25  
  Kleiza, Linas            -1.90   -1.40   -3.29  
  Skinner, Brian           -2.94   -0.46   -3.40  
  Garcia, Francisco        -1.96   -1.48   -3.44  
  Thornton, Al              0.12   -3.56   -3.44  
  Petro, Johan             -2.36   -1.09   -3.45  
  Carroll, Matt            -3.32   -0.13   -3.45  
  Collins, Jason           -2.90   -0.58   -3.48  
  Durant, Kevin            -1.41   -2.09   -3.50  
  Hawes, Spencer           -1.04   -2.47   -3.51  
  McGee, JaVale            -1.01   -2.62   -3.63  
  Frye, Channing           -1.75   -1.96   -3.71  
  Hickson, J.J.            -2.09   -1.63   -3.72  
  Powell, Josh             -2.22   -1.56   -3.78  
  Daniels, Antonio         -1.85   -2.68   -4.53  
@KwameBeanJordan

This seems to confirm your latest findings. I've checked other sources too and it's similar enough (not "somewhat similar" like before).

@mystic

I can confirm now "weight" doesn't need to be matrix like I said before.
You were right that standardize=FALSE almost completely solve the problem I mentioned in the first place. Nice finding. Thanks again.

Edit:

Re: Setting Up Excel File for RAPM

Posted: Wed Sep 14, 2016 5:20 pm
by DSMok1
This has been a very informative thread, guys! Very useful.

Quick question:

Does anyone have simple R code for converting to the wide & sparse data structure?

Right now my lineup data looks like:

Code: Select all

╔═══════════════════════════════════════════════════╦═══════════════════════════════════════════════════╗
║                  visitor_lineup                   ║                    home_lineup                    ║
╠═══════════════════════════════════════════════════╬═══════════════════════════════════════════════════╣
║ caldwke01:drumman01:ilyaser01:jacksre01:morrima03 ║ bazemke01:horfoal01:korveky01:millspa01:teaguje01 ║
╚═══════════════════════════════════════════════════╩═══════════════════════════════════════════════════╝
The way I understand it, that needs to be converted to wide format. Evan Zamir was able to jump that type of a lineup data straight to a sparse matrix in Python ( http://nyloncalculus.com/2015/07/29/gue ... -a-how-to/ ). Is that the approach you all are using for R as well, a sparse matrix?

I haven't been able to figure out a simple way to do that in R.

Thanks for your help!

Re: Setting Up Excel File for RAPM

Posted: Fri Sep 16, 2016 12:55 pm
by Nate
Sorry are you looking for something like splitstr() or something to set up dummy variables:

http://r.iq.harvard.edu/docs/zelig/3.4- ... ating.html


Or maybe something else.

Re: Setting Up Excel File for RAPM

Posted: Fri Sep 16, 2016 12:59 pm
by DSMok1
Nate wrote:Sorry are you looking for something like splitstr() or something to set up dummy variables:

http://r.iq.harvard.edu/docs/zelig/3.4- ... ating.html


Or maybe something else.
I'm more interested in how to move the (already split) string directly to a sparse matrix. I'd rather use a sparse matrix than a conventional 1's and 0's dummy matrix.