[R] lines and glm
kjetil@entelnet.bo
kjetil at entelnet.bo
Thu Apr 8 13:57:54 CEST 2004
On 8 Apr 2004 at 18:37, Jan P. Smit wrote:
> Dear R-helpers,
>
> I'm a beginner using R 1.8.1 on Windows 2000. I'm trying to replicate
> some examples in Franses' & Paap's Quantitative Models in Marketing
> Research.
>
> > t <- 1:1000
> > e1 <- rnorm(1000)
> > e2 <- rnorm(1000)
> > x <- 0.0001*t+e1
> > y2 <- -2+x+e2
> > y <- ifelse(y2>0,1,0)
> >
> > plot(x, y, pch = 16, col = "darkblue",
> + main = expression(paste("Scatter diagram of ", italic(y[t]), "
> against ",
> + italic(x[t]))),
> + xlab = expression(italic(x[t])),
> + ylab = expression(italic(y[t])))
> > lines(glm(y ~ x, family = binomial))
I don't think lines know what to do with an glm object! Reolace the
last line with something like:
test <- glm(y ~ x, family = binomial)
o <- order(x)
lines(x[o], fitted(test)[o])
Kjetil Halvorsen
>
> Error in xy.coords(x, y) : x and y lengths differ
>
> However,
>
> > length(x)
> [1] 1000
> > length(y)
> [1] 1000
>
> as it should be.
>
> I'm sure I must be missing something obvious, but it is not clear to
> me (after reading the Introduction, FAQ and the relevant functions
> help pages) what.
>
> Sincerely,
>
> Jan Smit
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list