You can use confint() to calculate the 95% confidence interval (CI) for an empty model.
# Get the 95% CI for the empty model of PriceK
empty_model <- lm(PriceK ~ NULL, data = Smallville)
confint(empty_model)
Example of output from running the code above:
Example 2:
You can use confint() to calculate the 95% confidence interval (CI) for a univariate model (a model with a single explanatory variable). If you save the model into an object, you can use the name of the object as the argument for confint(), or you can use the lm() function within the confint() function (to skip saving the model first). You can also adjust the confidence level with the "level =" argument.
# Get the 95% CI for the Neighborhood model of PriceK
neighborhood_model <- lm(PriceK ~ Neighborhood, data = Smallville)
confint(neighborhood_model)
# ALT: Get the 95% CI for the Neighborhood model of PriceK (using lm() directly)
confint(lm(PriceK ~ Neighborhood, data = Smallville))
# Get the 99% CI for the Neighborhood model of PriceK by adjusting the level
confint(neighborhood_model, level = 0.99)
Example of output from running the code above:
Example 3:
You can use confint() to calculate the 95% confidence interval (CI) for a multivariate model (a model with more than one explanatory variable).
# Get the 95% CI for the multivariate model of PriceK
multi_model <- lm(PriceK ~ HomeSizeK + Neighborhood, data = Smallville)
confint(multi_model)
Example of output from running the code above: