Background
The brokenstick package has three major interfaces:
- Up to version
brokenstick 0.62.1(before May 2020) - Up to version
brokenstick 1.1.1(May 2020 - Nov 2021) - Versions higher than
brokenstick 2.0.0(Nov 2021 - now)
This document summarises the main changes in
brokenstick 2.0.0. See “Help for old friends” in
brokenstick 1.1.1 for an overview of the previous changes
from 0.75.0 to 1.1.1.
Main changes
Function
brokenstick()in version2.0.0sets the Kasim-Raudenbush sampler as the default method. The former methodlme4::lmer()remains available by settingmethod = "lmer"argument.Version
2.0.0adopts the variable names of thecodapackage (e.g.,start,end,thin,niter, and so on) and stores the results of the Kasim-Raudenbush sampler as objects of classmcmc.For
method = "kr"one may now inspect the solution of the sampler by standard functions from thecodapackage. Formethod = "lmer"we can apply functions from thelme4package formerModobjects.Version
2.0.0redefines thebrokenstickclass. New entries includecall,formula,internal,sample,light,data,impandmod. Removed entries areknots(renamed tointernal) anddraws(renamed toimp). We may omit thenewdataargument for the training data. Settinglight = TRUEcreates a small version of thebrokenstickobject. Objects of classbrokenstickare not backwards compatible, so one should regenerate objects of classbrokenstickin order use newer features in2.0.0.Version
2.0.0conforms to classic model fitting interface inR. Renames thenew_dataargument tonewdatato conform topredict.lm(). Methodsplot()andpredict()no longer require anewdataargument. All special cases ofpredict()updated and explained in documentation and examples.Version
2.0.0adds methodscoef(),fitted(),model.frame(),model.matrix(),print()andsummary()for thebrokenstickobject.Simplifies algorithmic control. Renames
control_brokenstick()toset_control()and removes a layer in the control list.Added support for
hideargument in user-oriented functions. Automatic suppression of last knot.
Minor changes
- Stabilises the
rgamma()calls in KR-algorithm for edge cases. -
predict_brokenstick()can now work with the both (internal) training and (external) test data. - Removes the superfluous
typeargument frompredict.brokenstick() - Adds a function
get_omega()to extract the variance-covariance matrix of the broken stick estimates - Improves error messages of edge cases in
test-brokenstick_edge.R - Perform stricter tests on arguments of
brokenstick() - Introduces argument
warn_splinesinmake_basis()to suppress uninteresting warns fromsplines::bs() - Removes superfluous
knotnamesargument inmake_basis() - Argument
xinmake_basis()is now a vector instead of a column vector - Introduces new
xnameargument inmake_basis()to set the xname
Install legacy version
We recommend changing your code to reflect the above changes and run
brokenstick 2.4.0 or higher. If needed, version
1.1.1 can be installed as
library("devtools")
install_github("growthcharts/brokenstick@9b969af")Examples
Example 1: Fit model
Fit model, brokenstick package version 0.75.0 -
1.1.1:
library(brokenstick)
data <- brokenstick::smocc_200
# formula interface
fit1 <- brokenstick(hgt.z ~ age | id, data)
# XY interface - numeric vector
# Deprecated in v2.0.0
fit2 <- with(data, brokenstick(age, hgt.z, id))
# XY interface - data.frame
# Deprecated in v2.0.0
fit3 <- with(data, brokenstick(data.frame(age), hgt.z, id))
# XY interface - matrix
# Deprecated in v2.0.0
tt <- as.matrix(data[, c(1, 2, 7)])
fit4 <- brokenstick(tt[, "age", drop = FALSE],
tt[, "hgt.z", drop = FALSE],
tt[, "id", drop = FALSE])Fit model, brokenstick package version 2.4.0:
library(brokenstick)
data <- brokenstick::smocc_200
# formula interface
fit1 <- brokenstick(hgt_z ~ age | id, data)Example 2: Predict model
Predict model, brokenstick package version 0.75.0 -
1.1.1:
# predict at observed data
p1 <- predict(fit1, data)
# predict at knots
p2 <- predict(fit1, data, x = "knots")
# predict at both observed data and knots
p3 <- predict(fit1, data, x = "knots", strip_data = FALSE)
# predict knots, broad matrix
p4 <- predict(fit1, data, x = "knots", shape = "wide")Predict model, brokenstick package version 2.4.0:
