# [R] testing slope

vito muggeo vito.muggeo at giustizia.it
Wed Feb 5 10:01:02 CET 2003

Hi,
in order to avoid the parameter of x:v3 to be estimated, you can
re-formulate the model.

You fitted
y~1+x+v2+v3+x:v2+x:v3
with 6 df

Now you would fit
y~0+v1+v2+v3+x:v1+x:v2)
with 5 df as x:v3 is not included in the model, i.e. the parameter x:v3 is
constrained to be zero.
best,
vito

A toy example is following:

x<-1:100 #explanatory continuous variable
f<-factor(rep(1:3,length=100)) #categorical variable
f<-model.matrix(~f-1)
xx<-f*x
X<-cbind(f,xx) #design matrix
colnames(X)[4:6]<-c("xf1","xf2","xf3")
b<-c(2,5,-3,-2,3,0) #parameters
y<-X%*%b+rnorm(100,0,1) #response
m0<-lm(y~0+X) #full model
m1<-lm(y~0+X[,-6]) #reduced model
anova(m0,m1) #test for nonnull slope

----- Original Message -----
From: "Ronaldo Reis Jr." <chrysopa at insecta.ufv.br>
To: "R-Help" <r-help at stat.math.ethz.ch>
Sent: Tuesday, February 04, 2003 8:50 PM
Subject: [R] testing slope

Hi all,

I try to test a linear slope using offset.

I have:

> m2 <- glm(Y~X*V)
> summary(m2)

Call:
glm(formula = Y ~ X * V)

Deviance Residuals:
Min        1Q    Median        3Q       Max
-2.01688  -0.56028   0.05224   0.53213   3.60216

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)   1.3673     0.8476   1.613 0.119788
X             4.0235     0.1366  29.453  < 2e-16 ***
Vn2           0.9683     1.1987   0.808 0.427131
Vn3           4.6043     1.1987   3.841 0.000787 ***
X:Vn2         4.1108     0.1932  21.279  < 2e-16 ***
X:Vn3        -4.0069     0.1932 -20.740  < 2e-16 ***
---
Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1

(Dispersion parameter for gaussian family taken to be 1.53955)

Null deviance: 15303.977  on 29  degrees of freedom
Residual deviance:    36.949  on 24  degrees of freedom
AIC: 105.39

Number of Fisher Scoring iterations: 2

It is clear that X slope is diferent of Zero.
X             4.0235     0.1366  29.453  < 2e-16 ***

It is too clear that X:Vn2's slope is diferent of X's slope and diferent of
Zero, because is greater than X'slope.
X:Vn2         4.1108     0.1932  21.279  < 2e-16 ***

But, the X:Vn3' slope is different of X'slope, but not necessarily different
of Zero.

How I make to introduce this parameter in a new model for test? An offset
only
with Vn3 slope???

I try:

m2 <- glm(Y~V*offset(0*X))
m2 <- glm(Y~X*V+V*offset(0*X))
m2 <- glm(Y~V:X+V*offset(0*X))

but neither work :((

Thanks for all.
Ronaldo
--
If you live in a country run by committee, be on the committee.
-- Graham Summer
--
|   //|\\   [*****************************][*******************]
|| ( õ õ )  [Ronaldo Reis Júnior          ][PentiumIII-600     ]
|     V     [ESALQ/USP-Entomologia, CP-09 ][HD: 30 + 10 Gb     ]
||  / l \   [13418-900 Piracicaba - SP    ][RAM: 128 Mb        ]
|  /(lin)\  [Fone: 19-429-4199 r.229      ][Video: SiS620-8Mb  ]
||/(linux)\ [chrysopa at insecta.ufv.br      ][Modem: Pctel-onboar]
|/ (linux) \[ICQ#: 5692561                ][Kernel: 2.4.18     ]
||  ( x )   [*****************************][*******************]