Summary

Load data

Use hou14 for the following analysis:

  1. Determine the distance limit in the distance band approach
    1. Determine the number of the nearest neighbors in the kth nearest neighbor approach.
load(file="df_hou4.Rdata")
hou14 <- df_hou4
save(hou14, file="hou14.Rdata")
load(file="hou14.Rdata")

Create data frame for low and high quality hotels

hou14$s_rating <- hou14$s_rating/10

# sort data by market id variables (qtr)
hou14 <- hou14[order(hou14$qtr),]

# If s_rating >= 3.5, hotels are considered as high quality
# If s_rating < 3.5, hotels are considered as low quality
hou14.h <- hou14[hou14$s_rating>3, ]
hou14.l <- hou14[hou14$s_rating<3.5, ]

1. Analysis with all hotels in Houston, TX

Source R functions

source(file="price_competition_functions.R")
source(file="MMC_functions1.R")
source(file="avmmc.new.R")

Determine the distance limit and the number of the nearest neighbors

# All hotels in Houston, TX
dist.mat.list.all <- list()
for(i in 1:4){
  temp.data <- hou14[hou14$qtr==i, c("lat", "lon")]
  temp.dist <- GeoDistMat(temp.data)
  dist.mat.list.all[[i]] <- temp.dist
}
## Loading required package: Imap
wp.temp <- get.wp(mkt.id.fld ="qtr", id.brand.fld ="id.brand", id.chain.fld="id.chain", 
                 price.fld ="adr", q.fl="room.sold", rating.fld="s_rating", 
                 dist.limit = 20, dat=hou14, dis.mat = dist.mat.list.all , n.rival=5)
## market id  1  completed 
## market id  2  completed 
## market id  3  completed 
## market id  4  completed
wp.temp2 <- lapply(wp.temp, as.data.frame)
wp.all  <- do.call(rbind.fill, wp.temp2) 
hou14.wp <- cbind(hou14, wp.all)          

# OLS regression with weighted matrix function (hotel within 20 miles from the focal hotel)
ols.hou.all <- lm(adr ~ wp.d + s_rating + hi.sales + room + cbd + air + factor(chain),
                          data= hou14.wp)

summary(ols.hou.all)
## 
## Call:
## lm(formula = adr ~ wp.d + s_rating + hi.sales + room + cbd + 
##     air + factor(chain), data = hou14.wp)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -71.730 -16.069  -1.153  13.458 161.832 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     -22.612746   3.617521  -6.251 5.32e-10 ***
## wp.d              0.061512   0.011371   5.410 7.35e-08 ***
## s_rating         40.334736   1.348540  29.910  < 2e-16 ***
## hi.sales        -60.045650  13.018845  -4.612 4.33e-06 ***
## room             -0.001327   0.007773  -0.171 0.864516    
## cbd              18.785077   3.734819   5.030 5.51e-07 ***
## air             -17.266029   3.530002  -4.891 1.11e-06 ***
## factor(chain)1   39.506478   2.523429  15.656  < 2e-16 ***
## factor(chain)2   43.807732   3.321344  13.190  < 2e-16 ***
## factor(chain)3   25.799594   2.759086   9.351  < 2e-16 ***
## factor(chain)4   -3.804409   3.137594  -1.213 0.225504    
## factor(chain)5    9.226447   2.839177   3.250 0.001181 ** 
## factor(chain)7   16.775244   6.429069   2.609 0.009164 ** 
## factor(chain)11  -4.289352   4.803931  -0.893 0.372064    
## factor(chain)12  20.314653   4.892639   4.152 3.48e-05 ***
## factor(chain)13 -10.228061   9.601733  -1.065 0.286944    
## factor(chain)14 -24.809914   9.623609  -2.578 0.010032 *  
## factor(chain)15   2.225962   8.000029   0.278 0.780863    
## factor(chain)16  37.778298   4.678231   8.075 1.38e-15 ***
## factor(chain)17  -9.578927   3.885334  -2.465 0.013798 *  
## factor(chain)18 159.058680  13.655595  11.648  < 2e-16 ***
## factor(chain)19 204.099757  27.186823   7.507 1.03e-13 ***
## factor(chain)22 -25.356534   4.961507  -5.111 3.63e-07 ***
## factor(chain)23  20.260527   3.801172   5.330 1.13e-07 ***
## factor(chain)24  -7.708359   4.741516  -1.626 0.104222    
## factor(chain)26  15.985344   9.995926   1.599 0.109991    
## factor(chain)27  -6.963797   6.168733  -1.129 0.259128    
## factor(chain)28  -0.731744  13.798716  -0.053 0.957715    
## factor(chain)29  -6.461710   9.591100  -0.674 0.500594    
## factor(chain)30 -29.260780   7.872338  -3.717 0.000209 ***
## factor(chain)40  25.203952   3.251210   7.752 1.66e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 26.78 on 1490 degrees of freedom
## Multiple R-squared:  0.7509, Adjusted R-squared:  0.7458 
## F-statistic: 149.7 on 30 and 1490 DF,  p-value: < 2.2e-16
gamma.a <- ols.hou.all$coefficients["wp.d"]
gamma.a.lw <- confint(ols.hou.all, "wp.d")[1]
gamma.a.up <- confint(ols.hou.all, "wp.d")[2]

distance <- as.matrix(seq(0, 20, by=0.1))

price.effect.a <- data.frame()
price.effect.a <- as.data.frame(cbind(distance, gamma.a/distance, gamma.a.lw/distance, gamma.a.up/distance))
price.effect.a <- price.effect.a[-1,]
names(price.effect.a) <- c("distance", "mean", "lower", "upper")

ggplot(price.effect.a, aes(x=distance, y=mean)) + geom_line(aes(color="Price Effect"), size=1) + 
  geom_ribbon(aes(ymin=lower, ymax=upper, x=distance, fill="CI Interval"), alpha=0.3 ) +
  scale_colour_manual("",values="blue")+
  scale_fill_manual("",values="grey12") +
  xlim(0,3) + 
  labs(x="Distance (Miles)", y="Price Effect = b") +
  theme_grey(base_size = 18)

ggplot(price.effect.a, aes(x=distance, y=mean)) + geom_line(aes(color="Price Effect"), size=1) + 
  geom_ribbon(aes(ymin=lower, ymax=upper, x=distance, fill="CI Interval"), alpha=0.3 ) +
  scale_colour_manual("",values="blue")+
  scale_fill_manual("",values="grey12") +
  xlim(0,10) + 
  labs(x="Distance (Miles)", y="Price Effect = b") +
  theme_grey(base_size = 18)

# High Quality Hotels
dim(hou14.h)
## [1] 253 155
## Create Distance Matrix
dist.mat.high.list <- list()
for(i in 1:4){
  temp.data <- hou14.h[hou14.h$qtr==i, ]
  temp.dist <- GeoDistMat(temp.data)
  dist.mat.high.list[[i]] <- temp.dist
}

wp.temp.h <- get.wp(mkt.id.fld ="qtr", id.brand.fld ="id.brand", id.chain.fld="id.chain", 
                 price.fld ="adr", q.fl="room.sold", rating.fld="s_rating", 
                 dist.limit = 20, dat=hou14.h, dis.mat = dist.mat.high.list , n.rival=5)
## market id  1  completed 
## market id  2  completed 
## market id  3  completed 
## market id  4  completed
wp.temp2 <- lapply(wp.temp.h, as.data.frame)
wp.high  <- do.call(rbind.fill, wp.temp2) 
hou14.h.wp <- cbind(hou14.h, wp.high)          

# OLS regression with weighted matrix function (hotel within 20 miles from the focal hotel)
ols.hou.high <- lm(adr ~ wp.d + s_rating + room + hi.sales + cbd + air + factor(chain),
                          data= hou14.h.wp)

summary(ols.hou.high)
## 
## Call:
## lm(formula = adr ~ wp.d + s_rating + room + hi.sales + cbd + 
##     air + factor(chain), data = hou14.h.wp)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -89.315 -19.192   1.704  21.292  74.028 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     -1.407e+02  3.164e+01  -4.446 1.35e-05 ***
## wp.d            -9.257e-03  3.182e-02  -0.291 0.771347    
## s_rating         8.294e+01  7.477e+00  11.092  < 2e-16 ***
## room            -2.838e-02  1.339e-02  -2.120 0.035029 *  
## hi.sales         5.693e+01  6.039e+01   0.943 0.346830    
## cbd              1.148e+01  7.614e+00   1.507 0.133037    
## air             -4.310e+01  1.773e+01  -2.431 0.015832 *  
## factor(chain)1  -1.784e+01  8.173e+00  -2.183 0.030039 *  
## factor(chain)2   1.485e+00  7.903e+00   0.188 0.851149    
## factor(chain)3  -3.264e+01  9.368e+00  -3.484 0.000591 ***
## factor(chain)4  -4.928e+01  1.348e+01  -3.657 0.000315 ***
## factor(chain)7  -3.479e+01  1.412e+01  -2.464 0.014481 *  
## factor(chain)14 -9.373e+01  1.824e+01  -5.139 5.85e-07 ***
## factor(chain)16 -1.059e+01  9.798e+00  -1.081 0.280943    
## factor(chain)17 -1.274e+02  1.795e+01  -7.099 1.51e-11 ***
## factor(chain)18  1.283e+02  1.841e+01   6.972 3.20e-11 ***
## factor(chain)19  1.170e+02  3.526e+01   3.319 0.001049 ** 
## factor(chain)26 -3.826e+01  1.371e+01  -2.791 0.005686 ** 
## factor(chain)28 -4.047e+01  1.824e+01  -2.219 0.027479 *  
## factor(chain)40  4.158e+00  9.626e+00   0.432 0.666156    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 33.79 on 233 degrees of freedom
## Multiple R-squared:  0.6609, Adjusted R-squared:  0.6333 
## F-statistic:  23.9 on 19 and 233 DF,  p-value: < 2.2e-16
gamma.a <- ols.hou.high$coefficients["wp.d"]
gamma.a.lw <- confint(ols.hou.high, "wp.d")[1]
gamma.a.up <- confint(ols.hou.high, "wp.d")[2]

