[R] a question about glm( )

From: <qli_at_math.wustl.edu>
Date: Fri 07 Jul 2006 - 07:41:03 EST


Hi,

I am working on an example about generalized linear model in a paper using glm( ). The code is quite simple and straightforward, but the result is rediculous. The true parameter is c(4, -6), but the result is c(2.264774, -3.457114) Can anybody tell me the reason for this? Thanks a lot!!!

Here is the code:

g=function(t){exp(t)/(1+exp(t))} #the given link function

n = 100	 # sample size
beta.true = c(4,-6)	#the true parameter

#----------------------------------------- the given x
x = rep(0,n)

for(i in 1:n)

        {if (i<=80)

                x[i]=0.90-0.0025*i

         else

                x[i]=0.70-0.035*(i-80)

}

x = cbind(1,x)

#----------------------------------------- to generate y

meany = g(x%*%beta.true)

y = rep(0,100)
for(i in 1:n)

        { # simulate the data from a binomial distribution

		y[i] = rbinom(1,1,meany[i])

}
#------------------------------------------ to do the Quasi-likelihood
beta.old = glm (y~x[,2],family=binomial())$coef

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jul 07 07:46:57 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 07 Jul 2006 - 08:15:46 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.