Re: [R] Weighted SUR/NSUR

2013-08-20 Thread Arne Henningsen
Dear Ariel

Thank you for your detailed explanations and the example. Indeed, it
should be rather straightforward to implement observation-specific
weights in systemfit (i.e. in the estimation of systems of linear or
non-linear equations). As you indicated that many people are looking
for this feature, I wonder if I should start a crowd-funding
campaign...

Best regards,
Arne


On 16 August 2013 18:23, Ariel ariel.muld...@oregonstate.edu wrote:
 Arne Henningsen-3 wrote
 Is it possible
 to run SUR with weights using systemfit? I mean weighted seemingly
 unrelated
 regression (weighted SUR)

 Currently, systemfit cannot estimate (SUR) models with
 observation-specific
 weights :-(

 or weighted nonlinear unrelated regression (weighted NSUR).

 We are still not yet finished with implementing nonlinear models in
 systemfit (see http://www.systemfit.org/) :-(

 I recently had a student come to me with a very similar (okay, identical)
 problem as the OP.  I had to learn PROC MODEL, anyway, so I thought I’d poke
 around in R while I was at it.  I have nothing to add about any problems
 with or the lack of maturity of the estimation procedure for nlsystemfit(),
 but I do have some ideas about observation-level weights.

 It took me awhile to make the leap from the fairly straightforward linear
 weighted least squares (for example, see  Weisberg's Applied Linear
 Regression textbook equation 5.8) to understanding how weighting worked in
 nonlinear least squares.  The R help forum certainly came in handy:
 https://stat.ethz.ch/pipermail/r-help/2004-November/060424.html.  I can add
 weights into a nonlinear regression by simply multiplying both the response
 and the nonlinear function by the square root of the desired weights.
 Here’s a toy example, where I compare a model fit using the “weights”
 argument in nls() with a model where I put the weights in “by hand” :

 DNase1 = subset(DNase, Run == 1)
 fit2 = nls(density ~ Asym/(1 + exp((xmid - log(conc))/scal)),
  data = DNase1,
  start = list(Asym = 3, xmid = 0, scal = 1), weights =
 rep(1:8, each = 2))
 summary(fit2)

 # Take the square root of the weights for fitting “by hand”
 sw = sqrt(rep(1:8, each = 2) )
 fit3 = nls(sw*density ~ sw*(Asym/(1 + exp((xmid - log(conc))/scal))),
 DNase1,
  start = list(Asym = 3, xmid = 0, scal = 1) )
 summary(fit3)

 # The predicted values for fit3 need to be divided by the weights
 # but the residuals are weighted residuals
 predict(fit2)
 predict(fit3)/sw

 It seems like this weighted approach could be easily extended to the model
 formulas for a system of nonlinear equations (it would be similar for linear
 equations) to be fit with systemfit.

  Parresol (2001) in his paper
 titled Additivity of nonlinear biomass
 equations has run weighted NSUR using PROC MODEL (SAS institute Inc.1993).
 I was wondering if r can do that.

 It turned out I had to use this weighting approach in PROC MODEL, as well,
 when each equation in the system had a different set of weights.  The
 estimates I get when fitting the Parresol example mentioned by the OP using
 nlsystemfit and PROC MODEL are within spitting distance of each other, so I
 feel like I am at least making the same mistakes in both software packages.

 I'm wondering if my logic is sound or if I'm missing some complication that
 occurs when working with systems of equations.  I’ve seen several folks
 looking to fit weighted systems of equations in R with systemfit, and this
 approach might get them what they need.

 Ariel



 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Weighted-SUR-NSUR-tp4670602p4673973.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



-- 
Arne Henningsen
http://www.arne-henningsen.name

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Weighted SUR/NSUR

2013-08-16 Thread Ariel
Arne Henningsen-3 wrote
 Is it possible
 to run SUR with weights using systemfit? I mean weighted seemingly
 unrelated
 regression (weighted SUR)
 
 Currently, systemfit cannot estimate (SUR) models with
 observation-specific
 weights :-(
 
 or weighted nonlinear unrelated regression (weighted NSUR).
 
 We are still not yet finished with implementing nonlinear models in
 systemfit (see http://www.systemfit.org/) :-(

I recently had a student come to me with a very similar (okay, identical)
problem as the OP.  I had to learn PROC MODEL, anyway, so I thought I’d poke
around in R while I was at it.  I have nothing to add about any problems
with or the lack of maturity of the estimation procedure for nlsystemfit(),
but I do have some ideas about observation-level weights.

It took me awhile to make the leap from the fairly straightforward linear
weighted least squares (for example, see  Weisberg's Applied Linear
Regression textbook equation 5.8) to understanding how weighting worked in
nonlinear least squares.  The R help forum certainly came in handy:
https://stat.ethz.ch/pipermail/r-help/2004-November/060424.html.  I can add
weights into a nonlinear regression by simply multiplying both the response
and the nonlinear function by the square root of the desired weights. 
Here’s a toy example, where I compare a model fit using the “weights”
argument in nls() with a model where I put the weights in “by hand” :

DNase1 = subset(DNase, Run == 1)
fit2 = nls(density ~ Asym/(1 + exp((xmid - log(conc))/scal)),
 data = DNase1,
 start = list(Asym = 3, xmid = 0, scal = 1), weights =
rep(1:8, each = 2))
summary(fit2)

# Take the square root of the weights for fitting “by hand”
sw = sqrt(rep(1:8, each = 2) )
fit3 = nls(sw*density ~ sw*(Asym/(1 + exp((xmid - log(conc))/scal))),
DNase1,
 start = list(Asym = 3, xmid = 0, scal = 1) )
summary(fit3)

# The predicted values for fit3 need to be divided by the weights 
# but the residuals are weighted residuals
predict(fit2)
predict(fit3)/sw

It seems like this weighted approach could be easily extended to the model
formulas for a system of nonlinear equations (it would be similar for linear
equations) to be fit with systemfit.  

  Parresol (2001) in his paper
 titled Additivity of nonlinear biomass
 equations has run weighted NSUR using PROC MODEL (SAS institute Inc.1993).
 I was wondering if r can do that.

It turned out I had to use this weighting approach in PROC MODEL, as well,
when each equation in the system had a different set of weights.  The
estimates I get when fitting the Parresol example mentioned by the OP using
nlsystemfit and PROC MODEL are within spitting distance of each other, so I
feel like I am at least making the same mistakes in both software packages.  

I'm wondering if my logic is sound or if I'm missing some complication that
occurs when working with systems of equations.  I’ve seen several folks
looking to fit weighted systems of equations in R with systemfit, and this
approach might get them what they need.

Ariel



--
View this message in context: 
http://r.789695.n4.nabble.com/Weighted-SUR-NSUR-tp4670602p4673973.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Weighted SUR/NSUR

2013-06-30 Thread Arne Henningsen
Dear Tarquinio

On 29 Jun 2013 21:01, Tarquinio magalhaes tarq...@yahoo.com.br wrote:
 Is it possible
 to run SUR with weights using systemfit? I mean weighted seemingly
unrelated
 regression (weighted SUR)

Currently, systemfit cannot estimate (SUR) models with observation-specific
weights :-(

 or weighted nonlinear unrelated regression (weighted NSUR).

We are still not yet finished with implementing nonlinear models in
systemfit (see http://www.systemfit.org/) :-(

  Parresol (2001) in his paper
 titled Additivity of nonlinear biomass
 equations has run weighted NSUR using PROC MODEL (SAS institute Inc.1993).
 I was wondering if r can do that.

Unfortunately not (see above). As several people have asked for
observation-specific weights and NSUR, I should perhaps start a
crowd-funding initiative for implementing these features.

BTW: You can ask questions that are specific to systemfit via the help
forum at systemfit's R-Forge site:
https://r-forge.r-project.org/projects/systemfit/

Best wishes,
Arne

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Weighted SUR/NSUR

2013-06-29 Thread Tarquinio magalhaes
Hi,
Is it possible
to run SUR with weights using systemfit? I mean weighted seemingly unrelated
regression (weighted SUR) or weighted nonlinear unrelated regression (weighted
NSUR).  Parresol (2001) in his paper
titled Additivity of nonlinear biomass
equations has run weighted NSUR using PROC MODEL (SAS institute Inc.1993).
I was wondering if r can do that. Thanks.
Tarquinio Mateus
Magalhães

___
Tarquinio Mateus Magalhães
www.tarqmag.blogspot.com
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.