distance <- as.matrix(seq(0, 20, by=0.1))

price.effect.a <- data.frame()
price.effect.a <- as.data.frame(cbind(distance, gamma.a/distance, gamma.a.lw/distance, gamma.a.up/distance))
price.effect.a <- price.effect.a[-1,]
names(price.effect.a) <- c("distance", "mean", "lower", "upper")

ggplot(price.effect.a, aes(x=distance, y=mean)) + geom_line(aes(color="Price Effect"), size=1) + 
  geom_ribbon(aes(ymin=lower, ymax=upper, x=distance, fill="CI Interval"), alpha=0.3 ) +
  scale_colour_manual("",values="blue")+
  scale_fill_manual("",values="grey12") +
  xlim(0,3) + 
  labs(x="Distance (Miles)", y="Price Effect = b") +
  theme_grey(base_size = 18)
## Warning: Removed 170 rows containing missing values (geom_path).

ggplot(price.effect.a, aes(x=distance, y=mean)) + geom_line(aes(color="Price Effect"), size=1) + 
  geom_ribbon(aes(ymin=lower, ymax=upper, x=distance, fill="CI Interval"), alpha=0.3 ) +
  scale_colour_manual("",values="blue")+
  scale_fill_manual("",values="grey12") +
  xlim(0,10) + 
  labs(x="Distance (Miles)", y="Price Effect = b") +
  theme_grey(base_size = 18)
## Warning: Removed 100 rows containing missing values (geom_path).

# Find distance limit for low-quality hotels
# Low Quality Hotel for sdfd
dim(hou14.l)
## [1] 1268  155
## Create Distance Matrix
dist.mat.low.list <- list()
for(i in 1:4){
  temp.data <- hou14.l[hou14.l$qtr==i, c("lat", "lon") ]
  temp.dist <- GeoDistMat(temp.data)
  dist.mat.low.list[[i]] <- temp.dist
}

wp.temp.l <- get.wp(mkt.id.fld ="qtr", id.brand.fld ="id.brand", id.chain.fld="id.chain", 
                 price.fld ="adr", q.fl="room.sold", rating.fld="s_rating", 
                 dist.limit = 20, dat=hou14.l, dis.mat = dist.mat.low.list , n.rival=5)
## market id  1  completed 
## market id  2  completed 
## market id  3  completed 
## market id  4  completed
wp.temp2 <- lapply(wp.temp.l, as.data.frame)
wp.low  <- do.call(rbind.fill, wp.temp2) 
hou14.l.wp <- cbind(hou14.l, wp.low)          

# OLS regression with weighted matrix function (hotel within 20 miles from the focal hotel)
ols.hou.low <- lm(adr ~ wp.d + s_rating + room + hi.sales + cbd + air + factor(chain),
                          data= hou14.l.wp)

summary(ols.hou.low)
## 
## Call:
## lm(formula = adr ~ wp.d + s_rating + room + hi.sales + cbd + 
##     air + factor(chain), data = hou14.l.wp)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -42.261 -10.824  -1.127   9.359  63.161 
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      32.648201   3.024099  10.796  < 2e-16 ***
## wp.d              0.021554   0.005775   3.732 0.000198 ***
## s_rating          9.656766   1.305493   7.397 2.56e-13 ***
## room             -0.070768   0.012839  -5.512 4.32e-08 ***
## hi.sales        -28.756608   8.638386  -3.329 0.000897 ***
## cbd              36.267682   3.756057   9.656  < 2e-16 ***
## air             -11.514882   2.299656  -5.007 6.32e-07 ***
## factor(chain)1   80.020627   2.120504  37.737  < 2e-16 ***
## factor(chain)2   95.432251   3.103585  30.749  < 2e-16 ***
## factor(chain)3   65.119268   2.217987  29.360  < 2e-16 ***
## factor(chain)4   13.756830   2.110204   6.519 1.03e-10 ***
## factor(chain)5   30.546504   1.892087  16.144  < 2e-16 ***
## factor(chain)7   59.003923   5.281202  11.172  < 2e-16 ***
## factor(chain)11   5.123167   3.033882   1.689 0.091538 .  
## factor(chain)12  46.229191   3.173130  14.569  < 2e-16 ***
## factor(chain)13   2.198423   6.138281   0.358 0.720292    
## factor(chain)14  34.458273   8.505356   4.051 5.41e-05 ***
## factor(chain)15  45.444903   5.254176   8.649  < 2e-16 ***
## factor(chain)16  82.804755   4.642674  17.836  < 2e-16 ***
## factor(chain)17  22.563913   2.729696   8.266 3.52e-16 ***
## factor(chain)22  -0.767523   3.325875  -0.231 0.817529    
## factor(chain)23  48.172860   2.583622  18.645  < 2e-16 ***
## factor(chain)24   4.990006   3.149757   1.584 0.113391    
## factor(chain)27  11.619069   3.983740   2.917 0.003602 ** 
## factor(chain)29   5.752112   6.103177   0.942 0.346131    
## factor(chain)30  -1.563541   5.066021  -0.309 0.757653    
## factor(chain)40   9.771918   2.348895   4.160 3.40e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 16.81 on 1241 degrees of freedom
## Multiple R-squared:  0.8208, Adjusted R-squared:  0.817 
## F-statistic: 218.6 on 26 and 1241 DF,  p-value: < 2.2e-16
gamma.a <- ols.hou.low$coefficients["wp.d"]
gamma.a.lw <- confint(ols.hou.low, "wp.d")[1]
gamma.a.up <- confint(ols.hou.low, "wp.d")[2]

distance <- as.matrix(seq(0, 20, by=0.1))

price.effect.a <- data.frame()
price.effect.a <- as.data.frame(cbind(distance, gamma.a/distance, gamma.a.lw/distance, gamma.a.up/distance))
price.effect.a <- price.effect.a[-1,]
names(price.effect.a) <- c("distance", "mean", "lower", "upper")

ggplot(price.effect.a, aes(x=distance, y=mean)) + geom_line(aes(color="Price Effect"), size=1) + 
  geom_ribbon(aes(ymin=lower, ymax=upper, x=distance, fill="CI Interval"), alpha=0.3 ) +
  scale_colour_manual("",values="blue")+
  scale_fill_manual("",values="grey12") +
  xlim(0,3) + 
  labs(x="Distance (Miles)", y="Price Effect = b") +
  theme_grey(base_size = 18)
## Warning: Removed 170 rows containing missing values (geom_path).

ggplot(price.effect.a, aes(x=distance, y=mean)) + geom_line(aes(color="Price Effect"), size=1) + 
  geom_ribbon(aes(ymin=lower, ymax=upper, x=distance, fill="CI Interval"), alpha=0.3 ) +
  scale_colour_manual("",values="blue")+
  scale_fill_manual("",values="grey12") +
  xlim(0,10) + 
  labs(x="Distance (Miles)", y="Price Effect = b") +
  theme_grey(base_size = 18)
## Warning: Removed 100 rows containing missing values (geom_path).

# loop for check the change in ramma withs the increase of number of rivals
ols.r.all <- list()
ols.r.big <- list()
ols.r.small <- list()
gamma.mat <- matrix(NA, 20, 3)
for (i in 1:20){
  wp.fld <- names(hou14.wp)[i+159]
  ols.eq <- paste("adr ~ ", wp.fld, " + s_rating + room + hi.sales + cbd + air  + factor(chain)" )
  est.all   <- lm(ols.eq, data=hou14.wp,   na.action = na.exclude)
  est.big   <- lm(ols.eq, data=hou14.h.wp, na.action = na.exclude)
  est.small <- lm(ols.eq, data=hou14.l.wp, na.action = na.exclude)
  ols.r.all[[i]] <- est.all
  ols.r.big[[i]] <- est.big
  ols.r.small[[i]] <- est.small
  gamma.mat[i,1] <- est.all$coefficients[wp.fld]
  gamma.mat[i,2] <- est.big$coefficients[wp.fld]
  gamma.mat[i,3] <- est.small$coefficients[wp.fld]
}
gamma.mat <- as.data.frame(gamma.mat)
colnames(gamma.mat) <- c("all", "high", "low")
n.rival <- c(1:20)
gamma.mat <- cbind(n.rival, gamma.mat)
gamma.mat <- as.data.frame(gamma.mat)
ggplot(gamma.mat) + geom_line(aes(x=n.rival, y=all, color="All"), size=1) + 
  geom_line(aes(x=n.rival, y=high, color="High"), size=1) + 
  geom_line(aes(x=n.rival, y=low, color="Low"), size=1) +
  scale_colour_manual("",values= c("black", "red", "blue" ))+
  xlab("No. of Rivals") + ylab("Gamma")

