
On Oct 26, 2009, at 8:47 AM, Tanya Cashorali wrote:

> Sorry here's working code, I wrote it from my iPhone before!

Gee, can I get the R.app that runs on an iPhone?

>
> x = runif(100, 0, 10)
> plot(x)
> abline(lsfit(1:100, x))
> abline(lsfit(1:100, x + sd(x)))
> fit = lsfit(1:100, x + sd(x))
> y = which(residuals(fit) > 0)
> points(y, x[y], col="red")
>

You were almost there:

plot(x)
  abline(lsfit(1:100, x))
  abline(lsfit(1:100, x + sd(x)))
  fit = lsfit(1:100, x + sd(x))
  y = which(residuals(fit) > sd(x))
  points(y, x[y], col="red")

--  
David.

> Notice the points that are red are all the ones above the first  
> lsfit. I'd like only those above the second lsfit that was drawn on  
> the plot.
>
> David Winsemius wrote:
>>
>>
>> On Oct 25, 2009, at 1:20 PM, Tanya Cashorali wrote:
>>
>>> I'm trying to extract the points above and below a particular  
>>> lsfit. I can only get the residuals from the original fit though.
>>>
>>> x = runif(100, 0, 10)
>>> plot(x)
>>> abline(lsfit(1:100, test))
>>
>> Error in as.matrix(y) : object 'test' not found
>>
>> I ran the first three lines and was not in the least bit surprised  
>> that I got an error. I was expecting that lsfit needed to see some  
>> object (perhaps "x") rather than an integer series, and I didn't  
>> see "test" anywhere defined.
>>
>>> abline(lsfit(1:100, test + sd(test))) #I want the points above  
>>> THIS line.
>>
>> Did you really have running code that produced a line?
>>
>>>
>>> Is there a way to use the coefficients from the fit to do this?
>>> Thanks for any help.
>>
>> If you give lsfit a proper input, and assign the result to a fit  
>> object, say "xfit", then coef(xfit) will give you the coefficients,  
>> or if you wanted to apply some sort of test on the residuals, you  
>> could get them with either residuals(xfit) or xfit$residuals.
>>
>
>
>
> On Mon, Oct 26, 2009 at 7:48 AM, David Winsemius <dwinsemius@comcast.net 
> > wrote:
>
> On Oct 25, 2009, at 1:20 PM, Tanya Cashorali wrote:
>
> I'm trying to extract the points above and below a particular lsfit.  
> I can only get the residuals from the original fit though.
>
> x = runif(100, 0, 10)
> plot(x)
> abline(lsfit(1:100, test))
>
> Error in as.matrix(y) : object 'test' not found
>
> I ran the first three lines and was not in the least bit surprised  
> that I got an error. I was expecting that lsfit needed to see some  
> object (perhaps "x") rather than an integer series, and I didn't see  
> "test" anywhere defined.
>
>
> abline(lsfit(1:100, test + sd(test))) #I want the points above THIS  
> line.
>
> Did you really have running code that produced a line?
>
>
>
> Is there a way to use the coefficients from the fit to do this?
> Thanks for any help.
>
> If you give lsfit a proper input, and assign the result to a fit  
> object, say "xfit", then coef(xfit) will give you the coefficients,  
> or if you wanted to apply some sort of test on the residuals, you  
> could get them with either residuals(xfit) or xfit$residuals.
>
> -- 
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
>

David Winsemius, MD
Heritage Laboratories
West Hartford, CT


	[[alternative HTML version deleted]]


