[R] Errors in Variables
John Sorkin
jsorkin at grecc.umaryland.edu
Tue May 31 18:39:40 CEST 2005
I have a routine that corrects regression coefficients for the bias towards zero that occurs when there is error in the measurement of the independent variable. The code only works for a single independent variable, i.e. y~x. At this time the program does not calculate the SE of the coefficient. The program uses properly weighted perpendicular least squares regression. I would be happy to share the code if asked to do so by anyone who has participated in this thread.
John
John Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
Baltimore VA Medical Center GRECC and
University of Maryland School of Medicine Claude Pepper OAIC
University of Maryland School of Medicine
Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
410-605-7119
- NOTE NEW EMAIL ADDRESS:
jsorkin at grecc.umaryland.edu
>>> "John Fox" <jfox at mcmaster.ca> 5/29/2005 5:56:10 PM >>>
Dear Spencer,
> -----Original Message-----
> From: Spencer Graves [mailto:spencer.graves at pdf.com]
> Sent: Sunday, May 29, 2005 4:13 PM
> To: John Fox
> Cc: r-help at 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.
Regards,
John
> 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 at stat.math.ethz.ch
> >>[mailto:r-help-bounces at 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 at 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 at 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 at 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 at 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 at 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
More information about the R-help
mailing list