Reduced Form Analysis

Use the following estimates to define the markets under the two market definition approach * item Distance Limit: 2.5 and 5 miles * item Number of Rivals: 5 and 10 rivals

# data set: hou14, hou14.h, hou14.l
# all hotels (hou14, dist.mat.list.all)
mmc.all1<- get.avmmc.new(mkt.id.fld="qtr", id.brand.fld ="id.brand",
                          id.chain.fld="id.chain",price.fld ="adr", 
                          q.fld = "room.sold",
                          revpar.fld ="revpar", rating.fld = "s_rating", 
                          room.fld = "room", lat.fld="lat", lon.fld="lon", 
                          dist.limit = 2.5, dist.mat=dist.mat.list.all, 
                          data =hou14)
## Warning in brand.mkt * dum.hotel.incl[i, ]: longer object length is not a
## multiple of shorter object length
## Market id = 1
## Warning in brand.mkt * dum.hotel.incl[i, ]: longer object length is not a
## multiple of shorter object length
## Market id = 2
## Warning in brand.mkt * dum.hotel.incl[i, ]: longer object length is not a
## multiple of shorter object length
## Market id = 3
## Warning in brand.mkt * dum.hotel.incl[i, ]: longer object length is not a
## multiple of shorter object length
## Market id = 4
mmc.all2<- get.avmmc.new(mkt.id.fld="qtr", id.brand.fld ="id.brand",
                          id.chain.fld="id.chain",price.fld ="adr", 
                          q.fld = "room.sold",
                          revpar.fld ="revpar", rating.fld = "s_rating", 
                          room.fld = "room", lat.fld="lat", lon.fld="lon", 
                          dist.limit = 5, dist.mat=dist.mat.list.all, data =hou14)
## Warning in brand.mkt * dum.hotel.incl[i, ]: longer object length is not a
## multiple of shorter object length
## Market id = 1
## Warning in brand.mkt * dum.hotel.incl[i, ]: longer object length is not a
## multiple of shorter object length
## Market id = 2
## Warning in brand.mkt * dum.hotel.incl[i, ]: longer object length is not a
## multiple of shorter object length
## Market id = 3
## Warning in brand.mkt * dum.hotel.incl[i, ]: longer object length is not a
## multiple of shorter object length
## Market id = 4
hou14.all1 <- hou14

for(i in names(mmc.all1)){
  hou14.all1[, i] <- unlist(mmc.all1[[i]])
}

hou14.all2 <- hou14 


for(i in names(mmc.all2)){
  hou14.all2[, i] <- unlist(mmc.all2[[i]])
}


# regression 
y.var    <- c("adr")
inst.var <- c("rival.dist", "sum.rating", "n.same.brand", "n.same.chain", "n.brand.city", "n.chain.city")
# model 1
x.var    <- c("avmmc", "hi.sales","s_rating", "cbd","air", "factor(chain)")
endog.var <- c("avmmc")

est.all1 <- get.ols.iv.est(x.var.fld = x.var, y.var.fld=y.var, 
                          data = hou14.all1[hou14.all1$id.brand>1, , drop=F],
                          endog.var.fld = endog.var, inst.var.fld = inst.var,
                          model="both")
## Loading required package: AER
## Loading required package: car
## Loading required package: carData
## 
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
## 
##     recode
## Loading required package: lmtest
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: sandwich
## Loading required package: survival
## 
## =======================================================================
##                                           Dependent variable:          
##                                 ---------------------------------------
##                                                   adr                  
##                                            OLS             instrumental
##                                                              variable  
##                                            (1)                 (2)     
## -----------------------------------------------------------------------
## avmmc                                    0.159***            0.138***  
##                                          (0.037)             (0.051)   
##                                                                        
## hi.sales                                -46.335***          -44.654*** 
##                                          (12.932)            (13.223)  
##                                                                        
## s_rating                                33.431***           33.340***  
##                                          (1.437)             (1.445)   
##                                                                        
## cbd                                     31.493***           31.234***  
##                                          (3.423)             (3.450)   
##                                                                        
## air                                     -17.537***          -17.432*** 
##                                          (3.358)             (3.363)   
##                                                                        
## factor(chain)2                           7.811***            7.614***  
##                                          (2.821)             (2.840)   
##                                                                        
## factor(chain)3                          -14.227***          -14.404*** 
##                                          (2.561)             (2.578)   
##                                                                        
## factor(chain)4                          -43.256***          -43.924*** 
##                                          (3.222)             (3.403)   
##                                                                        
## factor(chain)5                          -31.851***          -32.300*** 
##                                          (2.875)             (2.968)   
##                                                                        
## factor(chain)7                          -16.091***          -16.947*** 
##                                          (5.620)             (5.792)   
##                                                                        
## factor(chain)11                         -49.410***          -49.728*** 
##                                          (4.495)             (4.525)   
##                                                                        
## factor(chain)12                         -24.076***          -23.952*** 
##                                          (4.369)             (4.375)   
##                                                                        
## factor(chain)13                         -51.182***          -52.286*** 
##                                          (8.620)             (8.809)   
##                                                                        
## factor(chain)14                         -55.142***          -56.174*** 
##                                          (8.482)             (8.649)   
##                                                                        
## factor(chain)15                         -32.232***          -32.783*** 
##                                          (6.978)             (7.037)   
##                                                                        
## factor(chain)16                           3.833               3.163    
##                                          (4.170)             (4.312)   
##                                                                        
## factor(chain)17                         -49.801***          -50.112*** 
##                                          (3.571)             (3.608)   
##                                                                        
## factor(chain)18                         130.201***          129.175*** 
##                                          (11.770)            (11.891)  
##                                                                        
## factor(chain)19                         173.826***          173.320*** 
##                                          (23.327)            (23.345)  
##                                                                        
## factor(chain)22                         -65.300***          -66.064*** 
##                                          (4.682)             (4.847)   
##                                                                        
## factor(chain)23                         -26.982***          -26.474*** 
##                                          (3.588)             (3.683)   
##                                                                        
## factor(chain)24                         -51.270***          -51.800*** 
##                                          (4.489)             (4.572)   
##                                                                        
## factor(chain)26                          -15.995*            -16.473*  
##                                          (8.544)             (8.581)   
##                                                                        
## factor(chain)27                         -49.137***          -49.626*** 
##                                          (5.573)             (5.631)   
##                                                                        
## factor(chain)28                         -24.454**           -25.304**  
##                                          (11.813)            (11.896)  
##                                                                        
## factor(chain)29                         -47.486***          -48.474*** 
##                                          (8.574)             (8.726)   
##                                                                        
## factor(chain)30                         -67.055***          -67.884*** 
##                                          (7.020)             (7.151)   
##                                                                        
## factor(chain)40                         -15.997***          -16.669*** 
##                                          (3.433)             (3.605)   
##                                                                        
## Constant                                30.298***           31.443***  
##                                          (5.253)             (5.578)   
##                                                                        
## -----------------------------------------------------------------------
## Observations                              1,141               1,141    
## R2                                        0.788               0.788    
## Adjusted R2                               0.783               0.783    
## Residual Std. Error (df = 1112)           22.982              22.986   
## F Statistic                     147.963*** (df = 28; 1112)             
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
est.all2 <- get.ols.iv.est(x.var.fld = x.var, y.var.fld=y.var, 
                          data = hou14.all2[hou14.all2$id.brand>1, , drop=F],
                          endog.var.fld = endog.var, inst.var.fld = inst.var,
                          model="both")
