Re: [R] How to estimate weekly Variance

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Sat, 16 Feb 2008 15:18:08 +0000 (UTC)

Felipe Carrillo <mazatlanmexico_at_yahoo.com> wrote in news:735441.30138.qm_at_web56609.mail.re3.yahoo.com:

> Dear All:
> Using the Excel formula below I am able to estimate
> daily variance(Daily VarPD)for PD,but I can't figure
> out how to estimate the Weekly variance for PD. Any
> hints?
>
> Daily VarPD = (PD * (1 - TD))/TD + VarTD *
> ((PD*(1-TD)+ PD^2*TD))/TD^3
>
>
> WK TD VARTD PD Daily VarPD
> 28 0.014735 0.0000449 0 0
> 28 0.012421 0.0000449 0 0
> 28 0.014396 0.0000449 71 7005
> 28 0.014898 0.0000449 132 14016
> 28 0.013512 0.0000449 223 32506
> 28 0.013886 0.0000449 224 31287
> 28 0.013778 0.0000449 218 30528
> 29 0.013274 0.0000449 228 34505
> 29 0.013072 0.0000449 224 34531
> 29 0.012518 0.0000449 488 117720
> 29 0.013264 0.0000449 525 119323
> 29 0.013233 0.0000449 80 9134
> 29 0.010194 0.0000449 417 133067
> 29 0.012567 0.0000449 82 10184
> 30 0.014695 0.0000449 413 68893
> 30 0.010634 0.0000449 373 103688
> 30 0.013934 0.0000449 914 272719
> 30 0.014107 0.0000449 213 28473
> 30 0.014339 0.0000449 651 147016
> 30 0.014375 0.0000449 521 102429
> 30 0.016373 0.0000449 979 229104

I am going to assume on the basis of your earlier posts that you have gotten this into a dataframe. You should know, since Prof Ripley told you so six months ago, that variable names cannot have spaces. The formula you offer makes no sense to me, and I could not see what bearing it has on calculating a variance of a week's worth of PD values. In the future, you should offer code to create a minimal dataset.

Assuming your dataframe is fishwk, here is a method to get the variances of PD by week:

by(data=fishwk, INDICES=fishwk$WK, function(x) var(x$PD))

-- 
David Winsemius

______________________________________________
R-help_at_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.
Received on Sat 16 Feb 2008 - 15:21:09 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 16 Feb 2008 - 15:30:15 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive