R Under development (unstable) (2024-09-10 r87115 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > options(digits = 4) > suppressWarnings(RNGversion("3.5.0")) > > ## package and data > library("betareg") > data("ReadingSkills", package = "betareg") > > ## beta regression mixture model > set.seed(1071) > rs_mix <- betamix(accuracy ~ iq, data = ReadingSkills, k = 3, + extra_components = extraComponent(type = "uniform", + coef = 0.99, delta = 0.01), nstart = 10) > > ## fitted model > print(rs_mix) Call: betamix(formula = accuracy ~ iq, data = ReadingSkills, k = 3, nstart = 10, extra_components = extraComponent(type = "uniform", coef = 0.99, delta = 0.01)) Cluster sizes: 1 2 3 10 20 14 convergence after 17 iterations > summary(rs_mix) $Comp.1 $Comp.1$mean Estimate Std. Error z value Pr(>|z|) (Intercept) 1.403 0.263 5.33 9.9e-08 *** iq 0.825 0.216 3.81 0.00014 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 $Comp.1$precision Estimate Std. Error z value Pr(>|z|) (Intercept) 2.685 0.454 5.91 3.4e-09 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 $Comp.2 $Comp.2$mean Estimate Std. Error z value Pr(>|z|) (Intercept) 0.5025 0.0825 6.09 1.1e-09 *** iq -0.0484 0.1129 -0.43 0.67 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 $Comp.2$precision Estimate Std. Error z value Pr(>|z|) (Intercept) 4.251 0.747 5.69 1.3e-08 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > > ## further methods > table(clusters(rs_mix), ReadingSkills$dyslexia) no yes 1 7 3 2 4 16 3 14 0 > round(posterior(rs_mix), digits = 4) [,1] [,2] [,3] [1,] 1.0000 0.0000 0.0000 [2,] 0.8720 0.1280 0.0000 [3,] 1.0000 0.0000 0.0000 [4,] 0.1521 0.0000 0.8479 [5,] 1.0000 0.0000 0.0000 [6,] 0.4674 0.5326 0.0000 [7,] 0.9276 0.0724 0.0000 [8,] 0.0000 0.0000 1.0000 [9,] 0.0022 0.0000 0.9978 [10,] 0.0938 0.0000 0.9062 [11,] 0.0305 0.0000 0.9695 [12,] 0.1621 0.0000 0.8379 [13,] 0.0399 0.0000 0.9601 [14,] 0.2680 0.0000 0.7320 [15,] 0.0002 0.0000 0.9998 [16,] 0.0399 0.0000 0.9601 [17,] 0.3641 0.6359 0.0000 [18,] 0.2545 0.0000 0.7455 [19,] 0.0806 0.9194 0.0000 [20,] 0.2377 0.0000 0.7623 [21,] 1.0000 0.0000 0.0000 [22,] 0.0008 0.0000 0.9992 [23,] 0.6760 0.3240 0.0000 [24,] 0.0415 0.9585 0.0000 [25,] 0.2593 0.0000 0.7407 [26,] 0.0827 0.9173 0.0000 [27,] 0.1375 0.8625 0.0000 [28,] 0.8438 0.1562 0.0000 [29,] 0.1856 0.8144 0.0000 [30,] 0.2568 0.7432 0.0000 [31,] 0.0397 0.9603 0.0000 [32,] 0.0101 0.9899 0.0000 [33,] 0.0029 0.9971 0.0000 [34,] 0.3365 0.6635 0.0000 [35,] 0.1013 0.8987 0.0000 [36,] 0.5090 0.4910 0.0000 [37,] 0.3690 0.6310 0.0000 [38,] 0.1338 0.8662 0.0000 [39,] 0.5589 0.4411 0.0000 [40,] 0.3227 0.6773 0.0000 [41,] 0.3087 0.6913 0.0000 [42,] 0.2423 0.7577 0.0000 [43,] 0.2825 0.7175 0.0000 [44,] 0.2558 0.7442 0.0000 > > proc.time() user system elapsed 5.35 0.14 5.48