An S4 class for storing results of successes (true/false) Bayesian model.
Functions
summary(success_rate_class): prints a summary of the fit.
print(success_rate_class): prints a more detailed summary of the fit
show(success_rate_class): prints a more detailed summary of the fit.
plot(success_rate_class): plots fitted model against the data. Use this function to explore the quality of your fit.
plot(success_rate_class, subjects='boolean'): plots fitted model against the data. Use this function to explore the quality of your fit. You can plot on the subjects level (subjects=TRUE) or on the group level (subjects=FALSE).
plot_fit(success_rate_class): plots fitted model against the data. Use this function to explore the quality of your fit.
plot_fit(success_rate_class, subjects='boolean'): plots fitted model against the data. Use this function to explore the quality of your fit. You can plot on the subjects level (subjects=TRUE) or on the group level (subjects=FALSE).
plot_trace(success_rate_class): traceplot for main fitted model parameters.
get_parameters(success_rate_class): returns a dataframe with values of fitted parameters.
get_subject_parameters(success_rate_class): returns a dataframe with values of fitted parameters for each subject in the hierarchical model.
compare_means(success_rate_class, fit2=success_rate_class): returns difference in success rate between two groups. You can also provide the rope parameter.
compare_means(success_rate_class, fits=list): returns difference in success rate between multiple groups. You can also provide the rope parameter.
plot_means_difference(success_rate_class, fit2=success_rate_class): a visualization of the difference between two groups. You can also provide the rope and bins (number of bins in the histogram) parameters.
plot_means_difference(success_rate_class, fits=list): a visualization of the difference between multiple groups. You can also provide the rope and bins (number of bins in the histogram) parameters.
plot_means(success_rate_class): plots density for the first group means.
plot_means(success_rate_class, fit2=success_rate_class): plots density for the first and the second group means.
plot_means(success_rate_class, fits=list): plots density for multiple
compare_distributions(success_rate_class, fit2=success_rate_class): draws samples from distribution of the first group and compares them against samples drawn from the distribution of the second group. You can also provide the rope parameter.
compare_distributions(success_rate_class, fits=list): draws and compares samples from distributions of multiple groups. You can also provide the rope parameter.
plot_distributions(success_rate_class): a visualization of the fitted distribution.
plot_distributions(success_rate_class, fit2=success_rate_class): a visualization of the distribution for two fits.
plot_distributions(success_rate_class, fits=list): a visualization of the distribution for multiple fits.
plot_distributions_difference(success_rate_class, fit2=success_rate_class): a visualization of the difference between the distribution of the first group and the second group. You can also provide the rope and bins (number of bins in the histogram) parameters.
plot_distributions_difference(success_rate_class, fits=list): a visualization of the difference between the distributions of multiple groups. You can also provide the rope and bins (number of bins in the histogram) parameters.
plot_fit(success_rate_class): plots fitted model against the data. Use this function to explore the quality of your fit. Fit will be plotted on the group level.
class
Slots
extract: Extract from Stan fit.
fit: Stan fit.
data: Data on which the fit is based.
Examples
# priorsp_prior <- b_prior(family ="beta", pars = c(1,1))tau_prior <- b_prior(family ="uniform", pars = c(0,500))# attach priors to relevant parameterspriors <- list( c("p", p_prior), c("tau", tau_prior))# subjectss <- rep(1:5,20)# generate data and fitdata1 <- rbinom(100, size =1, prob =0.6)fit1 <- b_success_rate(r = data1, s = s, priors = priors, chains =1)data2 <- rbinom(100, size =1, prob =0.1)fit2 <- b_success_rate(r = data2, s = s, priors = priors, chains =1)data3 <- rbinom(100, size =1, prob =0.5)fit3 <- b_success_rate(r = data3, s = s, priors = priors, chains =1)data4 <- rbinom(100, size =1, prob =0.9)fit4 <- b_success_rate(r = data4, s = s, priors = priors, chains =1)# fit listfit_list <- list(fit2, fit3, fit4)# a short summary of fitted parameterssummary(fit1)# a more detailed summary of fitted parametersprint(fit1)show(fit1)# plot the fitted distribution against the dataplot(fit1)plot_fit(fit1)# plot the fitted distribution against the data,# plot on the top (group) levelplot(fit1, subjects =FALSE)plot_fit(fit1, subjects =FALSE)# traceplot of the fitted parametersplot_trace(fit1)# extract parameter values from the fitparameters <- get_parameters(fit1)# extract parameter values on the bottom (subject) level from the fitsubject_parameters <- get_subject_parameters(fit1)# compare means between two fits, use a rope intervalcompare_means(fit1, fit2 = fit2, rope =0.05)# compare means between multiple fitscompare_means(fit1, fits = fit_list)# visualize difference in means between two fits,# specify number of histogram bins and rope intervalplot_means_difference(fit1, fit2 = fit2, bins =40, rope =0.05)# visualize difference in means between multiple fitsplot_means_difference(fit1, fits = fit_list)# visualize means of a single fitplot_means(fit1)# visualize means of two fitsplot_means(fit1, fit2 = fit2)# visualize means of multiple fitsplot_means(fit1, fits = fit_list)# draw samples from distributions underlying two fits and compare them,# use a rope intervalcompare_distributions(fit1, fit2 = fit2, rope =0.05)# draw samples from distributions underlying multiple fits and compare themcompare_distributions(fit1, fits = fit_list)# visualize the distribution underlying a fitplot_distributions(fit1)# visualize distributions underlying two fitsplot_distributions(fit1, fit2 = fit2)# visualize distributions underlying multiple fitsplot_distributions(fit1, fits = fit_list)# visualize difference between distributions underlying two fits,# use a rope intervalplot_distributions_difference(fit1, fit2 = fit2, rope =0.05)# visualize difference between distributions underlying multiple fitsplot_distributions_difference(fit1, fits = fit_list)