# NOT RUN {
##----- A toy example -------
set.seed(0)
n <- 100
x = seq(1/n, 1,length.out = n)
y0 = 0*x; y0[x>0.5] = 1
y = y0 + rnorm(n, sd = 0.1)
# For 'amias' object
fit <- amias(y, k = 1)
coef(fit) # extract the fitting coefficients
coef(fit, type="active") # extract the detected knots
# For 'samias' object
fit <- samias(y, kmax = 6)
coef(fit) # get the coefficients with the minimum BIC value
coef(fit, k = 3:5) # get the coefficients that number of knots being 3, 4, and 5
coef(fit, type="active") # get the active set with minimum BIC value
coef(fit, type="active", k = 3:5) # get the active sets that number of knots being 3, 4, and 5
# }
Run the code above in your browser using DataLab