[R] Can't understand error message :-{
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Tue Mar 2 17:43:16 CET 1999
Stuart Luppescu <s-luppescu at uchicago.edu> writes:
> attach(sizef)
> mschmod <- lm (mavgres ~ crimesch + socstat + povnojob + ploinc94 + aa94 +
> hisp94 + minty94 + mixed94, data=sizef)
> plot(mschmod$residuals ~ size94)
>
> The last line gives this error message:
> Error in model.frame(formula, rownames, variables, varnames, extras,
> extranames, : variable lengths differ
>
> In fact, the lengths are different:
> > length(mschmod$residuals)
> [1] 379
> > length(size94)
> [1] 384
>
> but I'm sure I don't know 1) how this happened since it all came from the same
> data frame, or 2) why it should prevent me from plotting the data. If someone
> can tell me how to fix this (before I have to present the results at this
> Thursday's meeting!) I'd be very appreciative.
(1) Missing values in response and/or regressors cause cases to be
discarded.
(2) Plotting which of the y's against which x's ?
plot(mschmod$residuals ~ size94[complete.cases(mavgres,crimesch,
socstat,povnojob,ploinc94,aa94,hisp94,minty94,mixed94)])
should do the trick. Or, simpler but sneakier:
attach(sizef[rownames(mschmod$model),])
plot(residuals(mschmod) ~ size94)
detach()
It should also work with:
evalq(plot(residuals(mschmod) ~ size94), sizef[rownames(mschmod$model),])
(none of the above is tested, since I don't have your data of course)
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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