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.