### Probability function ###
# Parameters
mu <- c(-4, 2, 4)
phi <- 6.5
xi <- 2
xvals <- -30:30
# Skewed-left distribution (mu < xi)
plot(xvals, dsdl(xvals, mu[1], phi, xi),
type = "h", xlab = "x", ylab = "Pmf")
# Symmetric distribution (mu = xi)
plot(xvals, dsdl(xvals, mu[2], phi, xi),
type = "h", xlab = "x", ylab = "Pmf")
# Skewed-right distribution (mu > 0)
plot(xvals, dsdl(xvals, mu[3], phi, xi),
type = "h", xlab = "x", ylab = "Pmf")
### Difference between paired samples of non-negative observations ###
# Parameters
mu <- 3
phi <- 4
xi <- 0
# Paired samples of a pre-post treatment experimental study
before <- rgeom(1000, 2 / (2 + phi - mu))
after <- rgeom(1000, 2 / (2 + phi + mu))
# Response variable
y <- after - before
# Barplot
obj <- barplot(prop.table(table(y)),
xlab = "Response",
ylab = "Proportion",
col = "white",
ylim = c(0, mean(y == 0) + 0.01))
# Sdl model for the differences
points(obj, dsdl(sort(unique(y)), mu, phi, xi), col = "red", pch = 16)
Run the code above in your browser using DataLab