RE: [R] Errors in Variables

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 03 Jun 2005 - 00:55:46 EST

On Sun, 29 May 2005, John Fox wrote:

> Dear Spencer,
>
>> -----Original Message-----
>> From: Spencer Graves [mailto:spencer.graves@pdf.com]
>> Sent: Sunday, May 29, 2005 4:13 PM
>> To: John Fox
>> Cc: r-help@stat.math.ethz.ch; 'Jacob van Wyk'; 'Eric-Olivier Le Bigot'
>> Subject: Re: [R] Errors in Variables
>>
>> Hi, John:
>>
>> Thanks for the clarification. I know that the
>> "errors in X problem"
>> requires additional information, most commonly one of the
>> variances or the correlation. The question I saw (below)
>> indicated he had tried "model of the form y ~ x (with a given
>> covariance matrix ...)", which made me think of "sem".
>>
>> If he wants "the least (orthogonal) distance", could
>> he could get it indirectly from "sem" by calling "sem"
>> repeatedly giving, say, a variance for "x", then averaging
>> the variances of "x" and "y" and trying that in "sem"?
>>
>
> I'm not sure how that would work, but seems similar to averaging the
> regressions of y on x and x on y.
>
>> Also, what do you know about "ODRpack"? It looks
>> like that might solve "the least (orthogonal) distance".
>>
>
> I'm not familiar with ODRpack, but it seems to me that one could fairly
> simply minimize the sum of squared least distances using, e.g., optim.

Exactly. In fact this is easily reduced to a function of one variable (the slope, known to lie between the y or x and x om y regressions) and so optimize() would be more appropriate. I did do that in S once upon a long time, but it seemed too esoteric to package up (and it would take me longer to find the code than to do it again).

My paper quoted originally deals with the case of known variances for each of x and y (and heteroscedasticity in both). It was written for chemists, and contains all the formulae one needs. In their applications knowing (at least approximately) the variances is a reasonable assumption.

Brian

