Dear Ed, In my opinion you don't need to set the slope to zero. Just test if the slope in lm(d ~ t) is significant. If it is significant then you have evidence that the slope is NOT zero. But when it is not significant (and in your example it is), you can't say that it is zero. But doing some power calculations allows you to estimate the smallest detectable slope. The estimated slope in your example is 0.49. Your design has a power of 13% to detect slopes of this size. The real slope has to be about 1.75 in order to have 80% power. Let's say that it would matter if the slope is about 2 or larger and it won't matter is it is below 2. The power to detect a slope of 2 is 89%, hence you would likely get a significant slope if it was larger then 2. Since the slope was not significant, it's safe to say that the slope is not larger then 2. But if a slope of 0.5 would matter, you couldn't make this kind of assumptions because the power to detect a slope of 0.5 is only 13%. So the change of rejecting the null hypothesis (slope = 0) when slope = 0.5 is too small.
HTH, Thierry > power.trend <- function(repetitions = 5, x = c(0, 1), sd = 1, slope = 1, alpha = 0.05){ + X <- rep(x, repetitions) + ncp <- slope ^ 2 * sum((X - mean(X))^2) / sd ^ 2 + return(1 - pf(qf(1 - alpha, 1, length(X) - 2), 1, length(X) - 2, ncp = ncp)) + } > > df <- data.frame(t = 1:6, d = c(303, 302, 304, 306, 307, 303)) > fit <- lm(d ~ t, data = df) > summary(fit) Call: lm(formula = d ~ t, data = df) Residuals: 1 2 3 4 5 6 0.04762 -1.43810 0.07619 1.59048 2.10476 -2.38095 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 302.4667 1.7849 169.45 7.28e-09 *** t 0.4857 0.4583 1.06 0.349 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.917 on 4 degrees of freedom Multiple R-Squared: 0.2192, Adjusted R-squared: 0.02402 F-statistic: 1.123 on 1 and 4 DF, p-value: 0.349 > power.trend(repetitions = 1, x = df$t, sd = sd(df$d), slope = coef(fit)["t"]) [1] 0.1292668 > power.trend(repetitions = 1, x = df$t, sd = sd(df$d), slope = 1.75) [1] 0.8021454 ------------------------------------------------------------------------ ---- ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney > -----Oorspronkelijk bericht----- > Van: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Namens > [EMAIL PROTECTED] > Verzonden: dinsdag 14 augustus 2007 13:37 > Aan: r-help@stat.math.ethz.ch > Onderwerp: [R] Linear Regression with slope equals 0 > > > Hi there, am trying to run a linear regression with a slope of 0. > > I have a dataset as follows > > t d > 1 303 > 2 302 > 3 304 > 4 306 > 5 307 > 6 303 > > I would like to test the significance that these points > would lie on a horizontal straight line. > > The standard regression lm(d~t) doesn't seem to allow the > slope to be set. > > Any help very welcome. > > ed > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > 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. > ______________________________________________ R-help@stat.math.ethz.ch mailing list 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.