if (require("ggplot2")) {
m1 <- fm_mesh_1d(c(1, 2, 3, 5, 8, 10),
boundary = c("neumann", "free")
)
weights <- c(2, 3, 6, 3, 4, 7)
ggplot() +
geom_fm(data = m1, xlim = c(0.5, 11), weights = weights)
m2 <- fm_mesh_1d(c(1, 2, 3, 5, 8, 10),
boundary = c("neumann", "free"),
degree = 2
)
ggplot() +
geom_fm(data = m2, xlim = c(0.5, 11), weights = weights)
# The knot interpretation is different for degree=2 and degree=1 meshes:
ggplot() +
geom_fm(data = m1, xlim = c(0.5, 11), weights = weights) +
geom_fm(data = m2, xlim = c(0.5, 11), weights = weights)
# The `mid` values are the representative basis function midpoints,
# and can be used to connect degree=2 and degree=1 mesh interpretations:
m1b <- fm_mesh_1d(m2$mid,
boundary = c("neumann", "free"),
degree = 1
)
ggplot() +
geom_fm(data = m2, xlim = c(0.5, 11), weights = weights) +
geom_fm(data = m1b, xlim = c(0.5, 11), weights = weights)
}
Run the code above in your browser using DataLab