Posts

Showing posts with the label R

4.4.3 R4. Regression Trees- Video 2 The Data

Before we jump into R, let's understand the data. Each entry of this data set corresponds to a census tract, a statistical division of the area that is used by researchers to break down towns and cities. As a result, there will usually be multiple census tracts per town. LON and LAT are the longitude and latitude of the center of the census tract. MEDV is the median value of owner-occupied homes, measured in thousands of dollars. CRIM is the per capita crime rate. ZN is related to how much of the land is zoned for large residential properties. INDUS is the proportion of the area used for industry. CHAS is 1 if a census tract is next to the Charles River, which I drew before. NOX is the concentration of nitrous oxides in the air, a measure of air pollution. RM is the average number of rooms per dwelling. AGE is the proportion of owner-occupied units built before 1940. DIS is a measure of how far the tract is from centers of employment in Boston. RAD is a measure of clo...

2.2.7 An Introduction to Linear Regression - Video 4 Linear Regression in R

In our R Console, let's start by loading our data set. Don't forget to make sure you're in the directory containing the file wine.csv first. We'll call our data frame wine, and we'll use the read.csv function to read in the data file wine.csv. We can look at the structure of our data by using the str function. We can see that we have a data frame with 25 observations of seven different variables. Year gives the year the wine was produced, and it's just a unique identifier for each observation. Price is the dependent variable we're trying to predict. And WinterRain, AGST, HarvestRain, Age, and FrancePop are the independent variables we'll use to predict Price. We can also look at the statistical summary of our data using the summary function. This gives us information about the range of values for each variable in our data set. Let's now create a one-variable linear regression equation using AGST to predict Price. We'll call our regr...