>> Thanks again for your note, John.
>> Best Wishes,
>> Spencer Graves
>>
>> John Fox wrote:
>>
>>> Dear Spencer,
>>>
>>> The reason that I didn't respond to the original posting (I'm the
>>> author of the sem package), that that without additional
>> information
>>> (such as the error variance of x), a model with error in
>> both x and y
>>> will be underidentified (unless there are multiple indicators of x,
>>> which didn't seem to be the case here). I figured that what
>> Jacob had
>>> in mind was something like minimizing the least
>> (orthogonal) distance
>>> of the points to the regression line (implying by the way
>> that x and y
>>> are on the same scale or somehow standardized), which isn't
>> doable with sem as far as I'm aware.
>>>
>>> Regards,
>>> John
>>>
>>> --------------------------------
>>> John Fox
>>> Department of Sociology
>>> McMaster University
>>> Hamilton, Ontario
>>> Canada L8S 4M4
>>> 905-525-9140x23604
>>> http://socserv.mcmaster.ca/jfox
>>> --------------------------------
>>>
>>>
>>>> -----Original Message-----
>>>> From: r-help-bounces@stat.math.ethz.ch
>>>> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of
>> Spencer Graves
>>>> Sent: Saturday, May 28, 2005 4:47 PM
>>>> To: Eric-Olivier Le Bigot
>>>> Cc: r-help@stat.math.ethz.ch; Jacob van Wyk
>>>> Subject: Re: [R] Errors in Variables
>>>>
>>>> I'm sorry, I have not followed this thread, but I
>> wonder if you
>>>> have considered library(sem), "structural equations modeling"?
>>>> "Errors in variables" problems are the canonical special case.
>>>>
>>>> Also, have you done a search of "www.r-project.org"
>>>> -> search -> "R site search" for terms like "errors in
>>>> variables regression"? This just led me to "ODRpack",
>> which is NOT a
>>>> CRAN package but is apparently available after a Google
>> search. If it
>>>> were my problem, I'd first try to figure out "sem"; if that seemed
>>>> too difficult, I might then look at "ODRpack".
>>>>
>>>> Also, have you read the posting guide!
>>>> http://www.R-project.org/posting-guide.html? This suggests, among
>>>> other things, that you provide a toy example that a potential
>>>> respondant could easily copy from your email, test a few
>>>> modifications, and prase a reply in a minute or so.
>>>> This also helps clarify your question so any respondants are more
>>>> likely to suggest something that is actually useful to you.
>> Moreover,
>>>> many people have reported that they were able to answer their own
>>>> question in the course of preparing a question for this
>> list using the
>>>> posting guide.
>>>>
>>>> hope this helps. spencer graves
>>>>
>>>> Eric-Olivier Le Bigot wrote:
>>>>
>>>>
>>>>> I'm interested in this "2D line fitting" too! I've been looking,
>>>>> without success, in the list of R packages.
>>>>>
>>>>> It might be possible to implement quite easily some of the
>>>>
>>>> formalism
>>>>
>>>>> that you can find in Numerical Recipes (Fortran 77, 2nd ed.),
>>>>> paragraph 15.3. As a matter of fact, I did this in R but
>>>>
>>>> only for a
>>>>
>>>>> model of the form y ~ x (with a given covariance matrix
>>>>
>>>> between x and
>>>>
>>>>> y). I can send you the R code (preliminary version: I
>>>>
>>>> wrote it yesterday), if you want.
>>>>
>>>>> Another interesting reference might be Am. J. Phys. 60, p.
>>>>
>>>> 66 (1992).
>>>>
>>>>> But, again, you would have to implement things by yourself.
>>>>>
>>>>> All the best,
>>>>>
>>>>> EOL
>>>>>
>>>>> --
>>>>> Dr. Eric-Olivier LE BIGOT (EOL) CNRS
>>>>
>>>> Associate Researcher
>>>>
>>>> ~~~o~o~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>> ~~~~o~o~~~
>>>>
>>>>> Kastler Brossel Laboratory (LKB)
>>>>
>>>> http://www.lkb.ens.fr
>>>>
>>>>> Université P. & M. Curie and Ecole Normale Supérieure, Case 74
>>>>> 4 place Jussieu 75252 Paris CEDEX 05
>>>>
>>>> France
>>>>
>>>> ~~~o~o~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>> ~~~~o~o~~~
>>>>
>>>>> office : 01 44 27 73 67 fax:
>>>>
>>>> 01 44 27 38 45
>>>>
>>>>> ECR room: 01 44 27 47 12 x-ray room:
>>>>
>>>> 01 44 27 63 00
>>>>
>>>>> home: 01 73 74 61 87 For int'l calls: 33 + number
>>>>
>>>> without leading 0
>>>>
>>>>>
>>>>> On Wed, 25 May 2005, Jacob van Wyk wrote:
>>>>>
>>>>>
>>>>>> I hope somebody can help.
>>>>>> A student of mine is doing a study on Measurement Error models
>>>>>> (errors-in-variables, total least squares, etc.). I have an old
>>>>>> reference to a "multi archive" that contains
>>>>>> leiv3: Programs for best line fitting with errors in both
>>>>
>>>> coordinates.
>>>>
>>>>>> (The date is October 1989, by B.D. Ripley et al.) I have done a
>>>>>> search for something similar in R withour success. Has this been
>>>>>> implemented in a R-package, possibly under some sort of
>>>>
>>>> assumptions
>>>>
>>>>>> about variances. I would lke my student to apply some regression
>>>>>> techniques to data that fit this profile.
>>>>>> Any help is much appreciated.
>>>>>> (If I have not done my search more carefully - my
>>>>
>>>> apologies.) Thanks
>>>>
>>>>>> Jacob
>>>>>>
>>>>>>
>>>>>> Jacob L van Wyk
>>>>>> Department of Mathematics and Statistics University of
>>>>
>>>> Johannesburg
>>>>
>>>>>> APK P O Box 524 Auckland Park 2006 South Africa
>>>>>> Tel: +27-11-489-3080
>>>>>> Fax: +27-11-489-2832
>>>>>>
>>>>>> ______________________________________________
>>>>>> R-help@stat.math.ethz.ch mailing list
>>>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>>>> PLEASE do read the posting guide!
>>>>>> http://www.R-project.org/posting-guide.html
>>>>>>
>>>>>
>>>>>
>>>> ------------------------------------------------------------
>> ----------
>>>>
>>>>> --
>>>>>
>>>>> ______________________________________________
>>>>> R-help@stat.math.ethz.ch mailing list
>>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>>> PLEASE do read the posting guide!
>>>>> http://www.R-project.org/posting-guide.html
>>>>
>>>> ______________________________________________
>>>> R-help@stat.math.ethz.ch mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide!
>>>> http://www.R-project.org/posting-guide.html
>>>
>>>
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Received on Fri Jun 03 01:02:32 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:21 EST