## Example 1
head(birth) #geo-coded dataset
hist(birth$birthweight) # attribute of interest
# Linear regression model
mod1 = lm(birthweight ~ primiparous + datediff + bmi
+ inc, data = birth)
summary(mod1)
data.adj1 = vario.reg.prep(mod1)
head(data.adj1)
hist(data.adj1$adj) # adjusted attribute of interest
# The data frame can be used as input for the vario.mod function.
## Example 2
# No data argument provided within lm (not recommended, but possible):
mod2 = lm(birth$birthweight ~ birth$primiparous + birth$datediff + birth$bmi
+ birth$inc)
summary(mod2)
# In this case, make sure to provide the data argument here:
data.adj2 = vario.reg.prep(reg = mod2, data = birth)
if (requireNamespace("lme4", quietly = TRUE)) {
## Example 3
# Linear mixed regression model
mod3 = lme4::lmer(birthweight ~ primiparous + datediff
+ bmi + (1|inc), data = birth)
summary(mod3)
data.adj3 = vario.reg.prep(mod3)
## Example 4
# Data argument within lmer not provided (not recommended, but possible):
mod4 = lme4::lmer(birth$birthweight ~ birth$primiparous + birth$datediff
+ birth$bmi + (1|birth$inc))
summary(mod4)
# In this case, make sure to provide the data argument here:
data.adj4 = vario.reg.prep(reg = mod4, data = birth)
}
Run the code above in your browser using DataLab