<p>You can't estimate a model like this by OLS because it is not linear in parameters.</p>
<p>Are you willing to model this as shown below? <span class="math-container">$$y_i =\frac{1}{1+e^{\beta_0+\beta_1x_i}}+u_i $$</span></p>
<p>If so you could use nonlinear least squares.  This can be implemented in Stata with the <strong>nl</strong> command.</p>
<p>If you are not able to change the modeling assumption, then I think you'd have to do method of moments. One moment would presumably be <span class="math-container">$E[u]=0$</span>. The other moment would presumably be <span class="math-container">$E[xu]=0$</span>. You'd have to code this yourself in python or matlab I think. You'd solve for the <span class="math-container">$\hat{\beta_0}$</span> and <span class="math-container">$\hat{\beta_1}$</span> such that the sample average of <span class="math-container">$\hat{u}$</span> is 0 and the sample average of <span class="math-container">$x_i\hat{u_i}$</span> is 0.</p>
<p><strong>EDIT:</strong> You can do the method of moments in Stata. By solving for <span class="math-container">$u$</span>, it is the case that <span class="math-container">$$u_i =\ln\left(\frac{1-y_i}{y_i} -\beta_0-\beta_1x_i\right)$$</span></p>
<p>Thus, the Stata code to do method of moments based on <span class="math-container">$E[u]=0$</span> and <span class="math-container">$E[xu]=0$</span> is</p>
<p>gmm (ln((1-y)/y) -{b0} -{b1}*x ), instruments(x)</p>
<p>You'll just need to change the names of <span class="math-container">$x$</span> and <span class="math-container">$y$</span> based on what they are called in your data.</p>

CC BY-SA 4.0
2023-06-13T11:15:01.577Z
2023-06-13T11:35:03.170Z
2023-06-13T11:35:03.170Z
Michael Gmeiner
<p>I have the following Model and would like to know how to acquire the OLS-estimates when the model is expressed like this? I have tried to look it up, but no one is explicit about how to acquire the OLS estimates when you have a linear coefficient and the rest a non-linear expression.
I know that if there was no 1 in the denominator, I would be able to take the logarithm of y, which would make the model linear in parameters, but the 1 is kinda irritating me at this point.</p>
<p>If I take logs, I get the following:
<span class="math-container">$$
\log(y) = -\log(1+\beta_0 + \beta_1 x + u)
$$</span>
and this does not help me a lot because the the model is not linear in parameters.</p>
<p>Any help would be much appreciated</p>
<p><a href="https://i.sstatic.net/2d89E.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2d89E.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2023-06-11T01:01:35.590Z
Welcome! How about $1/y = 1+\exp(\beta_0+\beta_1+u)$ so $\log(1/y-1) = \beta_0+\beta_1 x+u$? It is required that $0<y<1$.
chan1142
CC BY-SA 4.0
2023-06-11T07:08:41.733Z
You can try least-squares.
callculus42
<econometrics><regression>
OLS-estimation and regression models
Bob
# OLS-estimation and regression models

(Asked by: username_0 on 2023-06-10)

I have the following Model and would like to know how to acquire the OLS-estimates when the model is expressed like this? I have tried to look it up, but no one is explicit about how to acquire the OLS estimates when you have a linear coefficient and the rest a non-linear expression.
I know that if there was no 1 in the denominator, I would be able to take the logarithm of y, which would make the model linear in parameters, but the 1 is kinda irritating me at this point.

If I take logs, I get the following:
$$
\log(y) = -\log(1+\beta\_0 + \beta\_1 x + u)
$$
and this does not help me a lot because the the model is not linear in parameters.

Any help would be much appreciated

[![enter image description here](https://i.sstatic.net/2d89E.png)](https://i.sstatic.net/2d89E.png)

**Tags:** econometrics, regression
> **Comments:**
> **username_1**: Welcome! How about $1/y = 1+\exp(\beta_0+\beta_1+u)$ so $\log(1/y-1) = \beta_0+\beta_1 x+u$? It is required that $0<y<1$.  
> **username_2**: You can try least-squares.  

---

## 1 answers

### Answer by username_3 on 2023-06-13. Score: 2

You can't estimate a model like this by OLS because it is not linear in parameters.

Are you willing to model this as shown below? $$y\_i =\frac{1}{1+e^{\beta\_0+\beta\_1x\_i}}+u\_i $$

If so you could use nonlinear least squares. This can be implemented in Stata with the **nl** command.

If you are not able to change the modeling assumption, then I think you'd have to do method of moments. One moment would presumably be $E[u]=0$. The other moment would presumably be $E[xu]=0$. You'd have to code this yourself in python or matlab I think. You'd solve for the $\hat{\beta\_0}$ and $\hat{\beta\_1}$ such that the sample average of $\hat{u}$ is 0 and the sample average of $x\_i\hat{u\_i}$ is 0.

**EDIT:** You can do the method of moments in Stata. By solving for $u$, it is the case that $$u\_i =\ln\left(\frac{1-y\_i}{y\_i} -\beta\_0-\beta\_1x\_i\right)$$

Thus, the Stata code to do method of moments based on $E[u]=0$ and $E[xu]=0$ is

gmm (ln((1-y)/y) -{b0} -{b1}\*x ), instruments(x)

You'll just need to change the names of $x$ and $y$ based on what they are called in your data.


---

