[R] Standard error of a sum

Sundar Dorai-Raj sundar.dorai-raj at PDF.COM
Fri Jul 23 01:59:52 CEST 2004



Jim Brennan wrote:
> Was just looking at this data and tried this:
> 
> 
>>event.var<--tapply(d.1$chem,factor(d.1$event),var)
>>event.var
> 
>          1          2          3
>  -9.022233 -35.385033 -11.884433
> 
> Any idea why the variances are coming out negative.
> 

Yes, I think you meant:

event.var <- tapply(d.1$chem,factor(d.1$event),var)

(note: second dash negated your result)
> 
>>var(d.1$chem[1:3])
> 
> [1] 9.022233
> 
> right number ....
> 
> Anyway here is the answer I got if we assume independant means-- and I don't
> see why not to with the info given.
> 
> 
>>sqrt(sum(s.err_event^2))
> 
> [1] 4.331732
> 
> (sum(event.var/3*-1)^.5)
> [1] 4.331732
> 
> 
> ----- Original Message -----
> From: "Kenneth Cabrera" <krcabrer at epm.net.co>
> To: <jahernan at umn.edu>; <r-help at stat.math.ethz.ch>
> Sent: Thursday, July 22, 2004 7:27 PM
> Subject: Re: [R] Standard error of a sum
> 
> 
> 
>>If you supose that each mean is independent then
>>
>>s.err_total_chem <- sqrt(sum(s.err_event^2))
>>
>>If not you must estimate de var-covariance matrix to find this s.err.
>>This estimation will be difficult given the scarce data available.
>>
>>Hope it will helps.
>>
>>Kenneth
>>
>>Jose A. Hernandez wrote:
>>
>>
>>>Folks,
>>>
>>>This is so simple is driving me crazy. It's not really an R question
>>>is more an Statistics question.
>>>
>>>I applied a chemical in 3 different events during a growing season. I
>>>took 3 samples in each event to estimate mean applied chemical.
>>>
>>>Thus, I can easily estimate means and st.err by event. I can then
>>>estimate the total chemical applied for the whole season by adding the
>>>3 means for each event. How can I estimate the standard error of this
>>>total applied chemical.
>>>
>>>Thanks in advance,
>>>
>>>Jose
>>>
>>>
>>>event <- c(1,1,1,2,2,2,3,3,3)
>>>chem <- c(131.75,125.92,130.09,42.67,48.26,54.56,85.05,91.17,90.86)
>>>d.1 <- data.frame(event,chem)
>>>attach(d.1)
>>>s.err <- function(x) sd(x)/(sqrt(length(x)))
>>>
>>>print(mean_event <- tapply(d.1$chem,factor(data.1$event),mean))
>>>print(s.err_event <- tapply(d.1$chem,factor(data.1$event),s.err))
>>>
>>>print(total_chem <- sum(mean_event))
>>>s.err_total_chem <-
>>>
>>>
>>>
>>
>>--
>>Kenneth Roy Cabrera Torres
>>Celular +57 (315) 504 9339
>>
>>______________________________________________
>>R-help at stat.math.ethz.ch mailing list
>>https://www.stat.math.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://www.stat.math.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