[R] Regression with ranges and displaying them in an XY-Plot

Johannes Radinger JRadinger at gmx.at
Fri Aug 5 11:02:20 CEST 2011


Hello UseRs, 

just some additional questions to my post below:

I have now an idea how I want to solve my question with the intervals as input for regression.

a probable approach

Y <- dependent
X1 <- first independent
X2 <- runif(X2a, X2b)

and then the standard approach
lm(Y~X1+X2)

now just some questions:
* how can I use runif(X2a, X2b) so that a whole vector is calculated?
Do I have to use it in a for-loop. If I have defined the variables
X2a and X2b and try runif(X2a, X2b) only the first value is calculated.

*how can I repeat the lm function several (lets say 10000) times, so that every time a new random number is generated and the regression is calculated. And how can that be then summarized, like the mean regression coeeficients etc? I don't know what is the appropriate tool for that.

thank you
/Johannes




Message: 11
Date: Thu, 28 Jul 2011 14:49:00 +0200
From: "Johannes Radinger" <JRadinger at gmx.at>
To: r-help at r-project.org
Subject: [R] Regression with ranges and displaying them in an XY-Plot
Message-ID: <20110728124900.198380 at gmx.net>
Content-Type: text/plain; charset="utf-8"

Hello UseRs,

I've got 3 variables, the dependent variable Y as well as a max and a min value of the independent variable (Xa and Xb) where in some cases Xa=Xb (so actually a single value for X).
First I'd like to perform a regression, but my problem is that my X is a range (acutally a censored independent variable Xa-Xb) rather then one single value. I know already some possible approaches like Bayesian Regression or EM algorithms but I've to dig deeper into that...But any suggestions so far? 

Another question arises: How can I display the ranges in a XY-Plot to just have a look at the data and possibly overlay it with the resulting regression line? How can I do that in R? I'd like to just display a line for every Xa-Xb pair. An idea was also to use the color for the lines depending on the range-length (the longer the more grey, the shorter the more black). Maybe you can give me some tips or some simple sample codes.

Thank you very much
/Johannes
--


--



More information about the R-help mailing list