Adding a custom constraint to weighted least squares regression model Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Moderator Election Q&A - Questionnaire 2019 Community Moderator Election ResultsCan FTRL be applied on linear least squares? or is it just for logistic regression models?What is the difference between residual sum of squares and ordinary least squares?Understanding Locally Weighted Linear RegressionCorrelation with missing values. Is least squares an acceptable option?Closed form solution of linear regression via least squares using matrix derivativesLocally Weighted Regression (Loess) - Robustifying iterationsLeast Squares Regression $Ax=b$ when $A$ is fixed and $b$ is variedDifference between output of probabilistic and ordinary least squares regressionsPartial least squares (PLS)Ordinary Least Squares - P values differing in Jupyter and Spyder for the same Multiple Linear Regression problem

Using et al. for a last / senior author rather than for a first author

ListPlot join points by nearest neighbor rather than order

Why is "Consequences inflicted." not a sentence?

Why was the term "discrete" used in discrete logarithm?

Identify plant with long narrow paired leaves and reddish stems

Can I cast Passwall to drop an enemy into a 20-foot pit?

What is the meaning of the new sigil in Game of Thrones Season 8 intro?

Should I discuss the type of campaign with my players?

How can I make names more distinctive without making them longer?

String `!23` is replaced with `docker` in command line

How come Sam didn't become Lord of Horn Hill?

The logistics of corpse disposal

How to tell that you are a giant?

Short Story with Cinderella as a Voo-doo Witch

What's the purpose of writing one's academic biography in the third person?

Should I use a zero-interest credit card for a large one-time purchase?

Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?

If a contract sometimes uses the wrong name, is it still valid?

What does the "x" in "x86" represent?

How to align text above triangle figure

What is Arya's weapon design?

What's the meaning of 間時肆拾貳 at a car parking sign

Is it true that "carbohydrates are of no use for the basal metabolic need"?

Check which numbers satisfy the condition [A*B*C = A! + B! + C!]



Adding a custom constraint to weighted least squares regression model



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Moderator Election Q&A - Questionnaire
2019 Community Moderator Election ResultsCan FTRL be applied on linear least squares? or is it just for logistic regression models?What is the difference between residual sum of squares and ordinary least squares?Understanding Locally Weighted Linear RegressionCorrelation with missing values. Is least squares an acceptable option?Closed form solution of linear regression via least squares using matrix derivativesLocally Weighted Regression (Loess) - Robustifying iterationsLeast Squares Regression $Ax=b$ when $A$ is fixed and $b$ is variedDifference between output of probabilistic and ordinary least squares regressionsPartial least squares (PLS)Ordinary Least Squares - P values differing in Jupyter and Spyder for the same Multiple Linear Regression problem










0












$begingroup$


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?










share|improve this question











$endgroup$











  • $begingroup$
    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)$
    $endgroup$
    – Juan Esteban de la Calle
    5 hours ago











  • $begingroup$
    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.
    $endgroup$
    – ste_kwr
    5 hours ago










  • $begingroup$
    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=fracc(1+e^-(beta_0+beta_1x+beta_2log(x)))$
    $endgroup$
    – Juan Esteban de la Calle
    4 hours ago
















0












$begingroup$


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?










share|improve this question











$endgroup$











  • $begingroup$
    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)$
    $endgroup$
    – Juan Esteban de la Calle
    5 hours ago











  • $begingroup$
    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.
    $endgroup$
    – ste_kwr
    5 hours ago










  • $begingroup$
    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=fracc(1+e^-(beta_0+beta_1x+beta_2log(x)))$
    $endgroup$
    – Juan Esteban de la Calle
    4 hours ago














0












0








0


2



$begingroup$


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?










share|improve this question











$endgroup$




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?







python regression linear-regression






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 9 mins ago







ste_kwr

















asked 5 hours ago









ste_kwrste_kwr

1063




1063











  • $begingroup$
    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)$
    $endgroup$
    – Juan Esteban de la Calle
    5 hours ago











  • $begingroup$
    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.
    $endgroup$
    – ste_kwr
    5 hours ago










  • $begingroup$
    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=fracc(1+e^-(beta_0+beta_1x+beta_2log(x)))$
    $endgroup$
    – Juan Esteban de la Calle
    4 hours ago

















  • $begingroup$
    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)$
    $endgroup$
    – Juan Esteban de la Calle
    5 hours ago











  • $begingroup$
    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.
    $endgroup$
    – ste_kwr
    5 hours ago










  • $begingroup$
    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=fracc(1+e^-(beta_0+beta_1x+beta_2log(x)))$
    $endgroup$
    – Juan Esteban de la Calle
    4 hours ago
















$begingroup$
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)$
$endgroup$
– Juan Esteban de la Calle
5 hours ago





$begingroup$
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)$
$endgroup$
– Juan Esteban de la Calle
5 hours ago













$begingroup$
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.
$endgroup$
– ste_kwr
5 hours ago




$begingroup$
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.
$endgroup$
– ste_kwr
5 hours ago












$begingroup$
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=fracc(1+e^-(beta_0+beta_1x+beta_2log(x)))$
$endgroup$
– Juan Esteban de la Calle
4 hours ago





$begingroup$
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=fracc(1+e^-(beta_0+beta_1x+beta_2log(x)))$
$endgroup$
– Juan Esteban de la Calle
4 hours ago











1 Answer
1






active

oldest

votes


















0












$begingroup$

The model you are looking for is this:



$Y=fracA1+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(E)


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






share|improve this answer








New contributor




Juan Esteban de la Calle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$













    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "557"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f49428%2fadding-a-custom-constraint-to-weighted-least-squares-regression-model%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0












    $begingroup$

    The model you are looking for is this:



    $Y=fracA1+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(E)


    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






    share|improve this answer








    New contributor




    Juan Esteban de la Calle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






    $endgroup$

















      0












      $begingroup$

      The model you are looking for is this:



      $Y=fracA1+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(E)


      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






      share|improve this answer








      New contributor




      Juan Esteban de la Calle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      $endgroup$















        0












        0








        0





        $begingroup$

        The model you are looking for is this:



        $Y=fracA1+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(E)


        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






        share|improve this answer








        New contributor




        Juan Esteban de la Calle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        $endgroup$



        The model you are looking for is this:



        $Y=fracA1+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(E)


        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







        share|improve this answer








        New contributor




        Juan Esteban de la Calle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        Juan Esteban de la Calle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 3 hours ago









        Juan Esteban de la CalleJuan Esteban de la Calle

        36011




        36011




        New contributor




        Juan Esteban de la Calle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        Juan Esteban de la Calle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        Juan Esteban de la Calle is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Data Science Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f49428%2fadding-a-custom-constraint-to-weighted-least-squares-regression-model%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Францішак Багушэвіч Змест Сям'я | Біяграфія | Творчасць | Мова Багушэвіча | Ацэнкі дзейнасці | Цікавыя факты | Спадчына | Выбраная бібліяграфія | Ушанаванне памяці | У філатэліі | Зноскі | Літаратура | Спасылкі | НавігацыяЛяхоўскі У. Рупіўся дзеля Бога і людзей: Жыццёвы шлях Лявона Вітан-Дубейкаўскага // Вольскі і Памідораў з песняй пра немца Адвакат, паэт, народны заступнік Ашмянскі веснікВ Минске появится площадь Богушевича и улица Сырокомли, Белорусская деловая газета, 19 июля 2001 г.Айцец беларускай нацыянальнай ідэі паўстаў у бронзе Сяргей Аляксандравіч Адашкевіч (1918, Мінск). 80-я гады. Бюст «Францішак Багушэвіч».Яўген Мікалаевіч Ціхановіч. «Партрэт Францішка Багушэвіча»Мікола Мікалаевіч Купава. «Партрэт зачынальніка новай беларускай літаратуры Францішка Багушэвіча»Уладзімір Іванавіч Мелехаў. На помніку «Змагарам за родную мову» Барэльеф «Францішак Багушэвіч»Памяць пра Багушэвіча на Віленшчыне Страчаная сталіца. Беларускія шыльды на вуліцах Вільні«Krynica». Ideologia i przywódcy białoruskiego katolicyzmuФранцішак БагушэвічТворы на knihi.comТворы Францішка Багушэвіча на bellib.byСодаль Уладзімір. Францішак Багушэвіч на Лідчыне;Луцкевіч Антон. Жыцьцё і творчасьць Фр. Багушэвіча ў успамінах ягоных сучасьнікаў // Запісы Беларускага Навуковага таварыства. Вільня, 1938. Сшытак 1. С. 16-34.Большая российская1188761710000 0000 5537 633Xn9209310021619551927869394п

            Partai Komunis Tiongkok Daftar isi Kepemimpinan | Pranala luar | Referensi | Menu navigasidiperiksa1 perubahan tertundacpc.people.com.cnSitus resmiSurat kabar resmi"Why the Communist Party is alive, well and flourishing in China"0307-1235"Full text of Constitution of Communist Party of China"smengembangkannyas

            ValueError: Expected n_neighbors <= n_samples, but n_samples = 1, n_neighbors = 6 (SMOTE) The 2019 Stack Overflow Developer Survey Results Are InCan SMOTE be applied over sequence of words (sentences)?ValueError when doing validation with random forestsSMOTE and multi class oversamplingLogic behind SMOTE-NC?ValueError: Error when checking target: expected dense_1 to have shape (7,) but got array with shape (1,)SmoteBoost: Should SMOTE be ran individually for each iteration/tree in the boosting?solving multi-class imbalance classification using smote and OSSUsing SMOTE for Synthetic Data generation to improve performance on unbalanced dataproblem of entry format for a simple model in KerasSVM SMOTE fit_resample() function runs forever with no result