## ---- include = FALSE---------------------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
## ----setup--------------------------------------------------------------------
library(linear1)
## -----------------------------------------------------------------------------
lm1(mpg ~ disp + wt, data = mtcars)
## -----------------------------------------------------------------------------
# Add na values
mtcars.na <- mtcars[,c(1,3,6)]
mtcars.na[1,2] <- NA
# Conduct linear regression
lm1(mpg ~ disp + wt, data = mtcars.na, na.action = "na.impute")
## -----------------------------------------------------------------------------
#A stop is expected as the dataset contains NAs.
lm1(mpg ~ disp + wt, data = mtcars.na, na.action = "na.impute")
#lm1(mpg ~ disp + wt, data = mtcars, na.action = na.fail)
## -----------------------------------------------------------------------------
lm1(mpg ~ disp + wt, data = mtcars, intercept = FALSE)
## -----------------------------------------------------------------------------
# model with interaction between disp and wt
lm1(mpg ~ disp + wt, data = mtcars, interaction = matrix(c("disp", "wt"),1,2))
## -----------------------------------------------------------------------------
model <- lm1(mpg ~ disp + wt, data = mtcars)
summary1(model)
## -----------------------------------------------------------------------------
model <- lm1(mpg ~ disp + wt, data = mtcars)
diagnosis(model)
## -----------------------------------------------------------------------------
all.equal(lm(mpg ~ disp + wt, data = mtcars)$fitted.values, lm1(mpg ~ disp + wt, data = mtcars)$fitted.values)
## -----------------------------------------------------------------------------
bench::mark(lm1(mpg ~ disp + wt, data = mtcars)$fitted.values, lm(mpg ~ disp + wt, data = mtcars)$fitted.values)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.