7.1

7.1 After reading the dataset into R (naming it using your student ID as usual), identify the number of observations, data types, as well as the mean, median, and quartiles for each variable in the dataset. Use any function(s) that you like. Show your function(s) and your output.

Consider other statistics or graphics you may want to create.

cp <- read.csv("CommercialProperties.csv")

View(cp)

summary(cp)
##   Rental.Rates       Age         Operating.Expenses.and.Taxes Vacancy.Rates    
##  Min.   :10.5   Min.   : 0.000   Min.   : 3.000               Min.   :0.00000  
##  1st Qu.:14.0   1st Qu.: 2.000   1st Qu.: 8.145               1st Qu.:0.00000  
##  Median :15.0   Median : 4.000   Median :10.370               Median :0.03000  
##  Mean   :15.2   Mean   : 8.012   Mean   : 9.814               Mean   :0.08244  
##  3rd Qu.:16.5   3rd Qu.:15.000   3rd Qu.:11.620               3rd Qu.:0.09750  
##  Max.   :20.0   Max.   :20.000   Max.   :20.000               Max.   :0.73000  
##  Total.Square.Footage
##  Min.   : 27000      
##  1st Qu.: 70500      
##  Median :129614      
##  Mean   :164772      
##  3rd Qu.:239000      
##  Max.   :500020
str(cp)
## 'data.frame':    82 obs. of  5 variables:
##  $ Rental.Rates                : num  13.5 12 10.5 15 14 10.5 14 16.5 17.5 16.5 ...
##  $ Age                         : int  1 14 16 4 11 15 2 1 1 8 ...
##  $ Operating.Expenses.and.Taxes: num  5.02 8.19 3 10.7 8.97 ...
##  $ Vacancy.Rates               : num  0.14 0.27 0 0.05 0.07 0.24 0.19 0.6 0 0.03 ...
##  $ Total.Square.Footage        : int  123000 104079 39998 57112 60000 101385 31300 248172 215000 251015 ...

7.2

7.2 Perform a series of regressions where you predict 7.2.1 rental rates of the properties (Rental Rates) using Age, 7.2.2 rental rates of the properties (Rental Rates) using Operating Expenses & Taxes, 7.2.3 rental rates of the properties (Rental Rates) using Vacancy Rates, and 7.2.4 rental rates of the properties (Rental Rates) using Total Square Footage

Please run four simple linear regressions. Do not run a multiple regression. Show your commands and your output.

After running these 4 models, which independent variables (IVs) seem to have a statistically-significant effect on the dependent variable (DV) of Rental Rates?

Age, operating expenses and taxes, and total square footage are statistically-significant predictors of rental rates. Vacancy rates are not.

reg1 <- lm(cp$Rental.Rates ~ cp$Age)
reg2 <- lm(cp$Rental.Rates ~ cp$Operating.Expenses.and.Taxes)
reg3 <- lm(cp$Rental.Rates ~ cp$Vacancy.Rates)
reg4 <- lm(cp$Rental.Rates ~ cp$Total.Square.Footage)

summary(reg1)
## 
## Call:
## lm(formula = cp$Rental.Rates ~ cp$Age)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.3739 -0.9308  0.1209  1.0112  5.3582 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 15.57003    0.30593  50.895   <2e-16 ***
## cp$Age      -0.04641    0.02932  -1.583    0.117    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.775 on 80 degrees of freedom
## Multiple R-squared:  0.03038,    Adjusted R-squared:  0.01826 
## F-statistic: 2.506 on 1 and 80 DF,  p-value: 0.1173
summary(reg2)
## 
## Call:
## lm(formula = cp$Rental.Rates ~ cp$Operating.Expenses.and.Taxes)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.5862 -0.9241 -0.1766  0.7576  4.8161 
## 
## Coefficients:
##                                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                     12.17872    0.63735  19.109  < 2e-16 ***
## cp$Operating.Expenses.and.Taxes  0.30767    0.06247   4.925 4.45e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.579 on 80 degrees of freedom
## Multiple R-squared:  0.2327, Adjusted R-squared:  0.2231 
## F-statistic: 24.26 on 1 and 80 DF,  p-value: 4.452e-06
summary(reg3)
## 
## Call:
## lm(formula = cp$Rental.Rates ~ cp$Vacancy.Rates)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.8924 -1.1243 -0.0965  1.1264  4.6569 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       15.0965     0.2329  64.815   <2e-16 ***
## cp$Vacancy.Rates   1.2329     1.4841   0.831    0.409    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.795 on 80 degrees of freedom
## Multiple R-squared:  0.008552,   Adjusted R-squared:  -0.003841 
## F-statistic: 0.6901 on 1 and 80 DF,  p-value: 0.4086
summary(reg4)
## 
## Call:
## lm(formula = cp$Rental.Rates ~ cp$Total.Square.Footage)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.1236 -0.7636  0.2848  1.0718  3.3699 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             1.370e+01  2.848e-01  48.117  < 2e-16 ***
## cp$Total.Square.Footage 9.065e-06  1.421e-06   6.377 1.08e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.468 on 80 degrees of freedom
## Multiple R-squared:  0.337,  Adjusted R-squared:  0.3287 
## F-statistic: 40.67 on 1 and 80 DF,  p-value: 1.084e-08

7.3

7.3 Look at your output for the regression of rental rates and total square footage.
How many observations are analyzed (what is the “n” value)? What is the regression equation? What is the R2 value? [use the “Multiple R-Squared”]. What percentage of variation does this model explain? According to this model, how much would a property of 300,000 square feet rent for?

n = 82 Y = 13.70 + 0.000009065*Total Square Footage R2 = 0.337

300000*0.000009065 + 13.70
## [1] 16.4195

A property of 300,000 square feet would rent for $16.42 per square foot.

7.4

7.4 Use the ggplot() to check the required conditions for the model [only do model 4, the one with total square footage as the independent variable and rental rates as the dependent variable]. Show your commands and your output. Choose your own colors for your graphics.

Be sure you have appropriate titles on all of your graphics, and that all axes are labeled appropriately.

State your conclusion about the usefulness of the model.

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.2.3
reg4StdRes <- rstandard(reg4)

reg4$StdRes <- reg4StdRes
reg4$StdRes <- reg4StdRes


ggplot(data = reg4, aes(reg4$StdRes)) + 
  geom_histogram(breaks = seq(-3, 3, by=0.2),col = "blue2",fill = "blue2", bins = 5) + 
  labs(title = "Checking for Normality", x = "Standardized Residuals", y = "Count") + 
  theme(plot.title=element_text(hjust=0.5))

ggplot(data = reg4) + 
  geom_point(mapping = aes(x = reg4$fitted.values, y = reg4$StdRes), color = "blue") + 
  labs(title = "Checking for Homoscedasticity", x = "Fitted Values", y = "Standard Residuals") + 
  theme(plot.title=element_text(hjust=0.5))

length(subset(reg4StdRes, reg4StdRes>2))
## [1] 1
length(subset(reg4StdRes, reg4StdRes<(-2)))
## [1] 3

The model satisfies all required condition [although is slightly non-normal].