我已经生成了1000个泊松分布样本,并试图绘制概率密度函数和最大似然估计图。我已经完成了概率密度函数图,但是我不知道如何找到数据集的MLE以及绘制MLE图的方法
#1000 samples with sample size n = 100#
set.seed(124)
library(ggplot2)
library(tidyr)
#generating 1000 samples with sample size n = 100 with Poission Distribution with parameter lambda = 3#
Sample1000 <- replicate(1000, matrix(data=rpois(100, lambda = 3),ncol = 1), simplify = TRUE)
Graph1000 <- gather(as.data.frame(Sample1000))
View(Sample1000)
colMeans(Sample1000)
apply(Sample1000, 2, var)
#plot the pdf graph for 1000 samples set#
ggplot(Graph1000, aes(x = value)) +
geom_density(aes(group = key)) +
labs(x = "y", y = "P(y)", title = "Probability density function for 1000 samples") +
theme_classic() +
theme(plot.title = element_text(hjust = 0.5)) +
scale_x_continuous(breaks = seq(from = 0,to = 14,by = 2), limits = c(0,14)) +
scale_y_continuous(expand = c(0,0))