I have a data frame x and y, and I know the maximum of y. I want to fit this data to a quadratic model. How can I do it in R knowing the maximum? If I didn't know the maximum, I would fit it with lm(y~x + I(x^2)). Can anyone has an idea about this? Thanks in advance!
How to fit a quadratic model knowing the maximum in R?

Best Answer
You have to minimize the sum of squares subject to the constraint; Make up some data. Here I'll say the known maximum is 50.
Make a function to get the quadratic curve for points at x with given quadratic and linear coefficients and given maximum M. The calculus is straightforward; see duffymo's answer for details.
Make a function that get the sum of squares between a quadratic curve with given quadratic and linear coefficients and the data in d.
Get the ordinary
Optimize the coefficients in the
Make a plot showing how the fit has a max at 50; the original

Other Answer1
I'd use calculus to calculate the expression for the maximum point. Differentiation will eliminate some of the constants in the equation, so the calculation is easier if you know what that max value needs to be. If I recall correctly, a simple functions of 1 variable have a maximum at f'(x) = 0 and f''(x) < 0. Check me on this. So if your function is f(x):
Set the second equation equal to zero to get the stationary point, then put that value of x into the third one to find out if it's a max or min. 
Relate
 Fit ARIMA model
 Fit a nointercept model in caret
 Nonlinear Model Fit
 Goodness of fit of a model
 Fit 3d model inside a window
 fit a generalized model in R [closed]
 Do there exist methods to identify quadratic components in a linear model with R?
 Include quadratic terms in Deducer's Linear Regression Model Builder
 Maximum Number of Rectangles to Fit in An Area [Competition , Not HW]
 Fit maximum convex hull to interior of a set of points
 maximum entropy model and logistic regression
 Getting unadjusted values from model fit in R
 Where would an authentication model fit in the MVC framework?
 How to fit a model using features by number, not name
 How to fit an VARMA time series model in R?
lm(y~I((xxcoordmax)^2))
should work.