Last chance! 50% off unlimited learning
Sale ends in
The function uses the formula presented in Douma & Weedon (2019). It is primarily intended to be used in beta regression (regression for continuous proportions) when data contain zeroes and/or ones, but can be applied to any variable initially bounded in the [0,1] interval when rescaling is necessary. The function can also perform back-transformation.
p.beta(p, n = length(p), C = 2, back = FALSE)
numeric vector of values in the [0,1] interval.
total number of observations in the initial data set. Not very useful when the transformation is applied to the initial data set, but needed when back-transformation is applied from predicted values.
number of categories from which p
was computed.
logical. If TRUE
, back-transformation is performed rather than transformation.
# NOT RUN {
# A fictive example with four animals performing a behavioral choice-test where time
# can be spent in three branches (total time 20 min)
(tab <- data.frame(Individual=c("Ind1","Ind2","Ind3","Ind4"),Branch1=c(0,12,20,4),
Branch2=c(8,4,0,6),Branch3=c(12,4,0,10)))
# Raw proportions of time spent in branch 1:
(p1 <- tab$Branch1/rowSums(tab[,-1]))
# Scaled proportions:
p.beta(p1,C=3)
# }
Run the code above in your browser using DataLab