Re: [R] linear model coefficients by year and industry, fitted values, residuals, panel data

2013-04-04 Thread Cecilia Carmo
De: Peter Ehlers [ehl...@ucalgary.ca] Enviado: quarta-feira, 3 de Abril de 2013 19:01 Para: Adams, Jean Cc: Cecilia Carmo; r-help@r-project.org Assunto: Re: [R] linear model coefficients by year and industry, fitted values, residuals, panel data A few minor improvements to Jean's post suggested

Re: [R] linear model coefficients by year and industry, fitted values, residuals, panel data

2013-04-04 Thread Peter Ehlers
De: Peter Ehlers [ehl...@ucalgary.ca] Enviado: quarta-feira, 3 de Abril de 2013 19:01 Para: Adams, Jean Cc: Cecilia Carmo; r-help@r-project.org Assunto: Re: [R] linear model coefficients by year and industry, fitted values, residuals, panel data A few minor

Re: [R] linear model coefficients by year and industry, fitted values, residuals, panel data

2013-04-04 Thread Cecilia Carmo
Carmo Cc: r-help@r-project.org; Adams, Jean Assunto: Re: [R] linear model coefficients by year and industry, fitted values, residuals, panel data On 2013-04-04 02:11, Cecilia Carmo wrote: Thank you all. I'm very happy with this solution. Just two questions: I use mutate() with package plyr

[R] linear model coefficients by year and industry, fitted values, residuals, panel data

2013-04-03 Thread Cecilia Carmo
Hi R-helpers, My real data is a panel (unbalanced and with gaps in years) of thousands of firms, by year and industry, and with financial information (variables X, Y, Z, for example), the number of firms by year and industry is not always equal, the number of years by industry is not always

Re: [R] linear model coefficients by year and industry, fitted values, residuals, panel data

2013-04-03 Thread Adams, Jean
Cecilia, Thanks for providing a reproducible example. Excellent. You could use the ddply() function in the plyr package to fit the model for each industry and year, keep the coefficients, and then estimate the fitted and residual values. Jean library(plyr) coef - ddply(final3, .(industry,

Re: [R] linear model coefficients by year and industry, fitted values, residuals, panel data

2013-04-03 Thread Peter Ehlers
A few minor improvements to Jean's post suggested inline below. On 2013-04-03 05:41, Adams, Jean wrote: Cecilia, Thanks for providing a reproducible example. Excellent. You could use the ddply() function in the plyr package to fit the model for each industry and year, keep the coefficients,

Re: [R] linear model coefficients by year and industry, fitted values, residuals, panel data

2013-04-03 Thread Adams, Jean
Peter. For suggestion 1, what advantages are there to using coef() rather than $coef? For suggestion 2, thanks! I'm new to the plyr package and wasn't aware of the mutate() function. Jean On Wed, Apr 3, 2013 at 1:01 PM, Peter Ehlers ehl...@ucalgary.ca wrote: A few minor improvements to

Re: [R] linear model coefficients by year and industry, fitted values, residuals, panel data

2013-04-03 Thread Rolf Turner
On 04/04/2013 07:54 AM, Adams, Jean wrote: Peter. For suggestion 1, what advantages are there to using coef() rather than $coef? Just thought I'd chip in: It is considered, uh, politically correct to use extractor functions rather than digging out components of objects in a direct manner.