Re: [R] Need help to locate my mistake

From: Rolf Turner <r.turner_at_auckland.ac.nz>
Date: Mon, 03 Mar 2008 15:15:29 +1300

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_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 Mon 03 Mar 2008 - 02:21:08 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 Mon 03 Mar 2008 - 02:30:18 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