[R] lines and glm

Uwe Ligges ligges at statistik.uni-dortmund.de
Thu Apr 8 13:48:34 CEST 2004


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))
> 
> 
> Error in xy.coords(x, y) : x and y lengths differ
 >
> However, 
> 
> 
>>length(x)
> 
> [1] 1000
> 
>>length(y)
> 
> [1] 1000

You don't want plot y against x here, but something related to the glm 
object. I guess you are looking for
    abline(glm.object)

Uwe Ligges



> 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