devtools::install_github("bonStats/gcreg")
library(gcreg)
y<-exp(k*x)
y_poly<-rep(0,length(x))
for(i in c(1:length(x)))
{
y_poly[i]<-sum(xpoly[i,]/fc)+1
}
plot(x,y, log="", main="fitting exponential with polynomial")
lines(x,y_poly, col=2, lty=2 )
legend(5,0.8, c("exponential exp(-x)","polynomial with degree of 200"), col=c(1,2), pch=c(1,-1), lty=c(-1,2))
#now try to fit the polynomail
#x<-k*x
mp<-cpm(y~x,degree=10,constraint="monotone", c_region=range(x))
deg<-11
c_model <- cpm(height ~ day, data = fda::onechild, degree = deg,
constraint = "monotone", c_region = range(fda::onechild$day))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.