discont_basis {moanin} | R Documentation |
Provides set of basis functions on either side of a time point, allowing for a discontinuity in the fitted functions
discont_basis( timepoints, discont_point, knots = NULL, dfPre = NULL, dfPost = dfPre, degree = 3, intercept = TRUE, type = c("ns", "bs") )
timepoints |
vector of numeric timepoints for which the splines basis will be evaluated |
discont_point |
a single numeric value that represents where the discontinuity should be |
knots |
passed to |
dfPre |
the df for the basis functions defined before the discontinuity point |
dfPost |
the df for the basis functions defined after the discontinuity point |
degree |
passed to |
intercept |
Whether to include an intercept (vector of all 1s) for each side of the discontinuity. Note this is different than the argument |
type |
either "ns" or "bs" indicating which splines basis function should be used. |
x<-seq(0,10,length=100) basis<-discont_basis(x,discont_point=3, dfPre=3, dfPost=4, intercept=TRUE) # Plot of the basis functions par(mfrow=c(3,3)) for(i in 1:ncol(basis)){ plot(x,basis[,i],type="l") abline(v=3,lty=2) } # Use it in a moanin_model object instead of ns/bs: data(exampleData) moanin <- create_moanin_model(data=testData, meta=testMeta, spline_formula=~Group:discont_basis(Timepoint,dfPre=3, dfPost=3,discont=20,intercept=TRUE)+0, degrees_of_freedom=6)