An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20101213/73eaf70b/attachment.pl>
multivariate multi regression
7 messages · Joe King, Bastiaan Bergman, David Winsemius +2 more
On Dec 13, 2010, at 8:46 PM, Bastiaan Bergman wrote:
Hello, I want to model my data with the following model: Y1=X1*coef1+X2*coef2 Y2=X1*coef2+X2*coef3 Note: coef2 appears in both lines Xi, Yi is input versus output data respectively How can I do this in R? I got this far: lm(Y1~X1+X2,mydata) now how do I add the second line of the model including the cross dependency?
The usual way would be to extract coef2 from the object returned from the first invocation of lm(...) and use it to calculate an offset term in a second model. It would not have any variance calculated since you are forcing it to be what was returned in the first model. Now, what is it that you are really trying to do with this procedure?
David. David Winsemius, MD West Hartford, CT
I am not even sure what model you are trying to run, you are talking about regression slopes for x1 being coef1, and coef2 being the slope for x2, where are you getting coef3 from, is it in your data? Joe King 206-913-2912 jp at joepking.com "Never throughout history has a man who lived a life of ease left a name worth remembering." --Theodore Roosevelt -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of David Winsemius Sent: Monday, December 13, 2010 6:06 PM To: Bastiaan Bergman Cc: r-help at r-project.org Subject: Re: [R] multivariate multi regression
On Dec 13, 2010, at 8:46 PM, Bastiaan Bergman wrote:
Hello, I want to model my data with the following model: Y1=X1*coef1+X2*coef2 Y2=X1*coef2+X2*coef3 Note: coef2 appears in both lines Xi, Yi is input versus output data respectively How can I do this in R? I got this far: lm(Y1~X1+X2,mydata) now how do I add the second line of the model including the cross dependency?
The usual way would be to extract coef2 from the object returned from the first invocation of lm(...) and use it to calculate an offset term in a second model. It would not have any variance calculated since you are forcing it to be what was returned in the first model. Now, what is it that you are really trying to do with this procedure?
David. David Winsemius, MD West Hartford, CT ______________________________________________ R-help at 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.
That doesn't work, one would get two different answers depending on the order of execution. The physics is: Overlay error on a Silicon wafer. One wafer has many flash fields, each flash field has multiple locations where the overlay error is measured (as: dX,dY offset). If one contemplates that the error is caused by a rotation of the flash field then we can say (dX,dY)=(-Y,X)*RotAngle. If in addition we have a scaling error: (dX,dY)=(X*XScale,Y*YScale) than the total model is: dX~X*XScale-Y*RotAngle dY~Y*YScale+X*RotAngle Now I want to find the values for XScale, YScale and RotAngle Length(dX)==length(dY)==length(X)==length(Y)==number of measured sites on a wafer Hope this clarifies... -----Original Message----- From: David Winsemius [mailto:dwinsemius at comcast.net] Sent: Monday, December 13, 2010 6:06 PM To: Bastiaan Bergman Cc: r-help at r-project.org Subject: Re: [R] multivariate multi regression
On Dec 13, 2010, at 8:46 PM, Bastiaan Bergman wrote:
Hello, I want to model my data with the following model: Y1=X1*coef1+X2*coef2 Y2=X1*coef2+X2*coef3 Note: coef2 appears in both lines Xi, Yi is input versus output data respectively How can I do this in R? I got this far: lm(Y1~X1+X2,mydata) now how do I add the second line of the model including the cross dependency?
The usual way would be to extract coef2 from the object returned from the first invocation of lm(...) and use it to calculate an offset term in a second model. It would not have any variance calculated since you are forcing it to be what was returned in the first model. Now, what is it that you are really trying to do with this procedure?
David. David Winsemius, MD West Hartford, CT
On Dec 13, 2010, at 9:21 PM, Bastiaan Bergman wrote:
That doesn't work, one would get two different answers depending on the order of execution. The physics is: Overlay error on a Silicon wafer. One wafer has many flash fields, each flash field has multiple locations where the overlay error is measured (as: dX,dY offset). If one contemplates that the error is caused by a rotation of the flash field then we can say (dX,dY)=(-Y,X)*RotAngle.
Some sort of linearized approximation of a rotation matrix?
If in addition we have a scaling error: (dX,dY)=(X*XScale,Y*YScale) than the total model is: dX~X*XScale-Y*RotAngle dY~Y*YScale+X*RotAngle Now I want to find the values for XScale, YScale and RotAngle
... that does _what_? Minimize the sum of squares of dY and dX?
Length(dX)==length(dY)==length(X)==length(Y)==number of measured sites on a wafer
So dY and dX are measured and X and Y are measured how many times? And are we doing this for several different wafers so that we need to have nested models that incorporate an error term for each wafer? (And if that is the case this may need to be transferred to the mixed- models mailing list or at the very least answered by someone with a better ax swing for such complexities that I can wield.)
David > > Hope this clarifies... > > > -----Original Message----- > From: David Winsemius [mailto:dwinsemius at comcast.net] > Sent: Monday, December 13, 2010 6:06 PM > To: Bastiaan Bergman > Cc: r-help at r-project.org > Subject: Re: [R] multivariate multi regression > > > On Dec 13, 2010, at 8:46 PM, Bastiaan Bergman wrote: > >> Hello, >> >> I want to model my data with the following model: >> >> Y1=X1*coef1+X2*coef2 >> Y2=X1*coef2+X2*coef3 >> >> Note: coef2 appears in both lines >> >> Xi, Yi is input versus output data respectively >> >> How can I do this in R? >> >> I got this far: >> >> lm(Y1~X1+X2,mydata) >> >> now how do I add the second line of the model including the cross >> dependency? > > The usual way would be to extract coef2 from the object returned from > the first invocation of lm(...) and use it to calculate an offset > term in a second model. It would not have any variance calculated > since you are forcing it to be what was returned in the first model. > Now, what is it that you are really trying to do with this procedure? > > -- David Winsemius, MD West Hartford, CT
On Dec 14, 2010, at 03:21 , Bastiaan Bergman wrote:
That doesn't work, one would get two different answers depending on the order of execution. The physics is: Overlay error on a Silicon wafer. One wafer has many flash fields, each flash field has multiple locations where the overlay error is measured (as: dX,dY offset). If one contemplates that the error is caused by a rotation of the flash field then we can say (dX,dY)=(-Y,X)*RotAngle. If in addition we have a scaling error: (dX,dY)=(X*XScale,Y*YScale) than the total model is: dX~X*XScale-Y*RotAngle dY~Y*YScale+X*RotAngle Now I want to find the values for XScale, YScale and RotAngle Length(dX)==length(dY)==length(X)==length(Y)==number of measured sites on a wafer Hope this clarifies...
Not completely, but I can see the general picture. I think the main thing is to rewrite the formula as dX = XScale * X + YScale * 0 + RotAngle * (-Y) + eX dY = XScale * 0 + YScale * Y + RotAngle * X + eY (where eX and eY are noise terms) Then string together all your data pairs as dX1 dY1 dX2 dY2 ... and the corresponding design matrix X1 0 -Y1 0 Y1 X1 X2 0 -Y2 0 Y2 X2 ... This sets up the joint linear model that you want. (Technically, it could be easier to put all the dX's first, then all the dY's, though.) The remaining question is what you assume about the eX and eY terms. If they can be assumed to be independent and have the same variance, you're done. If they are correlated and/or have different variance, then I think you need to look in the direction of lme() with a suitable variance function.
-----Original Message----- From: David Winsemius [mailto:dwinsemius at comcast.net] Sent: Monday, December 13, 2010 6:06 PM To: Bastiaan Bergman Cc: r-help at r-project.org Subject: Re: [R] multivariate multi regression On Dec 13, 2010, at 8:46 PM, Bastiaan Bergman wrote:
Hello, I want to model my data with the following model: Y1=X1*coef1+X2*coef2 Y2=X1*coef2+X2*coef3 Note: coef2 appears in both lines Xi, Yi is input versus output data respectively How can I do this in R? I got this far: lm(Y1~X1+X2,mydata) now how do I add the second line of the model including the cross dependency?
The usual way would be to extract coef2 from the object returned from the first invocation of lm(...) and use it to calculate an offset term in a second model. It would not have any variance calculated since you are forcing it to be what was returned in the first model. Now, what is it that you are really trying to do with this procedure? -- David. David Winsemius, MD West Hartford, CT
______________________________________________ R-help at 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.
Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
----------------------------------------
From: pdalgd at gmail.com Date: Tue, 14 Dec 2010 13:50:27 +0100 To: Bastiaan.Bergman at wdc.com CC: r-help at r-project.org Subject: Re: [R] multivariate multi regression On Dec 14, 2010, at 03:21 , Bastiaan Bergman wrote:
That doesn't work, one would get two different answers depending on the order of execution. The physics is: Overlay error on a Silicon wafer. One wafer has many flash fields, each flash field has multiple locations where the overlay error is measured (as: dX,dY offset). If one contemplates that the error is caused by a rotation of the flash field then we can say (dX,dY)=(-Y,X)*RotAngle. If in addition we have a scaling error: (dX,dY)=(X*XScale,Y*YScale) than the total model is: dX~X*XScale-Y*RotAngle dY~Y*YScale+X*RotAngle
First of course if you have a model it would help to get the equations right for tanslation, scale, and rotation around an arbitrary origin. If you can live with 3D, there may be something in the bio packages for aligning molecules with no assumptions about their relative initial orientations. Anyone know off hand if objection alignment exists in any bio or mapping packages? I would imagine related tasks come up in building a coherent map out of overlapping pieces, something which may have significant support too.
Now I want to find the values for XScale, YScale and RotAngle Length(dX)==length(dY)==length(X)==length(Y)==number of measured sites on a wafer Hope this clarifies...
Not completely, but I can see the general picture. I think the main thing is to rewrite the formula as dX = XScale * X + YScale * 0 + RotAngle * (-Y) + eX dY = XScale * 0 + YScale * Y + RotAngle * X + eY (where eX and eY are noise terms) Then string together all your data pairs as dX1 dY1 dX2 dY2 ... and the corresponding design matrix X1 0 -Y1 0 Y1 X1 X2 0 -Y2 0 Y2 X2 ... This sets up the joint linear model that you want. (Technically, it could be easier to put all the dX's first, then all the dY's, though.) The remaining question is what you assume about the eX and eY terms. If they can be assumed to be independent and have the same variance, you're done. If they are correlated and/or have different variance, then I think you need to look in the direction of lme() with a suitable variance function.
-----Original Message----- From: David Winsemius [mailto:dwinsemius at comcast.net] Sent: Monday, December 13, 2010 6:06 PM To: Bastiaan Bergman Cc: r-help at r-project.org Subject: Re: [R] multivariate multi regression On Dec 13, 2010, at 8:46 PM, Bastiaan Bergman wrote:
Hello, I want to model my data with the following model: Y1=X1*coef1+X2*coef2 Y2=X1*coef2+X2*coef3 Note: coef2 appears in both lines Xi, Yi is input versus output data respectively How can I do this in R? I got this far: lm(Y1~X1+X2,mydata) now how do I add the second line of the model including the cross dependency?
The usual way would be to extract coef2 from the object returned from the first invocation of lm(...) and use it to calculate an offset term in a second model. It would not have any variance calculated since you are forcing it to be what was returned in the first model. Now, what is it that you are really trying to do with this procedure? -- David. David Winsemius, MD West Hartford, CT
______________________________________________ R-help at 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.
-- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
______________________________________________ R-help at 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.