Message-ID: <1236329789.3481.30.camel@R1-Thux>
Date: 2009-03-06T08:56:29Z
From: Bernardo Rangel Tura
Subject: Regressão linear
In-Reply-To: <loom.20090305T021510-565@post.gmane.org>
On Thu, 2009-03-05 at 02:20 +0000, Ben Bolker wrote:
> Sueli Rodrigues <srodrigu <at> esalq.usp.br> writes:
> >
> > Ol?. Tenho um arquivo que a cada 6 linhas corresponde uma amostra da qual
> > preciso dos coeficientes da regress?o linear. Como fa?o para que o
> > programa distinga a cada 6 linhas como uma amostra e n?o calcule como um
> > todo?
> > Estou usando a fun??o: model=lm(y ~ x)
> >
>
> You're more likely to get a response if you post to the list
> in English (even fractured English).
>
> Based on what Google translator thinks you said (you want
> to perform linear regressions on 6-line subsets of a data set?),
> here's a starting point (assuming your data are in a data frame
> mydata, and have column names x and y):
>
> splitdat <- split(mydata,rep(1:6,length.out=nrow(mydata))
> linfits <- lapply(splitdata,lm,formula=y~x)
> coefs <- sapply(linfits,coef)
>
> or something like that.
>
> Ben Bolker
Hi Ben Bolker
First of all I would like to thank the kindness with my countrywoman.
Second in her problem each 6 rows is a subset for a linear regression so
the command is
splitdat <- split(mydata,rep(1:(nrow(mydata)/6),each=6))
--
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil