# Generate sample data for examples
x <- rnorm(100)
y <- 2*x + rnorm(100)
# Plot GAM smooth line only
scatter.gam(x, y)
# Equivalent call using formula syntax (y ~ x)
scatter.gam(y ~ x)
# Include scatter plot with underlying data points behind the GAM line
scatter.gam(x, y, data.dots = TRUE)
# Include summary points showing mean x and y for each tertile bin
scatter.gam(x, y, three.dots = TRUE)
# Customize the plot with a custom title, line color, and line width
scatter.gam(x, y, data.dots = TRUE, col = "red", lwd = 2, main = "GAM Fit")
# Control smoothness of the GAM line by specifying the basis dimension
scatter.gam(x, y, k = 10)
Run the code above in your browser using DataLab