Reputation: 457
I am trying to understand what is the minimum number of point so as to have loess
interpolation with geom_smooth()
working.
I make an example, this has only 4 point every item.
Dati <- data.frame(
Product = c("a", "a", "a", "a", "b", "b", "b", "b", "c", "c", "c", "c"),
Peel_average = c(3.19, 2.63, 2.3, 1.42, 3.19, 3.11, 2.69, 1.96, 3.3, 2.42, 1.34, 0.74),
Time = c("0W", "6W", "8W", "10W", "0W", "6W", "8W", "10W", "0W", "6W", "8W", "10W")
)
attach(Dati)
#I define the order of the factors
Dati$Time = factor(Dati$Time, levels = c("0W","6W","8W","10W"))
Graph2 <- ggplot(Dati, aes(x= `Time`, col=`Product`)) +
geom_point(aes(y= `Peel_average`, color=`Product`), shape = 1, size = 3.5) +
geom_smooth(aes(x=as.numeric(Dati$`Time`), y= `Peel_average`, col=`Product`), method="loess") +
scale_y_continuous(name="Peel average (N/mm)") +
scale_x_discrete(name="Time (Weeks)", expand=c(0.05, 0)) +
scale_color_manual(values=c("#25921a", "#e62a21", "#416cf4"))
Graph2
As you see on the picture no geom_smooth()
ran (too few points every item Product
).
Now I try to repeat it, but increasing from 4 to 12 the points for every sample. I will copy two other times the same ones.
Dati <- data.frame(
Product = c("a", "a", "a", "a", "b", "b", "b", "b", "c", "c", "c", "c", "a", "a", "a", "a", "b", "b", "b", "b", "c", "c", "c", "c", "a", "a", "a", "a", "b", "b", "b", "b", "c", "c", "c", "c"),
Peel_average = c(3.19, 2.63, 2.3, 1.42, 3.19, 3.11, 2.69, 1.96, 3.3, 2.42, 1.34, 0.74, 3.19, 2.63, 2.3, 1.42, 3.19, 3.11, 2.69, 1.96, 3.3, 2.42, 1.34, 0.74, 3.19, 2.63, 2.3, 1.42, 3.19, 3.11, 2.69, 1.96, 3.3, 2.42, 1.34, 0.74),
Time = c("0W", "6W", "8W", "10W", "0W", "6W", "8W", "10W", "0W", "6W", "8W", "10W", "0W", "6W", "8W", "10W", "0W", "6W", "8W", "10W", "0W", "6W", "8W", "10W", "0W", "6W", "8W", "10W", "0W", "6W", "8W", "10W", "0W", "6W", "8W", "10W")
)
attach(Dati)
#I define the order of the factors
Dati$Time = factor(Dati$Time, levels = c("0W","6W","8W","10W"))
Graph2 <- ggplot(Dati, aes(x= `Time`, col=`Product`)) +
geom_point(aes(y= `Peel_average`, color=`Product`), shape = 1, size = 3.5) +
geom_smooth(aes(x=as.numeric(Dati$`Time`), y= `Peel_average`, col=`Product`), method="loess") +
scale_y_continuous(name="Peel average (N/mm)") +
scale_x_discrete(name="Time (Weeks)", expand=c(0.05, 0)) +
scale_color_manual(values=c("#25921a", "#e62a21", "#416cf4"))
Graph2
The result is the same.
Is there a rule which definines the number of points and their values so as to have a working loess
interpolation? Is it that the values have also to be different?
[ADDENDUM] I was not clear enough: the problem is the absence of the dark gray confidence bands of the interpolation.
Upvotes: 0
Views: 43