[R] Homework help: Is this how CI using t dist are constructed?
Rolf Turner
r.turner at auckland.ac.nz
Tue Oct 30 22:17:04 CET 2007
On 31/10/2007, at 9:52 AM, Achim Zeileis wrote:
> On Tue, 30 Oct 2007, Zembower, Kevin wrote:
>
>> I'm trying to replicate some of the examples from my textbook in R
>> (my
>> text uses Minitab). In this problem, I'm trying to construct a 95%
>> confidence interval for these distance measurements [1]:
>>
>>> # Case Study 7.4.1, p. 483
>>> x <- scan()
>> 1: 62 52 68 23 34 45 27 42 83 56 40
>> 12:
>> Read 11 items
>>> alpha<-.95
>>> mean(x) + qt(c((1-alpha)/2, 1-((1-alpha)/2)), df=length(x)-1) * sd
>>> (x)
>> / sqrt(length(x))
>> [1] 36.21420 60.51307
>>>
>>
>> Are confidence intervals with the t distribution constructed using
>> this
>> type of equation, or am I overlooking a more concise, 'canned'
>> approach
>> that's already been programmed? Any suggestions on simplifying this?
>
> R offers a confint() generic with methods for various types of models.
> If you consider estimation of the mean as a simple linear model
> (with only
> an intercept) you can do
> fm <- lm(x ~ 1)
> fm
> to estimate the mean and then
> confint(fm)
> to get the confidence interval (by default at 0.95 level).
This is using a sledgehammer to crack a peanut.
The use of t.test() as suggested by Peter Dalgaard is much more
appropriate.
cheers,
Rolf Turner
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
More information about the R-help
mailing list