Adding a custom constraint to weighted least squares regression model

I am trying to run a weighted least squares model that looks something like this (but could be different):

$$y = \beta_0 + \beta_1 x + \beta_2 log(x) + \epsilon$$

with weights $$w_1, w_2, ..$$

However, I know, from external knowledge, that whatever the model the outcome must asymptotically converge to a constant for large values of $$x$$. How can I get an OLS estimate with this constraint.

As an example, let's say if I knew the asymptote $$c$$, then I can add two fake data points to my model, with very high values of $$x$$ and very high weights $$w$$ and $$y=c$$, and run the normal WLS model and it would give me what I need - except I don't know the value of $$c$$. Is there a way to impose this constraint - maybe through adding a custom error term to the model?

• Perhaps solving the equation $y=max(\beta_0+\beta_1x+\beta_2*log(x),c)+\epsilon$ instead of the original? you will have to add artificial points to the data with $(x_{large},c)$ – Juan Esteban de la Calle Apr 16 '19 at 21:19
• I don't know the value of $c$, so somehow I imagine the loss function would need to take care of this. If I knew $c$, I have described in the question how I would go about doing this. – ste_kwr Apr 16 '19 at 21:23
• Maybe you can try to fit something like a modified logit model. I have never tried something liike this and I don't know anything about a possible implementation, but a logit regression has a natural limit of $1$, you may work with a unknown limit. The equation would be like this: $Y=\frac{c}{(1+e^{-(\beta_0+\beta_1x+\beta_2log(x))})}$ – Juan Esteban de la Calle Apr 16 '19 at 22:23

The model you are looking for is this:

$$Y=\frac{A}{1+e^{-(\beta_0+\beta_1x+\beta_2log(x))}}$$, this could not be obtained but a very similar was obtained.

This code in R might work:

R=data.frame(X=c(1,2,3,4,5,6,7,8,9),Y=c(1,2,3,3,3,3,3,3,3)) # Data in which X is a line, and Y has an still unknown limit.
model=nls(formula = Y~A/(1+exp(-(b0+b1*X))),data=R)
summary(model)


In the result you can see how $$A$$ says that the limit of 3 (previously unknown) is calculated.

There is a limitation to take into account, is explained in this link, is summarized in the impossibility for all possible models to exist, the "most inside" model should be linear.

The model $$\beta_0+\beta_1x+\beta_2log(x)$$ could not be used, the model $$\beta_0+\beta_1x$$ could be used, take this into account.

First steps with Non-Linear Regression in R

Singular Gradient Error in nls with correct starting values