本代码是基于《The influence of the neighbourhood environment on peer-to-peer accommodations: A random forest regression analysis》文章来实现的 ,具体可参考网站https://doi.org/10.1016/j.jhtm.2022.02.028。
本文的附件及文章可在官网中下载。 需要更多资源 qq:1148721210 微信:hongqiang_jiang
引用格式为: Jiang, H.,Mei, L.,Wei, Y., et al. (2022). The influence of the neighbourhood environment on peer-to-peer accommodations: A random forest regression analysis. Journal of Hospitality and Tourism Mangement, 51: 105-118.
Multiple linear regression and Random forest regression
# Use the software RStudio 4.0.5
# -*- coding: UTF-8 -*-
# This code uses All room as an example, other types of Airbnb such as entire home/apt, private room, shared room codes are also used to avoid redundancy and will be omitted from the classification codes.
## Loading packages and data------------------------------------------------------------
library(randomForest)
library(pheatmap)
library(extrafont)
library(corrplot)
library(car)
setwd("C:/Users/Desktop/Airbnb") # Setting up the work path
Data_Airbnb <- read.csv("Airbnb_data.csv", sep = ",") # Reading data
## Multiple linear regression---------------------------------------------------------------
Lm_Airbnb <- lm(Airbnb~c("PopDen", "PGDP", "HPrice", "Distance", "BusDen", "MetroDen", "CaterDen", "ShopDen", "RecrDen"