我正在尝试获取与生产率数据相关的一组点的上凸壳,用于R语言。 我期望它是一个具有递减规模收益的函数,输入为工作时数,输出为工作完成量的度量。 我想要上凸壳是因为这将使我得到效率前沿。
我已经在R中找到了chull方法,但这只给出整个包络中的点集而不仅仅是上凸壳点。 有没有办法在R中自动选择上凸壳点?
例如,我们可以在生成的圆中找到上凸壳。
library(ggplot2)
# Generate random uniformly spaced points in the square space between (0,0) and (1,1)
x <- runif(10000, min = 0, max = 1)
y <- runif(10000, min = 0, max = 1)
df <- tibble(x,y)
# Filter out the points that don't lie inside a circle of radius 1
df %>% filter(!(x^2+y^2>1)) -> df
# Plot all the points in the above dataframe
ggplot(df, aes(x=x, y=y)) + geom_point()
# Compute the convex hull of the above points
newdf <- df[chull(df$x, df$y),]
# Plot the convex hull
ggplot(newdf, aes(x=x, y=y)) + geom_point()
完整的图像如下所示 凸包看起来像这样 在这个例子中,上侧壳应该只给我圆形的曲线部分,而不是坐标轴。
cut()
函数),并选择每个区间内的最大值? - Wimpel