## 
## =======================================================================
##                                           Dependent variable:          
##                                 ---------------------------------------
##                                                   adr                  
##                                            OLS             instrumental
##                                                              variable  
##                                            (1)                 (2)     
## -----------------------------------------------------------------------
## avmmc                                    0.090***            0.063**   
##                                          (0.023)             (0.029)   
##                                                                        
## hi.sales                               -166.721***         -154.404*** 
##                                          (23.271)            (24.590)  
##                                                                        
## s_rating                                32.483***           32.295***  
##                                          (1.430)             (1.436)   
##                                                                        
## cbd                                     29.964***           29.474***  
##                                          (3.325)             (3.342)   
##                                                                        
## air                                     -14.453***          -13.987*** 
##                                          (3.362)             (3.377)   
##                                                                        
## factor(chain)2                           7.201***            6.952**   
##                                          (2.773)             (2.779)   
##                                                                        
## factor(chain)3                          -16.944***          -16.912*** 
##                                          (2.523)             (2.525)   
##                                                                        
## factor(chain)4                          -43.761***          -44.807*** 
##                                          (3.103)             (3.177)   
##                                                                        
## factor(chain)5                          -33.069***          -33.870*** 
##                                          (2.821)             (2.869)   
##                                                                        
## factor(chain)7                          -18.327***          -19.711*** 
##                                          (5.485)             (5.560)   
##                                                                        
## factor(chain)11                         -47.148***          -48.257*** 
##                                          (4.511)             (4.570)   
##                                                                        
## factor(chain)12                         -24.716***          -24.526*** 
##                                          (4.320)             (4.324)   
##                                                                        
## factor(chain)13                         -54.834***          -56.824*** 
##                                          (8.477)             (8.578)   
##                                                                        
## factor(chain)14                         -56.186***          -58.202*** 
##                                          (8.371)             (8.476)   
##                                                                        
## factor(chain)15                         -33.824***          -34.671*** 
##                                          (6.865)             (6.891)   
##                                                                        
## factor(chain)16                           0.950               -0.181   
##                                          (4.035)             (4.102)   
##                                                                        
## factor(chain)17                         -51.597***          -52.336*** 
##                                          (3.563)             (3.596)   
##                                                                        
## factor(chain)18                         128.882***          126.933*** 
##                                          (11.618)            (11.693)  
##                                                                        
## factor(chain)19                         173.932***          173.124*** 
##                                          (23.056)            (23.077)  
##                                                                        
## factor(chain)22                         -68.422***          -69.509*** 
##                                          (4.490)             (4.547)   
##                                                                        
## factor(chain)23                         -26.637***          -25.947*** 
##                                          (3.492)             (3.523)   
##                                                                        
## factor(chain)24                         -52.475***          -53.598*** 
##                                          (4.448)             (4.509)   
##                                                                        
## factor(chain)26                          -16.074*           -16.991**  
##                                          (8.443)             (8.469)   
##                                                                        
## factor(chain)27                         -49.722***          -50.581*** 
##                                          (5.489)             (5.520)   
##                                                                        
## factor(chain)28                         -27.099**           -28.552**  
##                                          (11.644)            (11.689)  
##                                                                        
## factor(chain)29                         -52.787***          -54.124*** 
##                                          (8.391)             (8.440)   
##                                                                        
## factor(chain)30                         -70.013***          -71.056*** 
##                                          (6.847)             (6.884)   
##                                                                        
## factor(chain)40                         -17.387***          -18.664*** 
##                                          (3.348)             (3.449)   
##                                                                        
## Constant                                38.936***           40.843***  
##                                          (5.102)             (5.249)   
##                                                                        
## -----------------------------------------------------------------------
## Observations                              1,141               1,141    
## R2                                        0.793               0.793    
## Adjusted R2                               0.788               0.788    
## Residual Std. Error (df = 1112)           22.722              22.736   
## F Statistic                     152.287*** (df = 28; 1112)             
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
avmmc.all.knn1 <- get.avmmc.knn(mkt.id.fld ="qtr", id.brand.fld="id.brand", 
                            id.chain.fld ="id.chain",price.fld ="adr", 
                            ocu.fld ="ocu", 
                            room.fld ="room", rating.fld ="s_rating", 
                            lat.fld="lat", lon.fld="lon", knn =5, 
                            data = hou14)
## Loading required package: dbscan
avmmc.all.knn2 <- get.avmmc.knn(mkt.id.fld ="qtr", id.brand.fld="id.brand", 
                              id.chain.fld ="id.chain",price.fld ="adr", 
                              ocu.fld ="ocu", 
                              room.fld ="room", rating.fld ="s_rating", 
                              lat.fld="lat", lon.fld="lon", knn =10, 
                              data = hou14)


hou14.all3 <- hou14

for(i in names(avmmc.all.knn1)){
  hou14.all3[,i] <- unlist(avmmc.all.knn1[[i]])
}

hou14.all4 <- hou14

for(i in names(avmmc.all.knn1)){
  hou14.all4[,i] <- unlist(avmmc.all.knn2[[i]])
}


# model 3
x.var    <- c("avmmc.knn", "hi.sales","s_rating", "cbd","air", "factor(chain)")
endog.var <- c("avmmc.knn")

est.all.knn1 <- get.ols.iv.est(x.var.fld = x.var, y.var.fld=y.var, 
                          data = hou14.all3[hou14.all3$id.brand>1, , drop=F],
                          endog.var.fld = endog.var, inst.var.fld = inst.var,
                          model="both")
## 
## =======================================================================
##                                           Dependent variable:          
##                                 ---------------------------------------
##                                                   adr                  
##                                            OLS             instrumental
##                                                              variable  
##                                            (1)                 (2)     
## -----------------------------------------------------------------------
## avmmc.knn                                 -0.025              0.624*   
##                                          (0.155)             (0.321)   
##                                                                        
## hi.sales                                -27.077**           -27.852**  
##                                          (10.992)            (11.083)  
##                                                                        
## s_rating                                33.216***           34.455***  
##                                          (1.463)             (1.569)   
##                                                                        
## cbd                                     30.821***           31.918***  
##                                          (3.347)             (3.406)   
##                                                                        
## air                                     -16.414***          -16.387*** 
##                                          (3.374)             (3.401)   
##                                                                        
## factor(chain)2                           6.255**             6.218**   
##                                          (2.824)             (2.846)   
##                                                                        
## factor(chain)3                          -15.145***          -15.104*** 
##                                          (2.570)             (2.590)   
##                                                                        
## factor(chain)4                          -47.426***          -45.453*** 
##                                          (3.081)             (3.220)   
##                                                                        
## factor(chain)5                          -34.728***          -32.845*** 
##                                          (2.836)             (2.973)   
##                                                                        
## factor(chain)7                          -22.850***          -20.072*** 
##                                          (5.508)             (5.680)   
##                                                                        
## factor(chain)11                         -50.042***          -52.995*** 
##                                          (4.626)             (4.834)   
##                                                                        
## factor(chain)12                         -22.794***          -23.918*** 
##                                          (4.414)             (4.475)   
##                                                                        
## factor(chain)13                         -60.751***          -57.047*** 
##                                          (8.523)             (8.738)   
##                                                                        
## factor(chain)14                         -62.403***          -58.717*** 
##                                          (8.409)             (8.624)   
##                                                                        
## factor(chain)15                         -34.996***          -32.668*** 
##                                          (6.987)             (7.114)   
##                                                                        
## factor(chain)16                           -1.346              -0.008   
##                                          (4.053)             (4.125)   
##                                                                        
## factor(chain)17                         -51.977***          -50.640*** 
##                                          (3.571)             (3.646)   
##                                                                        
## factor(chain)18                         123.350***          126.132*** 
##                                          (11.771)            (11.924)  
##                                                                        
## factor(chain)19                         168.967***          169.047*** 
##                                          (23.512)            (23.697)  
##                                                                        
## factor(chain)22                         -73.113***          -73.595*** 
##                                          (4.488)             (4.528)   
##                                                                        
## factor(chain)23                         -23.056***          -26.646*** 
##                                          (3.612)             (3.958)   
##                                                                        
## factor(chain)24                         -54.760***          -51.738*** 
##                                          (4.484)             (4.705)   
##                                                                        
## factor(chain)26                         -19.980**           -18.609**  
##                                          (8.585)             (8.673)   
##                                                                        
## factor(chain)27                         -52.101***          -48.335*** 
##                                          (5.623)             (5.897)   
##                                                                        
## factor(chain)28                         -29.484**           -28.091**  
##                                          (11.810)            (11.918)  
##                                                                        
## factor(chain)29                         -53.618***          -49.110*** 
##                                          (8.566)             (8.851)   
##                                                                        
## factor(chain)30                         -72.728***          -69.492*** 
##                                          (6.969)             (7.162)   
##                                                                        
## factor(chain)40                         -22.131***          -22.676*** 
##                                          (3.237)             (3.270)   
##                                                                        
## Constant                                40.527***           33.312***  
##                                          (5.485)             (6.348)   
##                                                                        
## -----------------------------------------------------------------------
## Observations                              1,141               1,141    
## R2                                        0.785               0.781    
## Adjusted R2                               0.779               0.776    
## Residual Std. Error (df = 1112)           23.184              23.367   
## F Statistic                     144.708*** (df = 28; 1112)             
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
est.all.knn2 <- get.ols.iv.est(x.var.fld = x.var, y.var.fld=y.var, 
                          data = hou14.all4[hou14.all4$id.brand>1, , drop=F],
                          endog.var.fld = endog.var, inst.var.fld = inst.var,
                          model="both")
