SUMMARY

Many municipalities implementing smart-growth principles do so by designated specific areas—sometimes called clusters with more flexible zoning. Usually, the intent is to obtain a mix of uses in a more walkable environment. Sometimes, these clusters get their own special zoning area or “planned unit development” in the zoning map. Sometimes, they are conceived as overlay districts: special areas that cross over two or more zoning districts, but in which regulated exceptions from the basic zoning guidelines are allowed. In such clusters or flexible development areas, towns usually provide incentives for developers to build at higher densities.

Setting up working environment

## 
## Attaching package: 'janitor'
## The following objects are masked from 'package:stats':
## 
##     chisq.test, fisher.test
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6     ✔ purrr   0.3.4
## ✔ tibble  3.1.7     ✔ dplyr   1.0.9
## ✔ tidyr   1.2.0     ✔ stringr 1.4.0
## ✔ readr   2.1.2     ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## 
## Attaching package: 'scales'
## 
## 
## The following object is masked from 'package:purrr':
## 
##     discard
## 
## 
## The following object is masked from 'package:readr':
## 
##     col_factor

Create a new table of data from the “MASSZONG.xls”

masszoning <- read_xls("MASSZONING.xls")

Question 1:

For the minimum lot area per dwelling unit (unitarea): What share of cities do not have a minimum lot area? What is the 5 number summary of the minimum lot area per dwelling unit? Represent that distribution of minimum lot area as a boxplot and as a histogram. Remember to label your figures.

#histogram
minimum_lot_area_per_dwelling_unit_hist <- ggplot(masszoning, aes(x=unitarea), na.rm = TRUE)+
  geom_histogram(color = "dark gray", fill = "dark green")+
  labs(title = "Minimum lot area per dwelling unit distribution - Histogram", x = 'lot area')+
  theme(panel.background = element_rect(fill = 'white', color = 'grey'),
        panel.grid.major = element_line(color = 'lightgrey', size = .2),
        panel.grid.minor = element_line(color = 'lightgrey', size = .1))

minimum_lot_area_per_dwelling_unit_hist
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 79 rows containing non-finite values (stat_bin).

#boxplot
minimum_lot_area_per_dwelling_unit_box <- ggplot(masszoning, aes(y=unitarea), na.rm = TRUE)+
  geom_boxplot(color = "dark green", outlier.colour="red", outlier.shape=8,
                outlier.size=4)+
  labs(title = "Minimum lot area per dwelling unit distribution - Boxplot", x = 'lot area')+
  theme(panel.background = element_rect(fill = 'white', color = 'grey'),
        panel.grid.major = element_line(color = 'lightgrey', size = .2),
        panel.grid.minor = element_line(color = 'lightgrey', size = .1))

minimum_lot_area_per_dwelling_unit_box
## Warning: Removed 79 rows containing non-finite values (stat_boxplot).


Question 2:

For the minimum lot area per dwelling unit: Provide the sample mean Provide the variance from that sample mean Provide the standard deviation from that sample mean Provide the towns that are more than two standard deviations above the sample mean

min_lot_area = na.omit(masszoning$unitarea)

#mean
min_lot_area_mean <- mean(min_lot_area)
#standard deviation
min_lot_area_sd <- sd(min_lot_area)
#Provide the towns that are more than two standard deviations above the sample mean
masszoning %>% filter(unitarea > (min_lot_area_mean+2*min_lot_area_sd), na.rm = TRUE) %>% .$townname
## [1] "TOWNSEND" "HARVARD"  "BERKLEY"  "HALIFAX"  "REHOBOTH"

Question 3:

The state of Massachusetts is considering choosing a town from this sample at random to provide a $250,000 grant to support development of affordable housing. What is the probability that grant goes to a town that has adopted a mandatory inclusionary zoning requirement (include)? What is the probability that the grant goes to a town that has adopted a voluntary inclusionary zoning requirement? What is the probability that it goes to a town that has adopted both a mandatory and a voluntary inclusionary zoning requirement?

#P(Voluntary)
print(paste("P(Voluntary) is", round(sum(masszoning$include == 1)/nrow(masszoning), digit = 3)))
## [1] "P(Voluntary) is 0.209"
#P(Mandatory)
print(paste("P(Mandatory) is", round(sum(masszoning$include == 2)/nrow(masszoning), digit = 3)))
## [1] "P(Mandatory) is 0.193"
#P(Voluntary and Mandatory)
print(paste("P(Voluntary and Mandatory) is", round(sum(masszoning$include == 3)/nrow(masszoning), digit = 3)))
## [1] "P(Voluntary and Mandatory) is 0.128"

Question 4:

Create a contingency table with the number of towns that have adopted a mandatory inclusionary zoning requirement by the number that have adopted a planned or targeted growth rate (growrate). Do the results suggest that these two variables have any relation to each other?

new_tab <- data.frame(town_name = masszoning$townname,
                      mandatory_inclusionary_zoning = masszoning$include,
                      growth_rate = masszoning$growrate) %>%
  filter(.$mandatory_inclusionary_zoning == 2)

new_tab
##       town_name mandatory_inclusionary_zoning growth_rate
## 1        GROTON                             2           1
## 2        BOLTON                             2           1
## 3        BERLIN                             2           1
## 4  SOUTHBOROUGH                             2           0
## 5     HOPKINTON                             2           0
## 6        MENDON                             2           1
## 7    FRAMINGHAM                             2           0
## 8      WESTFORD                             2           1
## 9        NORTON                             2           0
## 10        DOVER                             2           0
## 11    WELLESLEY                             2           0
## 12      RAYNHAM                             2           0
## 13       CANTON                             2           0
## 14       NEWTON                             2           0
## 15    TEWKSBURY                             2           0
## 16       CARVER                             2           1
## 17      DUXBURY                             2           0
## 18   MARSHFIELD                             2           0
## 19     SCITUATE                             2           0
## 20     HOLBROOK                             2           0
## 21    WATERTOWN                             2           0
## 22   SOMERVILLE                             2           0
## 23      CHELSEA                             2           0
## 24      BELMONT                             2           0
## 25    ARLINGTON                             2           0
## 26    WAKEFIELD                             2           0
## 27      READING                             2           0
## 28      BEVERLY                             2           0
## 29      ANDOVER                             2           0
## 30    HAVERHILL                             2           1
## 31   GEORGETOWN                             2           1
## 32      IPSWICH                             2           0
## 33     ROCKPORT                             2           0
## 34   GLOUCESTER                             2           0
## 35  NORTHBRIDGE                             2           0
## 36       PAXTON                             2           0
print(paste("There are only", percent(sum(new_tab$growth_rate == 1)/nrow(new_tab)), "of towns with mandatory inclusionary zoning requirement that have adopted a planned growth rate"))
## [1] "There are only 22% of towns with mandatory inclusionary zoning requirement that have adopted a planned growth rate"