0

Trying to perform Logistics Regression:

I converted the variable price to a qualitative variable.

pricecode = (ifelse(Airbnb$price >= 175, "high", "low"))

glm.fits = glm(pricecode["high"] ~ latitude + longitude + number_of_reviews + calculated_host_listings_count + availability_365, data = Airbnb, family = binomial)

summary(glm.fits)

Run code:

pricecode = (ifelse(Airbnb$price >= 175, "high", "low"))

glm.fits = glm(pricecode['high'] ~ latitude + longitude + number_of_reviews + calculated_host_listings_count + availability_365, data = Airbnb, family = binomial)

Error in model.frame.default(formula = pricecode["high"] ~ latitude +  : 
  variable lengths differ (found for 'latitude')
zx8754
  • 52,746
  • 12
  • 114
  • 209
  • 3
    Try just `pricecode~...` in the formula. If that fails make `pricecode` a factor. – dcarlson Dec 02 '20 at 18:21
  • 1
    Yeah - not sure what `pricecode['high']` is trying to achieve, but don't do it. Just `pricecode`. – Gregor Thomas Dec 02 '20 at 18:25
  • It's possible that the OP desires "low" to be the base status so that the coefficients would represent the log-odds of seeing "high" versus "low". In which case the answer is to build the `pricecode` variable as a factor with levels `c("low", "high")`, which is the inverse of the default ordering. – IRTFM Dec 02 '20 at 18:55

0 Answers0