## 
## =======================================================================
##                                           Dependent variable:          
##                                 ---------------------------------------
##                                                   adr                  
##                                            OLS             instrumental
##                                                              variable  
##                                            (1)                 (2)     
## -----------------------------------------------------------------------
## avmmc.knn                                0.172**             0.438***  
##                                          (0.079)             (0.118)   
##                                                                        
## hi.sales                                -75.880***          -78.408*** 
##                                          (13.982)            (14.077)  
##                                                                        
## s_rating                                33.540***           34.298***  
##                                          (1.434)             (1.462)   
##                                                                        
## cbd                                     31.046***           32.551***  
##                                          (3.321)             (3.374)   
##                                                                        
## air                                     -13.780***          -12.850*** 
##                                          (3.352)             (3.383)   
##                                                                        
## factor(chain)2                           6.710**             7.477***  
##                                          (2.797)             (2.822)   
##                                                                        
## factor(chain)3                          -15.811***          -15.478*** 
##                                          (2.538)             (2.553)   
##                                                                        
## factor(chain)4                          -46.575***          -44.028*** 
##                                          (3.092)             (3.217)   
##                                                                        
## factor(chain)5                          -33.595***          -31.599*** 
##                                          (2.824)             (2.912)   
##                                                                        
## factor(chain)7                          -19.473***          -15.365*** 
##                                          (5.542)             (5.729)   
##                                                                        
## factor(chain)11                         -51.828***          -51.792*** 
##                                          (4.445)             (4.467)   
##                                                                        
## factor(chain)12                         -26.082***          -28.570*** 
##                                          (4.419)             (4.515)   
##                                                                        
## factor(chain)13                         -59.670***          -54.452*** 
##                                          (8.537)             (8.747)   
##                                                                        
## factor(chain)14                         -58.144***          -53.372*** 
##                                          (8.389)             (8.574)   
##                                                                        
## factor(chain)15                         -34.406***          -30.991*** 
##                                          (6.960)             (7.083)   
##                                                                        
## factor(chain)16                           -0.917              1.692    
##                                          (4.029)             (4.138)   
##                                                                        
## factor(chain)17                         -50.470***          -49.923*** 
##                                          (3.513)             (3.535)   
##                                                                        
## factor(chain)18                         125.651***          129.912*** 
##                                          (11.668)            (11.808)  
##                                                                        
## factor(chain)19                         169.151***          171.036*** 
##                                          (23.242)            (23.367)  
##                                                                        
## factor(chain)22                         -73.375***          -71.663*** 
##                                          (4.472)             (4.529)   
##                                                                        
## factor(chain)23                         -25.604***          -29.228*** 
##                                          (3.632)             (3.837)   
##                                                                        
## factor(chain)24                         -50.791***          -48.264*** 
##                                          (4.456)             (4.554)   
##                                                                        
## factor(chain)26                         -18.984**            -16.007*  
##                                          (8.527)             (8.625)   
##                                                                        
## factor(chain)27                         -48.955***          -46.215*** 
##                                          (5.552)             (5.651)   
##                                                                        
## factor(chain)28                         -29.143**           -25.482**  
##                                          (11.725)            (11.845)  
##                                                                        
## factor(chain)29                         -40.588***          -35.611*** 
##                                          (8.761)             (8.953)   
##                                                                        
## factor(chain)30                         -72.530***          -68.181*** 
##                                          (6.988)             (7.165)   
##                                                                        
## factor(chain)40                         -18.292***          -15.976*** 
##                                          (3.298)             (3.399)   
##                                                                        
## Constant                                41.550***           34.660***  
##                                          (5.441)             (5.912)   
##                                                                        
## -----------------------------------------------------------------------
## Observations                              1,141               1,141    
## R2                                        0.790               0.788    
## Adjusted R2                               0.784               0.782    
## Residual Std. Error (df = 1112)           22.910              23.025   
## F Statistic                     149.144*** (df = 28; 1112)             
## =======================================================================
## Note:                                       *p<0.1; **p<0.05; ***p<0.01
# hotels with high (hou14.h, dist.mat.list.high)
mmc.high1<- get.avmmc.new(mkt.id.fld="qtr", id.brand.fld ="id.brand",
                          id.chain.fld="id.chain",price.fld ="adr", 
                          q.fld = "room.sold",
                          revpar.fld ="revpar", rating.fld = "s_rating", 
                          room.fld = "room", lat.fld="lat", lon.fld="lon", 
                          dist.limit = 2.5, dist.mat=dist.mat.high.list, data =
                          hou14.h)
## Market id = 1 
## Market id = 2 
## Market id = 3
## Warning in brand.mkt * dum.hotel.incl[i, ]: longer object length is not a
## multiple of shorter object length
## Market id = 4
mmc.high2<- get.avmmc.new(mkt.id.fld="qtr", id.brand.fld ="id.brand",
                          id.chain.fld="id.chain",price.fld ="adr", 
                          q.fld = "room.sold",
                          revpar.fld ="revpar", rating.fld = "s_rating", 
                          room.fld = "room", lat.fld="lat", lon.fld="lon", 
                          dist.limit = 5, dist.mat=dist.mat.high.list, data =
                          hou14.h)
## Market id = 1 
## Market id = 2 
## Market id = 3
## Warning in brand.mkt * dum.hotel.incl[i, ]: longer object length is not a
## multiple of shorter object length
## Market id = 4
hou14.high1 <- hou14.h

for(i in names(mmc.high1)){
  hou14.high1[, i] <- unlist(mmc.high1[[i]])
}

hou14.high2 <- hou14.h


for(i in names(mmc.high2)){
  hou14.high2[, i] <- unlist(mmc.high2[[i]])
}


# regression 
y.var    <- c("adr")
inst.var <- c("rival.dist", "sum.rating", "n.same.brand", "n.same.chain", "n.brand.city", "n.chain.city")
# model 1
x.var    <- c("avmmc", "hi.sales","s_rating", "cbd","air", "factor(chain)")
endog.var <- c("avmmc")

est.high1 <- get.ols.iv.est(x.var.fld = x.var, y.var.fld=y.var, 
                          data = hou14.high1[hou14.high1$id.brand>1, , drop=F],
                          endog.var.fld = endog.var, inst.var.fld = inst.var,
                          model="both")
## 
## ====================================================================
##                                         Dependent variable:         
##                                -------------------------------------
##                                                 adr                 
##                                          OLS            instrumental
##                                                           variable  
##                                          (1)                (2)     
## --------------------------------------------------------------------
## avmmc                                   0.010              -0.687   
##                                        (0.321)            (0.604)   
##                                                                     
## hi.sales                              -40.987***         -40.096*** 
##                                        (8.538)            (8.667)   
##                                                                     
## s_rating                              47.929***          47.912***  
##                                        (7.605)            (7.697)   
##                                                                     
## cbd                                     5.416              3.335    
##                                        (6.018)            (6.278)   
##                                                                     
## air                                   -42.461**           -26.802   
##                                        (16.511)           (20.249)  
##                                                                     
## factor(chain)2                         15.663**           12.765*   
##                                        (6.288)            (6.707)   
##                                                                     
## factor(chain)3                        -18.252**          -24.604*** 
##                                        (8.002)            (9.334)   
##                                                                     
## factor(chain)4                        -38.529***         -44.493*** 
##                                        (11.549)           (12.475)  
##                                                                     
## factor(chain)7                         -22.076*          -29.112**  
##                                        (11.735)           (12.941)  
##                                                                     
## factor(chain)14                       -83.125***         -90.246*** 
##                                        (15.568)           (16.593)  
##                                                                     
## factor(chain)16                        15.360*             9.798    
##                                        (7.847)            (8.921)   
##                                                                     
## factor(chain)17                       -98.000***        -105.046*** 
##                                        (15.461)           (16.474)  
##                                                                     
## factor(chain)18                       126.615***         119.648*** 
##                                        (15.668)           (16.655)  
##                                                                     
## factor(chain)19                       174.767***         169.976*** 
##                                        (30.071)           (30.637)  
##                                                                     
## factor(chain)26                        -11.793            -16.063   
##                                        (11.610)           (12.158)  
##                                                                     
## factor(chain)28                       -34.917**          -41.806**  
##                                        (15.581)           (16.553)  
##                                                                     
## factor(chain)40                       27.819***           21.666**  
##                                        (8.806)            (9.982)   
##                                                                     
## Constant                               -16.533             -9.634   
##                                        (30.020)           (30.800)  
##                                                                     
## --------------------------------------------------------------------
## Observations                             211                211     
## R2                                      0.716              0.709    
## Adjusted R2                             0.691              0.683    
## Residual Std. Error (df = 193)          28.488             28.835   
## F Statistic                    28.623*** (df = 17; 193)             
## ====================================================================
## Note:                                    *p<0.1; **p<0.05; ***p<0.01
est.high2 <- get.ols.iv.est(x.var.fld = x.var, y.var.fld=y.var, 
                          data = hou14.high2[hou14.high2$id.brand>1, , drop=F],
                          endog.var.fld = endog.var, inst.var.fld = inst.var,
                          model="both")
## 
## ====================================================================
##                                         Dependent variable:         
##                                -------------------------------------
##                                                 adr                 
##                                          OLS            instrumental
##                                                           variable  
##                                          (1)                (2)     
## --------------------------------------------------------------------
## avmmc                                   -0.356             1.620*   
##                                        (0.428)            (0.835)   
##                                                                     
## hi.sales                               -56.363          -166.581*** 
##                                        (35.654)           (54.282)  
##                                                                     
## s_rating                              47.863***          44.541***  
##                                        (8.057)            (8.573)   
##                                                                     
## cbd                                    10.783*            14.172**  
##                                        (5.974)            (6.410)   
##                                                                     
## air                                    -16.714            -24.760   
##                                        (18.319)           (19.517)  
##                                                                     
## factor(chain)2                          9.229             13.439*   
##                                        (6.606)            (7.121)   
##                                                                     
## factor(chain)3                        -27.738***          -16.153*  
##                                        (8.293)            (9.662)   
##                                                                     
## factor(chain)4                        -37.618***         -41.517*** 
##                                        (11.700)           (12.408)  
##                                                                     
## factor(chain)7                         -23.890*            -3.394   
##                                        (12.471)           (15.027)  
##                                                                     
## factor(chain)14                       -85.235***         -60.007*** 
##                                        (16.655)           (19.710)  
##                                                                     
## factor(chain)16                         4.216              13.273   
##                                        (7.903)            (8.929)   
##                                                                     
## factor(chain)17                      -100.816***         -81.313*** 
##                                        (16.202)           (18.428)  
##                                                                     
## factor(chain)18                       125.369***         138.470*** 
##                                        (16.239)           (17.736)  
##                                                                     
## factor(chain)19                       169.401***         179.950*** 
##                                        (31.090)           (32.979)  
##                                                                     
## factor(chain)26                        -14.784             -7.781   
##                                        (11.936)           (12.823)  
##                                                                     
## factor(chain)28                       -35.099**           -24.675   
##                                        (16.058)           (17.324)  
##                                                                     
## factor(chain)40                       24.522***          35.002***  
##                                        (9.066)            (10.255)  
##                                                                     
## Constant                               -16.184             -8.496   
##                                        (32.331)           (34.182)  
##                                                                     
## --------------------------------------------------------------------
## Observations                             211                211     
## R2                                      0.696              0.663    
## Adjusted R2                             0.669              0.633    
## Residual Std. Error (df = 193)          29.467             31.055   
## F Statistic                    26.011*** (df = 17; 193)             
## ====================================================================
## Note:                                    *p<0.1; **p<0.05; ***p<0.01
avmmc.high.knn1 <- get.avmmc.knn(mkt.id.fld ="qtr", id.brand.fld="id.brand", 
                            id.chain.fld ="id.chain",price.fld ="adr", 
                            ocu.fld ="ocu", 
                            room.fld ="room", rating.fld ="s_rating", 
                            lat.fld="lat", lon.fld="lon", knn =5, 
                            data = hou14.h)

avmmc.high.knn2 <- get.avmmc.knn(mkt.id.fld ="qtr", id.brand.fld="id.brand", 
                              id.chain.fld ="id.chain",price.fld ="adr", 
                              ocu.fld ="ocu", 
                              room.fld ="room", rating.fld ="s_rating", 
                              lat.fld="lat", lon.fld="lon", knn =10, 
                              data = hou14.h)


hou14.high3 <- hou14.h
for(i in names(avmmc.high.knn1)){
  hou14.high3[,i] <- unlist(avmmc.high.knn1[[i]])
}

hou14.high4 <- hou14.h
for(i in names(avmmc.high.knn1)){
  hou14.high4[,i] <- unlist(avmmc.high.knn2[[i]])
}


# model 3
x.var    <- c("avmmc.knn", "hi.sales","s_rating", "cbd","air", "factor(chain)")
endog.var <- c("avmmc.knn")

est.high.knn1 <- get.ols.iv.est(x.var.fld = x.var, y.var.fld=y.var, 
                          data = hou14.high3[hou14.high3$id.brand>1, , drop=F],
                          endog.var.fld = endog.var, inst.var.fld = inst.var,
                          model="both")
## 
## ====================================================================
##                                         Dependent variable:         
##                                -------------------------------------
##                                                 adr                 
##                                          OLS            instrumental
##                                                           variable  
##                                          (1)                (2)     
## --------------------------------------------------------------------
## avmmc.knn                               0.433              -1.245   
##                                        (0.723)            (1.079)   
##                                                                     
## hi.sales                                67.892             71.274   
##                                        (73.977)           (75.021)  
##                                                                     
## s_rating                              52.088***          57.578***  
##                                        (8.339)            (8.843)   
##                                                                     
## cbd                                   15.861***           13.600**  
##                                        (5.967)            (6.143)   
##                                                                     
## air                                   -52.488***         -45.787*** 
##                                        (16.549)           (17.074)  
##                                                                     
## factor(chain)2                         15.132**           12.100*   
##                                        (6.609)            (6.852)   
##                                                                     
## factor(chain)3                        -18.641**          -24.684*** 
##                                        (8.268)            (8.855)   
##                                                                     
## factor(chain)4                        -30.552**          -39.489*** 
##                                        (12.421)           (13.281)  
##                                                                     
## factor(chain)7                         -16.528           -28.420**  
##                                        (12.966)           (14.294)  
##                                                                     
## factor(chain)14                       -77.085***         -86.134*** 
##                                        (16.587)           (17.351)  
##                                                                     
## factor(chain)16                         10.375             5.684    
##                                        (7.974)            (8.382)   
##                                                                     
## factor(chain)17                       -92.591***        -102.765*** 
##                                        (16.524)           (17.428)  
##                                                                     
## factor(chain)18                       133.963***         128.366*** 
##                                        (16.630)           (17.067)  
##                                                                     
## factor(chain)19                       175.574***         161.627*** 
##                                        (32.301)           (33.404)  
##                                                                     
## factor(chain)26                         -8.788            -18.649   
##                                        (12.860)           (13.844)  
##                                                                     
## factor(chain)28                        -20.408            -28.791*  
##                                        (16.506)           (17.196)  
##                                                                     
## factor(chain)40                       35.398***           24.772**  
##                                        (9.931)            (11.249)  
##                                                                     
## Constant                               -63.123*          -73.941**  
##                                        (36.317)           (37.174)  
##                                                                     
## --------------------------------------------------------------------
## Observations                             211                211     
## R2                                      0.684              0.675    
## Adjusted R2                             0.656              0.647    
## Residual Std. Error (df = 193)          30.049             30.466   
## F Statistic                    24.579*** (df = 17; 193)             
## ====================================================================
## Note:                                    *p<0.1; **p<0.05; ***p<0.01
est.high.knn2 <- get.ols.iv.est(x.var.fld = x.var, y.var.fld=y.var, 
                          data = hou14.high4[hou14.high4$id.brand>1, , drop=F],
                          endog.var.fld = endog.var, inst.var.fld = inst.var,
                          model="both")
## 
## ====================================================================
##                                         Dependent variable:         
##                                -------------------------------------
##                                                 adr                 
##                                          OLS            instrumental
##                                                           variable  
##                                          (1)                (2)     
## --------------------------------------------------------------------
## avmmc.knn                               -0.737            -1.394**  
##                                        (0.475)            (0.612)   
##                                                                     
## hi.sales                              410.717***         492.831*** 
##                                       (139.145)          (147.750)  
##                                                                     
## s_rating                              57.146***          61.955***  
##                                        (8.550)            (9.035)   
##                                                                     
## cbd                                   19.126***          18.977***  
##                                        (5.815)            (5.845)   
##                                                                     
## air                                   -58.649***         -60.357*** 
##                                        (15.916)           (16.026)  
##                                                                     
## factor(chain)2                         13.521**           13.657**  
##                                        (6.371)            (6.403)   
##                                                                     
## factor(chain)3                        -21.430***         -22.911*** 
##                                        (7.774)            (7.860)   
##                                                                     
## factor(chain)4                        -32.851***         -36.415*** 
##                                        (11.991)           (12.227)  
##                                                                     
## factor(chain)7                        -32.095**          -40.393*** 
##                                        (13.203)           (14.117)  
##                                                                     
## factor(chain)14                       -84.029***         -89.048*** 
##                                        (16.184)           (16.523)  
##                                                                     
## factor(chain)16                         8.473              6.766    
##                                        (7.680)            (7.781)   
##                                                                     
## factor(chain)17                      -100.922***        -108.435*** 
##                                        (16.580)           (17.225)  
##                                                                     
## factor(chain)18                       116.221***         109.179*** 
##                                        (17.187)           (17.750)  
##                                                                     
## factor(chain)19                       164.638***         154.812*** 
##                                        (31.912)           (32.574)  
##                                                                     
## factor(chain)26                        -13.351            -17.755   
##                                        (12.368)           (12.690)  
##                                                                     
## factor(chain)28                        -23.298            -26.707   
##                                        (15.961)           (16.162)  
##                                                                     
## factor(chain)40                        23.727**            16.820   
##                                        (9.935)            (10.760)  
##                                                                     
## Constant                             -107.247***        -128.352*** 
##                                        (36.508)           (38.684)  
##                                                                     
## --------------------------------------------------------------------
## Observations                             211                211     
## R2                                      0.696              0.693    
## Adjusted R2                             0.669              0.666    
## Residual Std. Error (df = 193)          29.478             29.624   
## F Statistic                    25.984*** (df = 17; 193)             
## ====================================================================
## Note:                                    *p<0.1; **p<0.05; ***p<0.01
# hotels with low (hou14.l, dist.mat.list.high)
mmc.low1<- get.avmmc.new(mkt.id.fld="qtr", id.brand.fld ="id.brand",
                          id.chain.fld="id.chain",price.fld ="adr", 
                          q.fld = "room.sold",
                          revpar.fld ="revpar", rating.fld = "s_rating", 
                          room.fld = "room", lat.fld="lat", lon.fld="lon", 
                          dist.limit = 2.5, dist.mat=dist.mat.low.list, data =
                          hou14.l)
