Skip to content

building a regression model

3 messages · dada, Rui Barradas, Mario Bourgoin

#
Hi 

I am trying to build a regression model. My data looks like this:

A	B	C	D	        E
1	1	1	2.57	5
2	0	0	1.64	3
0	5	1	4.8	        1
1	3	0	3.56	168
1	1	1	2.13	1
0	3	1	5	        168
2	0	0	7.75	28
4	0	2	2.85	168
3	0	1	1.89	6
1	1	1	2.33	3
3	2	2	1.77	168
1	0	0	1.38	0.04
0	6	1	4.57	168
2	2	2	2.86	1
3	1	1	4.11	168
3	0	2	3	         84
1	1	1	2.5	         56

where E is a response variable and A, B, C, D are predictor variables. Below
are commands which I enter in R:

str (mydata)
mydata.lm = lm (E ~ 1, data = mydata) # to create a blank model 
add1(mydata.lm, mydata, test='F') # to add the best predictor variable to
the blank model

However at this point the message appears: 

Warning messages:
1: In model.matrix.default(Terms, m, contrasts.arg = object$contrasts) :
  the response appeared on the right-hand side and was dropped
2: In model.matrix.default(Terms, m, contrasts.arg = object$contrasts) :
  problem with term 4 in model.matrix: no columns are assigned

What does it mean ? Could you please help ?






--
View this message in context: http://r.789695.n4.nabble.com/building-a-regression-model-tp4654701.html
Sent from the R help mailing list archive at Nabble.com.
#
Hello,

The "error" is just a warning, these are not the same thing. And the 
warning says that you're giving a wrong scope argument, one that 
includes the response. See ?add1. Argument 'scope' is "a formula giving 
the terms to be considered for adding or dropping." And you're passing 
the entire data.frame, not just the regressors.
To get rid of the warning, try the following.

add1(mydata.lm, ~ A + B + C + D, test='F')

Hope this helps,

Rui Barradas
Em 04-01-2013 23:53, dada escreveu: