extracting significance test for individual lm() parameters after using by

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

extracting significance test for individual lm() parameters after using by

jmoxley
I’m trying to test what growth functions best fit individual subjects. I’m wanting compare linear, quadratic, cubic etc.  Here is the example from the cubic curve.

b3a<-by(c,id,function(x) lm(w~agec+ageq+agecub,data=x))

I can get quiet a bit of information out of sapply(b3a,summary) but it reports something like this for each person
              37
call          Expression
terms         Expression
residuals     Numeric,62
coefficients  Numeric,16
aliased           Logical,4  4
sigma         67.05895
df            Integer,3
r.squared     0.9822921
adj.r.squared 0.9813762
fstatistic    Numeric,3
cov.unscaled  Numeric,16

I could obviously compute by hand the r squared change and then compute a p value based for what the partial r is for the variable but I’d like to have a simpler solution to it. Can I get the information or is there an package that I should download that will do what I’m trying to do much simpler?

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: extracting significance test for individual lm() parameters after using by

Jeff Newmiller
R-square is often a poor indicator of whether a model is appropriate or not. While it is possible that there exists a package that implements your algorithm (which you might find using the sos package), I would recommend that you get some advice from an expert on how to approach this subject, and this list is not a good place for studying statistics theory (read the Posting Guide). You might try stats.stackexchange. com.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<[hidden email]>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.

On January 24, 2015 6:01:59 PM PST, "Moxley, Jerad" <[hidden email]> wrote:

>I’m trying to test what growth functions best fit individual subjects.
>I’m wanting compare linear, quadratic, cubic etc.  Here is the example
>from the cubic curve.
>
>b3a<-by(c,id,function(x) lm(w~agec+ageq+agecub,data=x))
>
>I can get quiet a bit of information out of sapply(b3a,summary) but it
>reports something like this for each person
>              37
>call          Expression
>terms         Expression
>residuals     Numeric,62
>coefficients  Numeric,16
>aliased           Logical,4  4
>sigma         67.05895
>df            Integer,3
>r.squared     0.9822921
>adj.r.squared 0.9813762
>fstatistic    Numeric,3
>cov.unscaled  Numeric,16
>
>I could obviously compute by hand the r squared change and then compute
>a p value based for what the partial r is for the variable but I’d like
>to have a simpler solution to it. Can I get the information or is there
>an package that I should download that will do what I’m trying to do
>much simpler?
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>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.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: extracting significance test for individual lm() parameters after using by

jmoxley
Sorry I was not clearer, but I was asking an R programming question not a theory question. I will try to clarify. If I did this analysis with a dataset involving  just one subject the summary command on the lm object would give me a significance test on each parameter fit. The question in this cSe, is the cubic parameter significant? When I try to do this for each subject separately in a larger dataset using the by command, I get the parameter estimate but can't find a significance test. I apologize again for my poor explanation originally,

> On Jan 24, 2015, at 10:04 PM, Jeff Newmiller <[hidden email]> wrote:
>
> R-square is often a poor indicator of whether a model is appropriate or not. While it is possible that there exists a package that implements your algorithm (which you might find using the sos package), I would recommend that you get some advice from an expert on how to approach this subject, and this list is not a good place for studying statistics theory (read the Posting Guide). You might try stats.stackexchange. com.
> ---------------------------------------------------------------------------
> Jeff Newmiller                        The     .....       .....  Go Live...
> DCN:<[hidden email]>        Basics: ##.#.       ##.#.  Live Go...
>                                      Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
> /Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1
> ---------------------------------------------------------------------------
> Sent from my phone. Please excuse my brevity.
>> .
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: extracting significance test for individual lm() parameters after using by

Michael Dewey
In reply to this post by jmoxley
Dear Jerad

I may have completely misunderstood your question but you do know that
you can write your own function and use it in sapply where you have
summary? You could incorporate calls to summary or to coef or somet
other extractor or you could use the $ tool.

On 25/01/2015 02:01, Moxley, Jerad wrote:

> I’m trying to test what growth functions best fit individual subjects. I’m wanting compare linear, quadratic, cubic etc.  Here is the example from the cubic curve.
>
> b3a<-by(c,id,function(x) lm(w~agec+ageq+agecub,data=x))
>
> I can get quiet a bit of information out of sapply(b3a,summary) but it reports something like this for each person
>                37
> call          Expression
> terms         Expression
> residuals     Numeric,62
> coefficients  Numeric,16
> aliased           Logical,4  4
> sigma         67.05895
> df            Integer,3
> r.squared     0.9822921
> adj.r.squared 0.9813762
> fstatistic    Numeric,3
> cov.unscaled  Numeric,16
>
> I could obviously compute by hand the r squared change and then compute a p value based for what the partial r is for the variable but I’d like to have a simpler solution to it. Can I get the information or is there an package that I should download that will do what I’m trying to do much simpler?
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 2015.0.5645 / Virus Database: 4273/8997 - Release Date: 01/25/15
>

--
Michael
http://www.dewey.myzen.co.uk

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: extracting significance test for individual lm() parameters after using by

David Winsemius
In reply to this post by jmoxley

On Jan 24, 2015, at 11:02 PM, Moxley, Jerad wrote:

> Sorry I was not clearer, but I was asking an R programming question not a theory question.

Copying back the original text which appears to have been omitted:

On 25/01/2015 02:01, Moxley, Jerad wrote:
> I’m trying to test what growth functions best fit individual subjects. I’m wanting compare linear, quadratic, cubic etc.  Here is the example from the cubic curve.
>
> b3a<-by(c,id,function(x) lm(w~agec+ageq+agecub,data=x))


> I will try to clarify. If I did this analysis with a dataset involving  just one subject the summary command on the lm object would give me a significance test on each parameter fit. The question in this cSe, is the cubic parameter significant?

It's not really true that you are "not asking a theory question". You do want inferences. A further problem might be that people who do statistics regularly would not be making statistical inferences based on naive construction of squared and cubed values. I suspect most readers would rather not comment on a procedure that seems particularly prone to invalid results.

--
David.


> When I try to do this for each subject separately in a larger dataset using the by command, I get the parameter estimate but can't find a significance test. I apologize again for my poor explanation originally,

>> On Jan 24, 2015, at 10:04 PM, Jeff Newmiller <[hidden email]> wrote:
>>
>> R-square is often a poor indicator of whether a model is appropriate or not. While it is possible that there exists a package that implements your algorithm (which you might find using the sos package), I would recommend that you get some advice from an expert on how to approach this subject, and this list is not a good place for studying statistics theory (read the Posting Guide). You might try stats.stackexchange. com.
>> ---------------------------------------------------------------------------
>> Jeff Newmiller                        The     .....       .....  Go Live...
>


David Winsemius
Alameda, CA, USA

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.