## Warning in brand.mkt * dum.hotel.incl[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Market id = 1
## Warning in brand.mkt * dum.hotel.incl[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Market id = 2
## Warning in brand.mkt * dum.hotel.incl[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Market id = 3
## Warning in brand.mkt * dum.hotel.incl[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Market id = 4
mmc.low2<- get.avmmc.new(mkt.id.fld="qtr", id.brand.fld ="id.brand",
                          id.chain.fld="id.chain",price.fld ="adr", 
                          q.fld = "room.sold",
                          revpar.fld ="revpar", rating.fld = "s_rating", 
                          room.fld = "room", lat.fld="lat", lon.fld="lon", 
                          dist.limit = 5, dist.mat=dist.mat.low.list, data =
                          hou14.l)
## Warning in brand.mkt * dum.hotel.incl[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Market id = 1
## Warning in brand.mkt * dum.hotel.incl[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Market id = 2
## Warning in brand.mkt * dum.hotel.incl[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Market id = 3
## Warning in brand.mkt * dum.hotel.incl[i, ]: Recycling array of length 1 in array-vector arithmetic is deprecated.
##   Use c() or as.vector() instead.
## Market id = 4
hou14.low1 <- hou14.l

for(i in names(mmc.low1)){
  hou14.low1[, i] <- unlist(mmc.low1[[i]])
}

hou14.low2 <- hou14.l


for(i in names(mmc.low2)){
  hou14.low2[, i] <- unlist(mmc.low2[[i]])
}


# regression 
y.var    <- c("adr")
inst.var <- c("rival.dist", "sum.rating", "n.same.brand", "n.same.chain", "n.brand.city", "n.chain.city")
# model 1
x.var    <- c("avmmc", "hi.sales","s_rating", "cbd","air", "factor(chain)")
endog.var <- c("avmmc")

est.low1 <- get.ols.iv.est(x.var.fld = x.var, y.var.fld=y.var, 
                          data = hou14.low1[hou14.low1$id.brand>1, , drop=F],
                          endog.var.fld = endog.var, inst.var.fld = inst.var,
                          model="both")
## 
## =====================================================================
##                                         Dependent variable:          
##                                --------------------------------------
##                                                 adr                  
##                                           OLS            instrumental
##                                                            variable  
##                                           (1)                (2)     
## ---------------------------------------------------------------------
## avmmc                                  0.318***            0.493***  
##                                         (0.036)            (0.057)   
##                                                                      
## hi.sales                                -2.450             -19.827*  
##                                         (9.374)            (10.450)  
##                                                                      
## s_rating                               17.761***          17.551***  
##                                         (2.110)            (2.138)   
##                                                                      
## cbd                                    40.330***          39.756***  
##                                         (4.231)            (4.290)   
##                                                                      
## air                                   -10.516***          -10.659*** 
##                                         (2.661)            (2.697)   
##                                                                      
## factor(chain)2                         15.567***          16.516***  
##                                         (2.923)            (2.971)   
##                                                                      
## factor(chain)3                        -14.018***          -13.799*** 
##                                         (2.158)            (2.187)   
##                                                                      
## factor(chain)4                        -51.265***          -47.323*** 
##                                         (2.713)            (2.922)   
##                                                                      
## factor(chain)5                        -38.359***          -35.939*** 
##                                         (2.295)            (2.403)   
##                                                                      
## factor(chain)7                         -11.878**            -5.405   
##                                         (5.505)            (5.810)   
##                                                                      
## factor(chain)11                       -63.135***          -61.801*** 
##                                         (3.656)            (3.720)   
##                                                                      
## factor(chain)12                       -33.332***          -35.644*** 
##                                         (3.394)            (3.488)   
##                                                                      
## factor(chain)13                       -61.999***          -54.776*** 
##                                         (6.690)            (7.017)   
##                                                                      
## factor(chain)14                        -22.903**           -15.996*  
##                                         (8.929)            (9.213)   
##                                                                      
## factor(chain)15                       -27.257***          -22.936*** 
##                                         (5.339)            (5.518)   
##                                                                      
## factor(chain)16                         8.295*            14.275***  
##                                         (4.737)            (5.029)   
##                                                                      
## factor(chain)17                       -48.871***          -46.472*** 
##                                         (2.901)            (3.000)   
##                                                                      
## factor(chain)22                       -72.562***          -67.650*** 
##                                         (3.619)            (3.869)   
##                                                                      
## factor(chain)23                       -37.661***          -42.397*** 
##                                         (2.875)            (3.146)   
##                                                                      
## factor(chain)24                       -63.927***          -61.494*** 
##                                         (3.674)            (3.773)   
##                                                                      
## factor(chain)27                       -58.426***          -56.419*** 
##                                         (4.342)            (4.429)   
##                                                                      
## factor(chain)29                       -57.681***          -52.002*** 
##                                         (6.624)            (6.862)   
##                                                                      
## factor(chain)30                       -68.809***          -63.743*** 
##                                         (5.345)            (5.563)   
##                                                                      
## factor(chain)40                       -50.855***          -47.602*** 
##                                         (3.692)            (3.829)   
##                                                                      
## Constant                               65.606***          60.498***  
##                                         (6.219)            (6.430)   
##                                                                      
## ---------------------------------------------------------------------
## Observations                              930                930     
## R2                                       0.808              0.803    
## Adjusted R2                              0.803              0.798    
## Residual Std. Error (df = 905)          17.363              17.595   
## F Statistic                    158.970*** (df = 24; 905)             
## =====================================================================
## Note:                                     *p<0.1; **p<0.05; ***p<0.01
est.low2 <- get.ols.iv.est(x.var.fld = x.var, y.var.fld=y.var, 
                          data = hou14.low2[hou14.low2$id.brand>1, , drop=F],
                          endog.var.fld = endog.var, inst.var.fld = inst.var,
                          model="both")
## 
## =====================================================================
##                                         Dependent variable:          
##                                --------------------------------------
##                                                 adr                  
##                                           OLS            instrumental
##                                                            variable  
##                                           (1)                (2)     
## ---------------------------------------------------------------------
## avmmc                                  0.187***            0.209***  
##                                         (0.025)            (0.031)   
##                                                                      
## hi.sales                              -132.675***        -139.129*** 
##                                        (18.428)            (19.219)  
##                                                                      
## s_rating                               17.173***          17.043***  
##                                         (2.129)            (2.133)   
##                                                                      
## cbd                                    39.491***          39.644***  
##                                         (4.291)            (4.295)   
##                                                                      
## air                                   -12.633***          -12.868*** 
##                                         (2.679)            (2.687)   
##                                                                      
## factor(chain)2                         14.242***          14.211***  
##                                         (2.943)            (2.945)   
##                                                                      
## factor(chain)3                        -17.729***          -18.019*** 
##                                         (2.210)            (2.224)   
##                                                                      
## factor(chain)4                        -54.047***          -53.570*** 
##                                         (2.673)            (2.704)   
##                                                                      
## factor(chain)5                        -39.967***          -39.607*** 
##                                         (2.300)            (2.320)   
##                                                                      
## factor(chain)7                        -16.347***          -15.374*** 
##                                         (5.503)            (5.566)   
##                                                                      
## factor(chain)11                       -62.327***          -61.995*** 
##                                         (3.692)            (3.704)   
##                                                                      
## factor(chain)12                       -33.029***          -33.394*** 
##                                         (3.418)            (3.434)   
##                                                                      
## factor(chain)13                       -65.076***          -63.999*** 
##                                         (6.692)            (6.755)   
##                                                                      
## factor(chain)14                       -25.162***          -23.822*** 
##                                         (9.021)            (9.095)   
##                                                                      
## factor(chain)15                       -30.321***          -29.606*** 
##                                         (5.371)            (5.407)   
##                                                                      
## factor(chain)16                          5.016              5.856    
##                                         (4.714)            (4.768)   
##                                                                      
## factor(chain)17                       -51.905***          -51.489*** 
##                                         (2.931)            (2.953)   
##                                                                      
## factor(chain)22                       -74.777***          -74.237*** 
##                                         (3.540)            (3.570)   
##                                                                      
## factor(chain)23                       -35.191***          -35.852*** 
##                                         (2.841)            (2.896)   
##                                                                      
## factor(chain)24                       -64.862***          -64.346*** 
##                                         (3.718)            (3.744)   
##                                                                      
## factor(chain)27                       -59.852***          -59.495*** 
##                                         (4.368)            (4.380)   
##                                                                      
## factor(chain)29                       -66.241***          -65.702*** 
##                                         (6.617)            (6.635)   
##                                                                      
## factor(chain)30                       -76.484***          -76.030*** 
##                                         (5.317)            (5.333)   
##                                                                      
## factor(chain)40                       -52.303***          -51.964*** 
##                                         (3.668)            (3.681)   
##                                                                      
## Constant                               76.131***          75.455***  
##                                         (6.268)            (6.296)   
##                                                                      
## ---------------------------------------------------------------------
## Observations                              930                930     
## R2                                       0.805              0.805    
## Adjusted R2                              0.800              0.800    
## Residual Std. Error (df = 905)          17.493              17.500   
## F Statistic                    156.048*** (df = 24; 905)             
## =====================================================================
## Note:                                     *p<0.1; **p<0.05; ***p<0.01
avmmc.low.knn1 <- get.avmmc.knn(mkt.id.fld ="qtr", id.brand.fld="id.brand", 
                            id.chain.fld ="id.chain",price.fld ="adr", 
                            ocu.fld ="ocu", 
                            room.fld ="room", rating.fld ="s_rating", 
                            lat.fld="lat", lon.fld="lon", knn =5, 
                            data = hou14.l)

