[R] [NB] lm problems

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Tue Nov 26 22:58:05 CET 2002


You can't do linear regression with an ordered factor as a response.
If you mean to code the levels you need to do so explicitly by
codes(G5).

On Tue, 26 Nov 2002, Matej Cepl wrote:

> Hi,
>
> I have probably overlooked something obvious, but could anybody
> help me with following, please?
>
> Trying to make regression analysis. I have a huge dataframe with
> results from National Opinion Survey on Crime and Justice
> (www.abacon.com/fox/) with two variables G5 and N3 which are
> imported to R as ordered factors:
>
> 	> levels(noscj$G5)
> 	[1] "Strongly agree"    "Agree"             "Neither"
> 	[4] "Disagree"          "Strongly disagree"
> 	> levels(noscj$N3)
> 	[1] "Serious problem"  "Somewhat problem" "Minor problem"  "Not
> 	a problem"
> 	>
>
> (missing values are duly recoded as NA). When I try linear
> regression I get a lot of warnings which I have not managed to
> parse succesfully:
>
> 	> lm(G5 ~ N3,data=noscj)
>
> 	Call:
> 	lm(formula = G5 ~ N3, data = noscj)
>
> 	Coefficients:
> 	(Intercept)         N3.L         N3.Q         N3.C
> 	    3.38087     -0.05821     -0.15364      0.04367
>
> 	Warning message:
> 	"-" not meaningful for ordered factors in: Ops.ordered(y,
> 	z$residuals)
> 	> summary(lm(G5 ~ N3,data=noscj))
>
> 	Call:
> 	lm(formula = G5 ~ N3, data = noscj)
>
> 	Residuals:
> 	[1] <NA> <NA> <NA> <NA> <NA>
> 	Levels:  Strongly agree Agree Neither Disagree Strongly disagree
>
> 	Coefficients:
> 	            Estimate Std. Error t value Pr(>|t|)
> 	(Intercept)  3.38087
> 	N3.L        -0.05821
> 	N3.Q        -0.15364
> 	N3.C         0.04367
>
> 	Residual standard error: NA on 980 degrees of freedom
> 	Multiple R-Squared:    NA,      Adjusted R-squared:    NA
> 	F-statistic:    NA on 3 and 980 DF,  p-value: NA
>
> 	Warning messages:
> 	1: "-" not meaningful for ordered factors in: Ops.ordered(y,
> 	z$residuals)
> 	2: "^" not meaningful for ordered factors in: Ops.ordered(r, 2)
> 	3: ">" not meaningful for factors in: Ops.factor(qs[i], -Inf)
> 	4: "+" not meaningful for factors in: Ops.factor(qs[i],
> 	.minus(x[hi[i]], x[lo[i]]) * (index[i] - lo[i]))
> 	>
>
> Could anybody tell me, what's going on, please? I have no clue
> what "^", ">", etc. means.
>
> 	Thanks a lot (and thanks for your patience)
>
> 		Matej
>
> --
> Matej Cepl, matej at ceplovi.cz,
> Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC
> 138 Highland Ave. #10, Somerville, Ma 02143, (617) 623-1488
>
> Q: Is vi an easy editor to learn, is it intuitive?
> A: Yes, some of us think so. But most people think that we are
>    crazy.
>     -- vi FAQ
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list