How to Estimate Covariance by Week based on a linear regression model

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to Estimate Covariance by Week based on a linear regression model

Felipe Carrillo
Hi all:
  I have always used SPSS to estimate weekly
covariance based on a linear regression model
  but have to hard code the model Std. Error and the
Mean-Square and then execute
  one week a the time. I was wondering if someone
could give me an idea on how to estimate
  weekly(WK) covariance using the summary and anova of
"dfr"(lineal  model below). I have
  to do this for 52 weeks(WK) but I am providing a
dataset with only two weeks below. The
  first week(WK 38 is missing values)

 dfr <- read.table(textConnection("percentQ
Efficiency
1.565 0.0125
1.94 0.0213
0.876 0.003736
1.027 0.006
1.536 0.0148
1.536 0.0162
2.607 0.02
1.456 0.0157
2.16 0.0103
1.698 0.0196
1.64 0.0098684
1.814 0.0183
2.394 0.0107
2.469 0.0221
3.611 0.0197
3.466 0.0155
1.877 0.0283
2.893 0.0189
1.851 0.009772
2.834 0.0285
1.923 0.022
2.581 0.0159
2.361 0.0053591
2.43 0.0185
1.66 0.0151
2.285 0.0084034
2.285 0.0124
2.37 0.0122
2.392 0.0146
2.244 0.0175"), header=TRUE)
# Linear model
Reg<-lm(Efficiency~percentQ,data=dfr)
summary(Reg)

# Coefficients standard error
Std=Betas[,"Std. Error"]
Std[1]^2
Std[1]^2

# Analysis of Variance (ANOVA)
MS <- anova(lm(Efficiency~percentQ,data=dfr))
MS
# value of the Residual Mean-Square
MS$"Mean Sq"[2]

#I want to estimate weekly(WK) covariance of the
dataset below using the linear model above.

temp53 <- read.table(textConnection("XD TD PD WK
                                  38
                                  38
                                  38
                                  38
3.0259 0.022522 163299  38
2.2316 0.01724 120315  38
2.3374 0.017944 137874  38
2.2024 0.017046 160524  39
2.4216 0.018504 163565  39
1.4672 0.012157 143973  39
1.4817 0.012253 111956  39
1.4959 0.012348 89677  39
1.4431 0.011997 95269  39
1.5676 0.012825 81558  39"), header=TRUE)
# I read about the cov function and tried it with my
data but couldn't get the desired results..I would
really appreciate any hints..Thanks



Felipe D. Carrillo
  Fishery Biologist
  US Fish & Wildlife Service
  California, USA

______________________________________________
[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.