Skip to main content
20 events
when toggle format what by license comment
Sep 10, 2014 at 14:54 comment added whuber No, I think it means something is not quite right about the code in the present solution. Perhaps I just am not interpreting its output correctly...
Sep 10, 2014 at 10:10 comment added Datageek @whuber Does it mean linear regression is not as good as some other solvers in this case? I originally used Excel solver and got really close results as well. I need to solve this problem in R, and preferably with one of the cran libraries that doesn't require installation of additional software.
Sep 9, 2014 at 14:04 comment added Sycorax @whuber You're right that the results are incredibly precise. But b_hat is simply computed from the drawn (and transformed) sim_x value, so it is evaluated once for each draw. b_hat is not read in as if it were data.
Sep 9, 2014 at 14:00 comment added whuber There are problems with such a comparison, Datageek. First, the constraints automatically hold for any reasonable fit to these data. Second, the results shown in this answer are way too good: the distributions of the estimates are far too narrow (by one to two orders of magnitude) to be consistent with the actual data. Since I'm unfamiliar with rstan I cannot diagnose the problem. I believe, though, that it is unfairly using the true parameters b_hat in a simulation, so it is unclear to me to what extent it actually is testing the fitting procedure at all.
Sep 9, 2014 at 12:25 comment added Sycorax If you use weighted least squares with the data in my snippet, the parameter estimates satisfy the constraint. There's not too much to show.
Sep 9, 2014 at 12:17 history edited Sycorax CC BY-SA 3.0
deleted 269 characters in body
Sep 9, 2014 at 10:12 comment added Datageek @whuber this is great, thanks. Would you mind adding this as an answer? Would be great to see it produces the same results on the same data as user777.
Sep 8, 2014 at 20:50 comment added Sycorax With the expanded explanation, your meaning is, indeed, obvious. The great thing about CV is that I literally never stop learning.
Sep 8, 2014 at 19:54 comment added whuber The second one, if it exists, is guaranteed to meet the constraints, by construction. Otherwise, there is no solution. (But there always will be when the weights are positive.) Here's an example: fit a line $y=ax+b$ to $(x,y)$ data with the constraint $a+b\le 5$. If the OLS estimates do not satisfy that constraint, now fit the model $y=ax+5-a$ to those data. (You could easily do that by fitting the no-intercept model $y-5=a(x-1)$ to the data $(x-1,y-5)$, for instance.) I hope it's obvious the constraint will be met and that no special software is needed.
Sep 8, 2014 at 19:32 comment added Sycorax @whuber I'm not sure I fully understand. What happens when neither solutions meets the constraints?
Sep 8, 2014 at 19:30 comment added whuber I'm not exactly sure what @ssdecontrol is referring to :-), but as far as the other answers go, one (as I recall) suggested finding the weighted least squares solution. If it does not satisfy the constraint, then find the equality-constrained solution. Observe that (1) this requires only two least squares calculations, so it is efficient and fast and (2) in either case you obtain a covariance matrix for the estimates. Continuing in the analogical vein, that would make this problem about as easy as breaking a saltine into your soup, so you can put away the jackhammer :-).
Sep 8, 2014 at 19:24 comment added shadowtalker When you have a jackhammer, everything looks like a sidewalk.
Sep 8, 2014 at 18:43 comment added Datageek This is awesome, thanks @user777! I wonder how difficult it would be to do the same with one of the methods @whuber suggested.
Sep 8, 2014 at 18:29 vote accept Datageek
Sep 10, 2014 at 18:28
Sep 8, 2014 at 18:13 history edited Sycorax CC BY-SA 3.0
deleted 617 characters in body
Sep 8, 2014 at 17:19 history undeleted Sycorax
Sep 8, 2014 at 15:57 history deleted Sycorax via Vote
Sep 8, 2014 at 15:35 history edited Sycorax CC BY-SA 3.0
added 35 characters in body
Sep 8, 2014 at 15:28 history edited Sycorax CC BY-SA 3.0
added 35 characters in body
Sep 8, 2014 at 15:20 history answered Sycorax CC BY-SA 3.0