An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110819/d48874cc/attachment.pl>
Calculating p-value for 1-tailed test in a linear model
6 messages · Andrew Campomizzi, Rolf Turner, David Winsemius
On 20/08/11 10:20, Andrew Campomizzi wrote:
Hello, I'm having trouble figuring out how to calculate a p-value for a 1-tailed test of beta_1 in a linear model fit using command lm. My model has only 1 continuous, predictor variable. I want to test the null hypothesis beta_1 is>= 0. I can calculate the p-value for a 2-tailed test using the code "2*pt(-abs(t-value), df=degrees.freedom)", where t-value and degrees.freedom are values provided in the summary of the lm. The resulting p-value is the same as provided by the summary of the lm for beta_1. I'm unsure how to change my calculation of the p-value for a 1-tailed test. Thanks for your assistance, Andy
The r-help mailing list is *not* for giving assistance with homework.
cheers,
Rolf Turner
On Aug 19, 2011, at 6:20 PM, Andrew Campomizzi wrote:
Hello, I'm having trouble figuring out how to calculate a p-value for a 1- tailed test of beta_1 in a linear model fit using command lm. My model has only 1 continuous, predictor variable. I want to test the null hypothesis beta_1 is >= 0. I can calculate the p-value for a 2-tailed test using the code "2*pt(-abs(t-value), df=degrees.freedom)", where t-value and degrees.freedom are values provided in the summary of the lm. The resulting p-value is the same as provided by the summary of the lm for beta_1. I'm unsure how to change my calculation of the p-value for a 1-tailed test.
You need to clearly state your hypothesis. Then using the output from the regression function should be straightforward. (Yes. this is a intentionally vague answer designed to elicit further information about your understanding of the statistical issues and how they relate to your domain knowledge. Many time peole already have the data and because they didn't get the answer they wanted, they search for other ways to "game the system" by ad-hoc changes in the statistical "rules of the road".) -- David Winsemius, MD West Hartford, CT
1 day later
David, It's fair to question my intentions. I'm running power analyses using simulations (based on Bolker's Ecological Models and Data in R) and need to provide decision-makers with options. So, I'm attempting to make it clear that if the research hypothesis (e.g., response variable declines with an increase in predictor variable) can be clearly answered with a 1-tailed test, then one might need a sample size of n to get a particular power, given variance and alpha. I think Mark's response answers my question. Thanks, Andy -----Original Message----- From: David Winsemius [mailto:dwinsemius at comcast.net] Sent: Saturday, August 20, 2011 6:02 PM To: Andrew Campomizzi Cc: r-help at r-project.org Subject: Re: [R] Calculating p-value for 1-tailed test in a linear model
On Aug 19, 2011, at 6:20 PM, Andrew Campomizzi wrote:
Hello, I'm having trouble figuring out how to calculate a p-value for a 1- tailed test of beta_1 in a linear model fit using command lm. My model has only 1 continuous, predictor variable. I want to test the null hypothesis beta_1 is >= 0. I can calculate the p-value for a 2-tailed test using the code "2*pt(-abs(t-value), df=degrees.freedom)", where t-value and degrees.freedom are values provided in the summary of the lm. The resulting p-value is the same as provided by the summary of the lm for beta_1. I'm unsure how to change my calculation of the p-value for a 1-tailed test.
You need to clearly state your hypothesis. Then using the output from the regression function should be straightforward. (Yes. this is a intentionally vague answer designed to elicit further information about your understanding of the statistical issues and how they relate to your domain knowledge. Many time peole already have the data and because they didn't get the answer they wanted, they search for other ways to "game the system" by ad-hoc changes in the statistical "rules of the road".) -- David Winsemius, MD West Hartford, CT
On Aug 22, 2011, at 9:44 AM, Andrew Campomizzi wrote:
David, It's fair to question my intentions. I'm running power analyses using simulations (based on Bolker's Ecological Models and Data in R) and need to provide decision-makers with options. So, I'm attempting to make it clear that if the research hypothesis (e.g., response variable declines with an increase in predictor variable) can be clearly answered with a 1- tailed test, then one might need a sample size of n to get a particular power, given variance and alpha.
So the possibility that the response variable will be increased by the predictor variable is known to be false? It would be unusual to have such prior knowledge but I suppose it is possible if the starting point is at the ceiling, but then typical regression methods may not be appropriate.
I think Mark's response answers my question.
Mark's response was not copied to the list.
David. > Thanks, > Andy > > -----Original Message----- > From: David Winsemius [mailto:dwinsemius at comcast.net] > Sent: Saturday, August 20, 2011 6:02 PM > To: Andrew Campomizzi > Cc: r-help at r-project.org > Subject: Re: [R] Calculating p-value for 1-tailed test in a linear > model > > > On Aug 19, 2011, at 6:20 PM, Andrew Campomizzi wrote: > >> Hello, >> >> I'm having trouble figuring out how to calculate a p-value for a 1- >> tailed >> test of beta_1 in a linear model fit using command lm. My model has >> only 1 >> continuous, predictor variable. I want to test the null hypothesis >> beta_1 >> is >= 0. I can calculate the p-value for a 2-tailed test using the >> code >> "2*pt(-abs(t-value), df=degrees.freedom)", where t-value and >> degrees.freedom >> are values provided in the summary of the lm. The resulting p-value >> is the >> same as provided by the summary of the lm for beta_1. I'm unsure >> how to >> change my calculation of the p-value for a 1-tailed test. > > You need to clearly state your hypothesis. Then using the output from > the regression function should be straightforward. > > (Yes. this is a intentionally vague answer designed to elicit further > information about your understanding of the statistical issues and how > they relate to your domain knowledge. Many time peole already have the > data and because they didn't get the answer they wanted, they search > for other ways to "game the system" by ad-hoc changes in the > statistical "rules of the road".) > > -- > > David Winsemius, MD > West Hartford, CT > > David Winsemius, MD West Hartford, CT
It's not that it's known to be false, rather it's not of interest in this
case. If animal density (response) decreases with increasing year
(predictor), then a change in land management practices might be needed.
Whereas, if animal density is increasing, then the status quo should
suffice. Decision makers might decide they only need to know if density is
decreasing so that management actions can be taken to mitigate the problem.
Mark's message:
Hi: jake the value of beta_ j hat ( whatever the coefficient is from the
output ) along with the standard deviation of that coefficient , sigma_ j
hat.
Then, if you want to test the alternative that beta is greater than zero,
then calculate
t* = (beta _j - 0)/sigma_j
and 1-pt(t*, df) will give you the p-value.
the only slightly tricky part tricky part is getting sigma_j hat. If you
take the summary of the lm and call it summlm. then take diag(summlm$cov)
and then the sigma_ j hat that you want is depends on which coefficient you
want to test. if you want the third coefficient, then take the third one
etc.
mark
p.s: you could also divide the two tailed pvalue that have by 2 and that
will give you the right answer also but it doesn't show the understanding.
-----Original Message-----
From: David Winsemius [mailto:dwinsemius at comcast.net]
Sent: Monday, August 22, 2011 9:12 AM
To: Andrew Campomizzi
Cc: r-help at r-project.org
Subject: Re: [R] Calculating p-value for 1-tailed test in a linear model
On Aug 22, 2011, at 9:44 AM, Andrew Campomizzi wrote:
David, It's fair to question my intentions. I'm running power analyses using simulations (based on Bolker's Ecological Models and Data in R) and need to provide decision-makers with options. So, I'm attempting to make it clear that if the research hypothesis (e.g., response variable declines with an increase in predictor variable) can be clearly answered with a 1- tailed test, then one might need a sample size of n to get a particular power, given variance and alpha.
So the possibility that the response variable will be increased by the predictor variable is known to be false? It would be unusual to have such prior knowledge but I suppose it is possible if the starting point is at the ceiling, but then typical regression methods may not be appropriate.
I think Mark's response answers my question.
Mark's response was not copied to the list.
David. > Thanks, > Andy > > -----Original Message----- > From: David Winsemius [mailto:dwinsemius at comcast.net] > Sent: Saturday, August 20, 2011 6:02 PM > To: Andrew Campomizzi > Cc: r-help at r-project.org > Subject: Re: [R] Calculating p-value for 1-tailed test in a linear > model > > > On Aug 19, 2011, at 6:20 PM, Andrew Campomizzi wrote: > >> Hello, >> >> I'm having trouble figuring out how to calculate a p-value for a 1- >> tailed >> test of beta_1 in a linear model fit using command lm. My model has >> only 1 >> continuous, predictor variable. I want to test the null hypothesis >> beta_1 >> is >= 0. I can calculate the p-value for a 2-tailed test using the >> code >> "2*pt(-abs(t-value), df=degrees.freedom)", where t-value and >> degrees.freedom >> are values provided in the summary of the lm. The resulting p-value >> is the >> same as provided by the summary of the lm for beta_1. I'm unsure >> how to >> change my calculation of the p-value for a 1-tailed test. > > You need to clearly state your hypothesis. Then using the output from > the regression function should be straightforward. > > (Yes. this is a intentionally vague answer designed to elicit further > information about your understanding of the statistical issues and how > they relate to your domain knowledge. Many time peole already have the > data and because they didn't get the answer they wanted, they search > for other ways to "game the system" by ad-hoc changes in the > statistical "rules of the road".) > > -- > > David Winsemius, MD > West Hartford, CT > > David Winsemius, MD West Hartford, CT