Please I am new to R. I got the following code from a friend: 
 
gmat <- cbind(gmat,p*(1-p)*wxb)
for (j in seq(1:ncol(gmat))) {
  gmat[,j] <- fitted(lm(gmat[,j]~zmat))
}
 
It is for spatial logit.
 
After defining all the matrices in it such as P, wxb, gmat, and zmat,

I tried to run it in R and got the following error message:
Error in model.frame.default(formula = gmat[, j] ~ zmat, drop.unused.levels = TRUE) : 
  invalid type (list) for variable 'zmat'
 
Any help will be appreciated
 
Thanks
 
 
Abdul

	[[alternative HTML version deleted]]

