[R] Grabbing Indexes of a certain standard deviation

2012-07-12 Thread gcm
I have a graph of residuals and I am attempting to get a list of the indexes
of each time the residual is greater than 2 standard deviations or less than
-2 standard deviations, but only the first point of the section. And then
I'd also need the first point where the point returns to the range between
+/- 2 standard deviations.
So basically if my standard deviation=1 and my residuals=c(1, 2.1, 3, 4, 3,
1, 0, -4, -1) I want it to grab the second number, where it exceeds 2
standard deviations and the 6th where it returns to less than 2 standard
deviations. Also, it would grab -4 (or residuals[ 8]) and -1 (residuals[9])

--
View this message in context: 
http://r.789695.n4.nabble.com/Grabbing-Indexes-of-a-certain-standard-deviation-tp4636318.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Grabbing Indexes of a certain standard deviation

2012-07-13 Thread gcm
Thank you a ton! This is perfect!

From: Jean V Adams [via R] [mailto:ml-node+s789695n4636370...@n4.nabble.com]
Sent: Thursday, July 12, 2012 4:59 PM
To: Lauren Vogric
Subject: Re: Grabbing Indexes of a certain standard deviation

I wrote a little function called first() to help with situations like
this.  It returns a 1 every time an element of a vector is different from
the previous element, and a 0 otherwise.

first <- function(x) {
L <- length(x)
c(1, 1-(x[-1]==x[-L]))
}

sd <- 1
residuals <- c(1, 2.1, 3, 4, 3, 1, 0, -4, -1)
# logical, indicating if the residual exceeds 2 standard deviations
exceed <- abs(residuals) > (2*sd)
# indices of the first exceeding residual of a series
which(first(exceed) & exceed)

Jean


gcm <[hidden email]> wrote on 
07/12/2012 11:07:49 AM:

> I have a graph of residuals and I am attempting to get a list of the
indexes
> of each time the residual is greater than 2 standard deviations or less
than
> -2 standard deviations, but only the first point of the section. And
then
> I'd also need the first point where the point returns to the range
between
> +/- 2 standard deviations.
> So basically if my standard deviation=1 and my residuals=c(1, 2.1, 3, 4,
3,
> 1, 0, -4, -1) I want it to grab the second number, where it exceeds 2
> standard deviations and the 6th where it returns to less than 2 standard
> deviations. Also, it would grab -4 (or residuals[ 8]) and -1
(residuals[9])

[[alternative HTML version deleted]]

__
[hidden email] 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.


If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/Grabbing-Indexes-of-a-certain-standard-deviation-tp4636318p4636370.html
To unsubscribe from Grabbing Indexes of a certain standard deviation, click 
here<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4636318&code=bHZvZ3JpY0BncmFoYW1jYXBpdGFsLmNvbXw0NjM2MzE4fDUwNDUzMzMwMQ==>.
NAML<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>


--
View this message in context: 
http://r.789695.n4.nabble.com/Grabbing-Indexes-of-a-certain-standard-deviation-tp4636318p4636429.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Grabbing Indexes of a certain standard deviation

2012-07-16 Thread gcm
Jean, how would you modify your function to grab all the selected and not just 
the first?
Thank you so much!

From: Jean V Adams [via R] [mailto:ml-node+s789695n4636370...@n4.nabble.com]
Sent: Thursday, July 12, 2012 4:59 PM
To: Lauren Vogric
Subject: Re: Grabbing Indexes of a certain standard deviation

I wrote a little function called first() to help with situations like
this.  It returns a 1 every time an element of a vector is different from
the previous element, and a 0 otherwise.

first <- function(x) {
L <- length(x)
c(1, 1-(x[-1]==x[-L]))
}

sd <- 1
residuals <- c(1, 2.1, 3, 4, 3, 1, 0, -4, -1)
# logical, indicating if the residual exceeds 2 standard deviations
exceed <- abs(residuals) > (2*sd)
# indices of the first exceeding residual of a series
which(first(exceed) & exceed)

Jean


gcm <[hidden email]> wrote on 
07/12/2012 11:07:49 AM:

> I have a graph of residuals and I am attempting to get a list of the
indexes
> of each time the residual is greater than 2 standard deviations or less
than
> -2 standard deviations, but only the first point of the section. And
then
> I'd also need the first point where the point returns to the range
between
> +/- 2 standard deviations.
> So basically if my standard deviation=1 and my residuals=c(1, 2.1, 3, 4,
3,
> 1, 0, -4, -1) I want it to grab the second number, where it exceeds 2
> standard deviations and the 6th where it returns to less than 2 standard
> deviations. Also, it would grab -4 (or residuals[ 8]) and -1
(residuals[9])

[[alternative HTML version deleted]]

__
[hidden email] 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.


If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/Grabbing-Indexes-of-a-certain-standard-deviation-tp4636318p4636370.html
To unsubscribe from Grabbing Indexes of a certain standard deviation, click 
here<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4636318&code=bHZvZ3JpY0BncmFoYW1jYXBpdGFsLmNvbXw0NjM2MzE4fDUwNDUzMzMwMQ==>.
NAML<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>


--
View this message in context: 
http://r.789695.n4.nabble.com/Grabbing-Indexes-of-a-certain-standard-deviation-tp4636318p4636635.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Grabbing Indexes of a certain standard deviation

2012-07-16 Thread gcm
But I'll need the indexes and that gives me the values. I need to then be able 
to make the indexes into a list of numbers.

From: Jean V Adams [via R] [mailto:ml-node+s789695n4636641...@n4.nabble.com]
Sent: Monday, July 16, 2012 8:38 AM
To: Lauren Vogric
Subject: Re: Grabbing Indexes of a certain standard deviation

residuals[abs(residuals) > (2*sd)]


gcm <[hidden email]> wrote on 
07/16/2012 07:07:31 AM:

> Jean, how would you modify your function to grab all the selected
> and not just the first?
> Thank you so much!
>
> From: Jean V Adams [via R] [
mailto:[hidden email]]
> Sent: Thursday, July 12, 2012 4:59 PM
> To: Lauren Vogric
> Subject: Re: Grabbing Indexes of a certain standard deviation
>
> I wrote a little function called first() to help with situations like
> this.  It returns a 1 every time an element of a vector is different
from

> the previous element, and a 0 otherwise.
>
> first <- function(x) {
> L <- length(x)
> c(1, 1-(x[-1]==x[-L]))
> }
>
> sd <- 1
> residuals <- c(1, 2.1, 3, 4, 3, 1, 0, -4, -1)
> # logical, indicating if the residual exceeds 2 standard deviations
> exceed <- abs(residuals) > (2*sd)
> # indices of the first exceeding residual of a series
> which(first(exceed) & exceed)
>
> Jean
>
>
> gcm <[hidden email]>
> wrote on 07/12/2012 11:07:49 AM:
>
> > I have a graph of residuals and I am attempting to get a list of the
> indexes
> > of each time the residual is greater than 2 standard deviations or
less
> than
> > -2 standard deviations, but only the first point of the section. And
> then
> > I'd also need the first point where the point returns to the range
> between
> > +/- 2 standard deviations.
> > So basically if my standard deviation=1 and my residuals=c(1, 2.1, 3,
4,
> 3,
> > 1, 0, -4, -1) I want it to grab the second number, where it exceeds 2
> > standard deviations and the 6th where it returns to less than 2
standard
> > deviations. Also, it would grab -4 (or residuals[ 8]) and -1
> (residuals[9])

[[alternative HTML version deleted]]

__
[hidden email] 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.


If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/Grabbing-Indexes-of-a-certain-standard-deviation-tp4636318p4636641.html
To unsubscribe from Grabbing Indexes of a certain standard deviation, click 
here<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4636318&code=bHZvZ3JpY0BncmFoYW1jYXBpdGFsLmNvbXw0NjM2MzE4fDUwNDUzMzMwMQ==>.
NAML<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>


--
View this message in context: 
http://r.789695.n4.nabble.com/Grabbing-Indexes-of-a-certain-standard-deviation-tp4636318p4636642.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

__
R-help@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.