avmmc.low.knn2 <- get.avmmc.knn(mkt.id.fld ="qtr", id.brand.fld="id.brand", 
                              id.chain.fld ="id.chain",price.fld ="adr", 
                              ocu.fld ="ocu", 
                              room.fld ="room", rating.fld ="s_rating", 
                              lat.fld="lat", lon.fld="lon", knn =10, 
                              data = hou14.l)


hou14.low3 <- hou14.l
for(i in names(avmmc.low.knn1)){
  hou14.low3[,i] <- unlist(avmmc.low.knn1[[i]])
}

hou14.low4 <- hou14.l
for(i in names(avmmc.low.knn1)){
  hou14.low4[,i] <- unlist(avmmc.low.knn2[[i]])
}


# model 3
x.var    <- c("avmmc.knn", "hi.sales","s_rating", "cbd","air", "factor(chain)")
endog.var <- c("avmmc.knn")

est.low.knn1 <- get.ols.iv.est(x.var.fld = x.var, y.var.fld=y.var, 
                          data = hou14.low3[hou14.low3$id.brand>1, , drop=F],
                          endog.var.fld = endog.var, inst.var.fld = inst.var,
                          model="both")
## 
## =====================================================================
##                                         Dependent variable:          
##                                --------------------------------------
##                                                 adr                  
##                                           OLS            instrumental
##                                                            variable  
##                                           (1)                (2)     
## ---------------------------------------------------------------------
## avmmc.knn                              0.536***            1.854***  
##                                         (0.118)            (0.260)   
##                                                                      
## hi.sales                                19.378             -16.148   
##                                        (18.319)            (20.488)  
##                                                                      
## s_rating                               20.148***          23.399***  
##                                         (2.214)            (2.429)   
##                                                                      
## cbd                                    39.654***          37.063***  
##                                         (4.377)            (4.692)   
##                                                                      
## air                                   -11.112***          -10.132*** 
##                                         (2.732)            (2.920)   
##                                                                      
## factor(chain)2                         15.411***          18.419***  
##                                         (3.040)            (3.285)   
##                                                                      
## factor(chain)3                        -13.666***          -12.356*** 
##                                         (2.235)            (2.396)   
##                                                                      
## factor(chain)4                        -55.715***          -48.918*** 
##                                         (2.751)            (3.162)   
##                                                                      
## factor(chain)5                        -40.062***          -33.604*** 
##                                         (2.391)            (2.784)   
##                                                                      
## factor(chain)7                        -20.024***           -10.884*  
##                                         (5.599)            (6.180)   
##                                                                      
## factor(chain)11                       -67.280***          -70.595*** 
##                                         (3.809)            (4.105)   
##                                                                      
## factor(chain)12                       -31.041***          -35.179*** 
##                                         (3.503)            (3.805)   
##                                                                      
## factor(chain)13                       -68.989***          -58.327*** 
##                                         (6.821)            (7.508)   
##                                                                      
## factor(chain)14                       -32.551***          -22.195**  
##                                         (9.171)            (9.949)   
##                                                                      
## factor(chain)15                       -32.069***          -24.911*** 
##                                         (5.501)            (5.999)   
##                                                                      
## factor(chain)16                          0.427              7.045    
##                                         (4.783)            (5.230)   
##                                                                      
## factor(chain)17                       -51.788***          -47.997*** 
##                                         (2.992)            (3.259)   
##                                                                      
## factor(chain)22                       -79.174***          -77.557*** 
##                                         (3.579)            (3.830)   
##                                                                      
## factor(chain)23                       -30.811***          -36.143*** 
##                                         (2.846)            (3.174)   
##                                                                      
## factor(chain)24                       -64.574***          -56.902*** 
##                                         (3.875)            (4.342)   
##                                                                      
## factor(chain)27                       -58.265***          -49.612*** 
##                                         (4.571)            (5.101)   
##                                                                      
## factor(chain)29                       -62.840***          -51.993*** 
##                                         (6.862)            (7.558)   
##                                                                      
## factor(chain)30                       -75.143***          -65.550*** 
##                                         (5.490)            (6.088)   
##                                                                      
## factor(chain)40                       -54.698***          -54.655*** 
##                                         (3.778)            (4.032)   
##                                                                      
## Constant                               63.830***          52.264***  
##                                         (7.935)            (8.700)   
##                                                                      
## ---------------------------------------------------------------------
## Observations                              930                930     
## R2                                       0.795              0.766    
## Adjusted R2                              0.789              0.760    
## Residual Std. Error (df = 905)          17.970              19.177   
## F Statistic                    145.901*** (df = 24; 905)             
## =====================================================================
## Note:                                     *p<0.1; **p<0.05; ***p<0.01
est.low.knn2 <- get.ols.iv.est(x.var.fld = x.var, y.var.fld=y.var, 
                          data = hou14.low4[hou14.low4$id.brand>1, , drop=F],
                          endog.var.fld = endog.var, inst.var.fld = inst.var,
                          model="both")
## 
## =====================================================================
##                                         Dependent variable:          
##                                --------------------------------------
##                                                 adr                  
##                                           OLS            instrumental
##                                                            variable  
##                                           (1)                (2)     
## ---------------------------------------------------------------------
## avmmc.knn                              0.280***            0.838***  
##                                         (0.069)            (0.102)   
##                                                                      
## hi.sales                               81.375**             9.409    
##                                        (33.348)            (35.793)  
##                                                                      
## s_rating                               19.181***          21.237***  
##                                         (2.191)            (2.285)   
##                                                                      
## cbd                                    40.791***          40.628***  
##                                         (4.358)            (4.513)   
##                                                                      
## air                                   -10.883***          -8.258***  
##                                         (2.750)            (2.868)   
##                                                                      
## factor(chain)2                         15.353***          16.427***  
##                                         (3.027)            (3.137)   
##                                                                      
## factor(chain)3                        -14.249***          -14.957*** 
##                                         (2.229)            (2.310)   
##                                                                      
## factor(chain)4                        -56.253***          -51.283*** 
##                                         (2.746)            (2.917)   
##                                                                      
## factor(chain)5                        -40.949***          -36.720*** 
##                                         (2.374)            (2.519)   
##                                                                      
## factor(chain)7                        -19.202***            -9.085   
##                                         (5.651)            (6.000)   
##                                                                      
## factor(chain)11                       -66.768***          -68.236*** 
##                                         (3.773)            (3.911)   
##                                                                      
## factor(chain)12                       -32.087***          -38.279*** 
##                                         (3.552)            (3.767)   
##                                                                      
## factor(chain)13                       -67.087***          -56.151*** 
##                                         (6.872)            (7.258)   
##                                                                      
## factor(chain)14                       -29.910***           -18.272*  
##                                         (9.210)            (9.658)   
##                                                                      
## factor(chain)15                       -31.644***          -26.224*** 
##                                         (5.485)            (5.724)   
##                                                                      
## factor(chain)16                          3.104             10.151**  
##                                         (4.805)            (5.061)   
##                                                                      
## factor(chain)17                       -52.578***          -51.835*** 
##                                         (2.956)            (3.063)   
##                                                                      
## factor(chain)22                       -77.562***          -74.075*** 
##                                         (3.596)            (3.751)   
##                                                                      
## factor(chain)23                       -32.053***          -39.821*** 
##                                         (2.962)            (3.232)   
##                                                                      
## factor(chain)24                       -64.802***          -60.205*** 
##                                         (3.826)            (4.007)   
##                                                                      
## factor(chain)27                       -58.976***          -54.069*** 
##                                         (4.512)            (4.716)   
##                                                                      
## factor(chain)29                       -62.945***          -52.418*** 
##                                         (6.853)            (7.229)   
##                                                                      
## factor(chain)30                       -72.982***          -63.715*** 
##                                         (5.536)            (5.859)   
##                                                                      
## factor(chain)40                       -53.576***          -48.396*** 
##                                         (3.791)            (3.983)   
##                                                                      
## Constant                               58.808***          50.941***  
##                                         (7.508)            (7.842)   
##                                                                      
## ---------------------------------------------------------------------
## Observations                              930                930     
## R2                                       0.796              0.781    
## Adjusted R2                              0.790              0.775    
## Residual Std. Error (df = 905)          17.917              18.553   
## F Statistic                    146.988*** (df = 24; 905)             
## =====================================================================
## Note:                                     *p<0.1; **p<0.05; ***p<0.01