old <- options(digits = 3) knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library("brokenstick")
The brokenstick
package has three major interfaces:
brokenstick 0.62.1
(before May 2020) brokenstick 1.1.1
(May 2020 - Nov 2021) 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
.
Function brokenstick()
in version 2.0.0
sets the Kasim-Raudenbush sampler as the default method. The former method lme4::lmer()
remains available by setting method = "lmer"
argument.
Version 2.0.0
adopts the variable names of the coda
package (e.g., start
, end
, thin
, niter
, and so on) and stores the results of the Kasim-Raudenbush sampler as objects of class mcmc
.
For method = "kr"
one may now inspect the solution of the sampler by standard functions from the coda
package. For method = "lmer"
we can apply functions from the lme4
package for merMod
objects.
Version 2.0.0
redefines the brokenstick
class. New entries include call
, formula
, internal
, sample
, light
, data
, imp
and mod
. Removed entries are knots
(renamed to internal
) and draws
(renamed to imp
). We may omit the newdata
argument for the training data. Setting light = TRUE
creates a small version of the brokenstick
object. Objects of class brokenstick
are not backwards compatible, so one should regenerate objects of class brokenstick
in order use newer features in 2.0.0
.
Version 2.0.0
conforms to classic model fitting interface in R
. Renames the new_data
argument to newdata
to conform to predict.lm()
. Methods plot()
and predict()
no longer require a newdata
argument. All special cases of predict()
updated and explained in documentation and examples.
Version 2.0.0
adds methods coef()
, fitted()
, model.frame()
, model.matrix()
, print()
and summary()
for the brokenstick
object.
Simplifies algorithmic control. Renames control_brokenstick()
to set_control()
and removes a layer in the control list.
Added support for hide
argument in user-oriented functions. Automatic suppression of last knot.
rgamma()
calls in KR-algorithm for edge cases.predict_brokenstick()
can now work with the both (internal) training and (external) test data. type
argument from predict.brokenstick()
get_omega()
to extract the variance-covariance matrix of the broken stick estimatestest-brokenstick_edge.R
brokenstick()
warn_splines
in make_basis()
to suppress uninteresting warns from splines::bs()
knotnames
argument in make_basis()
x
in make_basis()
is now a vector instead of a column vectorxname
argument in make_basis()
to set the xnameWe 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")
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)
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
:
# predict at observed data p1 <- predict(fit1) # predict at knots p2 <- predict(fit1, x = "knots", include_data = FALSE) # predict at both observed data and knots p3 <- predict(fit1, x = "knots") # predict knots, broad matrix p4 <- predict(fit1, x = "knots", shape = "wide")
Plot trajectories, brokenstick package version 0.75.0
- 1.1.1
:
ids <- c(10001, 10005, 10022) plot(fit1, data, group = ids, what = "all")
Plot trajectories, brokenstick package version 2.4.0
:
ids <- c(10001, 10005, 10022) plot(fit1, group = ids, hide = "none")
options(old)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.