BACKGROUND
Hello, I am relatively new to R. I am trying to execute a regression of winning percentage against a certain set of statistics. I have had experience with regression when the data is simplified and tidy already, but I do not have much experience in fixing my data to allow me to run the proper regression.
Data
I have added the dataset I am using. Here is the link: https://www.kaggle.com/nathanlauga/nba-games You will be directed to the website that contains the games.csv download file.
Code
The first thing I did was make this into a data frame and replace all the Team I.D.'s with their real abbreviated names.
head(NBA_Games)
NBA.df <- data.frame(NBA_Games)
head(NBA.df)
NBA.df[NBA.df == "1610612737"] <- "ATL"
NBA.df[NBA.df == "1610612738"] <- "BOS"
NBA.df[NBA.df == "1610612740"] <- "NO"
NBA.df[NBA.df == "1610612741"] <- "CHI"
NBA.df[NBA.df == "1610612742"] <- "DAL"
NBA.df[NBA.df == "1610612743"] <- "DEN"
NBA.df[NBA.df == "1610612745"] <- "HOU"
NBA.df[NBA.df == "1610612746"] <- "LAC"
NBA.df[NBA.df == "1610612747"] <- "LAL"
NBA.df[NBA.df == "1610612748"] <- "MIA"
NBA.df[NBA.df == "1610612749"] <- "MIL"
NBA.df[NBA.df == "1610612750"] <- "MIN"
NBA.df[NBA.df == "1610612751"] <- "BKN"
NBA.df[NBA.df == "1610612752"] <- "NYK"
NBA.df[NBA.df == "1610612753"] <- "ORL"
NBA.df[NBA.df == "1610612754"] <- "IND"
NBA.df[NBA.df == "1610612755"] <- "PHI"
NBA.df[NBA.df == "1610612756"] <- "PHX"
NBA.df[NBA.df == "1610612757"] <- "POR"
NBA.df[NBA.df == "1610612758"] <- "SAC"
NBA.df[NBA.df == "1610612759"] <- "SAS"
NBA.df[NBA.df == "1610612760"] <- "OKC"
NBA.df[NBA.df == "1610612761"] <- "TOR"
NBA.df[NBA.df == "1610612762"] <- "UTA"
NBA.df[NBA.df == "1610612763"] <- "MEM"
NBA.df[NBA.df == "1610612764"] <- "WAS"
NBA.df[NBA.df == "1610612765"] <- "DET"
NBA.df[NBA.df == "1610612766"] <- "CHA"
NBA.df[NBA.df == "1610612739"] <- "CLE"
NBA.df[NBA.df == "1610612744"] <- "GSW"
I am aware that there may have been an easier way to do that and any advice on that would be helpful, but that is not the true problem I am having.
Problem
If you notice from the data set, it is split into home team stats and away team stats. The only stat that records wins is in the last column of the data frame, named "HOME_TEAM_WINS". It records a 1 if they did and a 0 if they did not win. Now, this is where I do not really know what to do. I want my Response (Y) variable in my regression to be winning percentage, but it is in binary form at the moment. I would like to think that there is a way to create a new variable that would allow me to run it against the other in-game statistics.
Also, what would the easiest way to factor this and split it up by each team's winning percentage?
I hope this makes sense. Any help on how to do this or any tips about how to think of this from a statistical perspective will be greatly appreciated.