Null hypothesis: variable has specified distribution
null_dist(var, dist, params = NULL)
variable name
distribution name. One of: beta, cauchy, chisq, exp, f, gamma, geom, lnorm, logis, nbinom, binom, norm, pois, t, unif, weibull
list of parameters of distribution. If NULL
, will
use fitdistr
to estimate them.
null_permute, null_lm
dframe <- data.frame(x = rnorm(150))
library(ggplot2)
# three histograms of normally distributed values
ggplot(
data=rorschach(method=null_dist("x", "norm"), n = 3, true=dframe)
) +
geom_histogram(aes(x=x, y=..density..), binwidth=0.25) +
facet_grid(.~.sample) +
geom_density(aes(x=x), colour="steelblue", size=1)
#> Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
#> ℹ Please use `linewidth` instead.
#> Warning: The dot-dot notation (`..density..`) was deprecated in ggplot2 3.4.0.
#> ℹ Please use `after_stat(density)` instead.
# uniform distributions are not as easy to recognize as such
dframe$x = runif(150)
ggplot(
data=rorschach(method=null_dist("x", "uniform",
params=list(min=0, max=1)),
n = 3, true=dframe)) +
geom_histogram(aes(x=x, y=..density..), binwidth=0.1) +
facet_grid(.~.sample) +
geom_density(aes(x=x), colour="steelblue", size=1)