On 3/03/2008, at 1:58 PM, Louise Hoffman wrote: > What if I need to calculate the variance for the fuel data? > > Are there a 'R' way to do that? > > I have derived > variance = (Y-x*theta)^T * (Y - x*theta) / (n-p)
This should be (something like) tr((Y - X%*%theta))%*%(Y-X%*%theta)/(n-p) where X is your design matrix. To get the information in R: fit <- lm(fpi ~ rtime,data=fuelData) summary(fit) This tells you the residual standard error (standard deviation) is 7.681. Typing summary(fit)$sigma gives the answer to more decimal places --- 7.681288. The residual variance can of course be obtained by summary(fit)$sigma^2 Note that the name ``sigma'' is bad --- this terminology should be reserved for population quantities. What we have is ``sigma-hat'', an *estimate* of sigma. Note also that for your fuel data the residual variance is pretty much meaningless since your model is highly inappropriate for these data. cheers, Rolf Turner ###################################################################### Attention:\ This e-mail message is privileged and confid...{{dropped:9}} ______________________________________________ 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.