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") > > ## augment with random noise > set.seed(1071) > n <- nrow(ReadingSkills) > ReadingSkills$x1 <- rnorm(n) > ReadingSkills$x2 <- runif(n) > ReadingSkills$x3 <- factor(sample(0:1, n, replace = TRUE)) > > ## fit beta regression tree > rs_tree <- betatree(accuracy ~ iq | iq, ~ dyslexia + x1 + x2 + x3, + data = ReadingSkills, minsize = 10) > > ## methods > print(rs_tree) Beta regression tree Model formula: accuracy ~ iq + iq | dyslexia + x1 + x2 + x3 Fitted party: [1] root | [2] dyslexia in no: n = 25 | (Intercept) iq (phi)_(Intercept) (phi)_iq | 1.657 1.466 1.273 2.048 | [3] dyslexia in yes: n = 19 | (Intercept) iq (phi)_(Intercept) (phi)_iq | 0.38093 -0.08623 4.80766 0.82603 Number of inner nodes: 1 Number of terminal nodes: 2 Number of parameters per node: 4 Objective function (negative log-likelihood): -66.73 > ## IGNORE_RDIFF_BEGIN > summary(rs_tree) ## possibly small deviations in number of BFGS/Fisher iterations $`2` Call: betatree(formula = accuracy ~ iq | iq, data = ReadingSkills) Quantile residuals: Min 1Q Median 3Q Max -2.495 -0.437 0.210 0.953 1.090 Coefficients (mean model with logit link): Estimate Std. Error z value Pr(>|z|) (Intercept) 1.657 0.286 5.78 7.3e-09 *** iq 1.466 0.248 5.92 3.2e-09 *** Phi coefficients (precision model with log link): Estimate Std. Error z value Pr(>|z|) (Intercept) 1.273 0.307 4.15 3.4e-05 *** iq 2.048 0.331 6.19 5.9e-10 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Type of estimator: ML (maximum likelihood) Log-likelihood: 39.4 on 4 Df Pseudo R-squared: 0.149 Number of iterations: 17 (BFGS) + 2 (Fisher scoring) $`3` Call: betatree(formula = accuracy ~ iq | iq, data = ReadingSkills) Quantile residuals: Min 1Q Median 3Q Max -2.426 -0.631 -0.067 0.778 1.555 Coefficients (mean model with logit link): Estimate Std. Error z value Pr(>|z|) (Intercept) 0.3809 0.0486 7.83 4.8e-15 *** iq -0.0862 0.0549 -1.57 0.12 Phi coefficients (precision model with log link): Estimate Std. Error z value Pr(>|z|) (Intercept) 4.808 0.414 11.61 <2e-16 *** iq 0.826 0.395 2.09 0.036 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Type of estimator: ML (maximum likelihood) Log-likelihood: 27.3 on 4 Df Pseudo R-squared: 0.0391 Number of iterations: 16 (BFGS) + 2 (Fisher scoring) > ## IGNORE_RDIFF_END > coef(rs_tree) (Intercept) iq (phi)_(Intercept) (phi)_iq 2 1.6565 1.46571 1.273 2.048 3 0.3809 -0.08623 4.808 0.826 > if(require("strucchange")) sctest(rs_tree) Loading required package: strucchange Loading required package: zoo Attaching package: 'zoo' The following objects are masked from 'package:base': as.Date, as.Date.numeric Loading required package: sandwich $`1` dyslexia x1 x2 x3 statistic 2.269e+01 8.5251 5.5699 3.6273 p.value 5.848e-04 0.9095 0.9987 0.9142 $`2` dyslexia x1 x2 x3 statistic 0 6.4116 4.5170 8.2019 p.value NA 0.8412 0.9752 0.2326 $`3` NULL > > proc.time() user system elapsed 1.18 0.17 1.34