Attaching package: 'ggeffects'
The following object is masked from 'package:easystats':
install_latest
## Read data from filepolysim <-read_csv("polysim.csv")
Rows: 100 Columns: 4
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
dbl (4): x, y1, y2, y3
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# ==============================================================================# LM for a linear relationship example## Fit linear modelfit1 <-lm(formula = y1 ~ x,data = polysim)model_parameters(fit1) |>print_md()
Data points may overlap. Use the `jitter` argument to add some amount of
random variation to the location of data points and avoid overplotting.
## Check linearity assumptioncheck_model(fit1, check ="linearity") # good enough
# ==============================================================================# LM with raw polynomials example## Fit raw polynomial modelfit1b <-lm(formula = y1 ~ x +I(x^2),data = polysim)model_parameters(fit1b) |>print_md() # both are nonsignificant
Data points may overlap. Use the `jitter` argument to add some amount of
random variation to the location of data points and avoid overplotting.
## Check linearity and collinearity assumptionscheck_model(fit1b, check ="linearity") # still acceptable
check_collinearity(fit1b) # problematically high
# Check for Multicollinearity
High Correlation
Term VIF VIF 95% CI Increased SE Tolerance Tolerance 95% CI
x 423.33 [292.35, 613.19] 20.57 2.36e-03 [0.00, 0.00]
I(x^2) 423.33 [292.35, 613.19] 20.57 2.36e-03 [0.00, 0.00]
# ==============================================================================# LM with orthogonal polynomials example## Fit orthogonal polynomial modelfit1c <-lm(formula = y1 ~poly(x, degree =2),data = polysim)model_parameters(fit1c) |>print_md() # first degree is significant