glebas2 | R Documentation |
A tibble containing a sample of 20 large parcels with different built areas.
glebas2
A tibble with 20 rows and 5 variables:
R: id
Ficha: another id (unused)
VI: sale price
AT: land area, in sq. meters
AC: Built area, in sq. meters
data(glebas2)
fit <- lm(VI ~ log(AT) + AC, data = glebas2)
library(effects)
plot(predictorEffects(fit, residuals = T), id = T,
axes = list(
grid = TRUE,
x = list(rotate=30)
))
powerPlot(fit, axis="inverted", smooth = TRUE, methods = c("lm", "loess"))
# Issue: Influential Points 5 and 10 (see also plot(fit))
# Solution 1 (better to interpret):
fit1 <- update(fit, VI ~ AT + AC, subset = -c(2, 5,10))
plot(predictorEffects(fit1, residuals = T), id = T,
axes = list(
grid = TRUE,
x = list(rotate=30)
))
powerPlot(fit1, axis = "inverted", smooth = TRUE, methods = c("lm", "loess"))
predict(fit1, newdata = list(AT = 9123.50, AC = 2272.47),
interval = 'confidence', level = .80)
# + 30% higher value than predicted with the original fit
# Solution 2 (just to add some nonlinear relationship between the original
variables)
fit2 <- update(fit, sqrt(VI) ~ sqrt(AT) + sqrt(AC), subset = -c(2, 10))
plot(predictorEffects(fit2, residuals = T), id = T,
axes = list(
grid = TRUE,
x = list(rotate=30),
y = list(transform=list(trans=sqrt, inverse=sqr), lab = "VI")
))
powerPlot(fit2, axis = "inverted", smooth = TRUE, methods = c("lm", "loess"),
func="sqrt") # note bias and nonlinearity
predict(fit2, newdata = list(AT = 9123.50, AC = 2272.47),
interval = 'confidence', level = .80)
# Almost 50% higher value than predicted with the original fit
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.