#' @article{Vallejo/Ato/Fernandez/Livacic-Rojas:2019, #' author = {Vallejo, Guillermo and Ato, Manuel and Fernández, M. Paula and Livacic-Rojas, Pablo E.}, #' year = {2019}, #' title = {Sample size estimation for heterogeneous growth curve models with attrition}, #' fjournal = {Behavior Research Methods}, #' journal = {Behav Res}, #' pages = {1216--1243}, #' volume = {51}, #' doi = {10.3758/s13428-018-1059}, #' } tau11 = function(r1,rho1,k1,t) { t11 =( 2*r1^2*rho1+(k1-1)-2*r1*sqrt(r1^1*rho1^2+rho1*(k1-1)))/(t-1)^2 return(t11) } beta11 = function(k1,t,dL) { return(dL*sqrt(k1)/(t-1)) } sb1 = function(r1,rho1,k1,t) { t11 = tau11(r1,rho1,k1,t) sb1 = sqrt(t11 + 12*(1-rho1)/(t^2-1)/t) return(sb1) } sample.size = function(alpha,beta,rho1,r1,p1,k1,dL) { N = (qnorm(1-alpha/2)+qnorm(1-beta))^2*(s1/b11)^2/(p1*(1-p1)) return(N) } # p1=0.5 r1=-0.5 dL = 0.4 t=4 k1=25 rho1 = 0.1 alpha=0.05 beta = 0.2 s1 = sb1(r1,rho1,k1,t) b11 = beta11(k1,t,dL) b11/s1 sample.size(alpha,beta,rho1,r1,p1,k1,dL) # p1=0.5 r1=.5 dL = 0.6 t=8 k1=25 rho1 = 0.5 alpha=0.05 beta = 0.2 s1 = sb1(r1,rho1,k1,t) b11 = beta11(k1,t,dL) b11/s1 sample.size(alpha,beta,rho1,r1,p1,k1,dL)