Tôi đã lắp đặt bản phân phối chuẩn với chức năng fitdist
từ gói fitdistrplus
. Sử dụng denscomp
, qqcomp
, cdfcomp
và ppcomp
chúng tôi có thể vẽ số histogram against fitted density functions
, theoretical quantiles against empirical ones
, the empirical cumulative distribution against fitted distribution functions
và theoretical probabilities against empirical ones
tương ứng như được đưa ra bên dưới.Làm các ô phù hợp với ggplot2
set.seed(12345)
df <- rnorm(n=10, mean = 0, sd =1)
library(fitdistrplus)
fm1 <-fitdist(data = df, distr = "norm")
summary(fm1)
denscomp(ft = fm1, legendtext = "Normal")
qqcomp(ft = fm1, legendtext = "Normal")
cdfcomp(ft = fm1, legendtext = "Normal")
ppcomp(ft = fm1, legendtext = "Normal")
Tôi rất quan tâm đến việc thực hiện các ô fitdist
này với ggplot2
. MWe là dưới đây:
qplot(df, geom = 'blank') +
geom_line(aes(y = ..density.., colour = 'Empirical'), stat = 'density') +
geom_histogram(aes(y = ..density..), fill = 'gray90', colour = 'gray40') +
geom_line(stat = 'function', fun = dnorm,
args = as.list(fm1$estimate), aes(colour = 'Normal')) +
scale_colour_manual(name = 'Density', values = c('red', 'blue'))
ggplot(data=df, aes(sample = df)) + stat_qq(dist = "norm", dparam = fm1$estimate)
tôi muốn khuyên bạn đánh giá cao nếu ai đó cho tôi gợi ý để thực hiện những âm mưu fitdist
với ggplot2
. Cảm ơn
Nếu điều này không có tiền thưởng, tôi sẽ bỏ phiếu để đóng quá rộng. Mỗi biểu đồ phải là một câu hỏi khác (mặc dù bạn có thể không cần hỏi mỗi biểu đồ nếu bạn có câu trả lời cho một hoặc hai trong số chúng). – Roland