Skip to content

Instantly share code, notes, and snippets.

View mihaiconstantin's full-sized avatar
📑
Thesis Writing

Mihai Constantin mihaiconstantin

📑
Thesis Writing
View GitHub Profile
@mihaiconstantin
mihaiconstantin / monotone_spline.R
Created April 12, 2021 18:31 — forked from willtownes/monotone_spline.R
monotone splines using package mgcv
library(mgcv)
#library(modules) #devtools::install_github(klmr/modules)
#mgcv<-import_package("mgcv")
mspline<-function(x,y,k=10,lower=NA,upper=NA){
#fits a monotonic spline to data
#small values of k= more smoothing (flatter curves)
#large values of k= more flexible (wiggly curves)
#k is related to effective degrees of freedom and number of knots
#use unconstrained gam to get rough parameter estimates