if (FALSE) {
# Equidistant knots with order 2
knots <- 1:10
P <- penalty(knots, order = 2)
print(P[[1]]) # First differences
# Non equidistant knots
knots <- c(0, 0, 0, 0, 1, 3, 4, 4, 4, 4)
P <- penalty(knots, order = 4)
print(P[[1]]) # First differences
print(P[[2]]) # Second differences
print(P[[3]]) # Third differences
# Periodic penalty for equidistant knots
oder <- 4
deg <- order - 1
knots <- 1:15
penalty(knots, order = order, periodic = TRUE)[[1]]
penalty(knots, order = order, periodic = TRUE)[[2]]
penalty(knots, order = order, periodic = TRUE)[[3]]
}
Run the code above in your browser using DataLab