Hi 

I am running some simulation in  R after resampling from a huge data set 500
columns and 86759 rows and fit these two model and calculate R-square 
fit <- lm(Y~X,weights = Weights)
bhat <- coef(fit)
Yhat <- X%*%bhat                         
SST <- sum((Y - mean(Y))^2)              
SSE <- sum((Y - Yhat)^2)               
MSE <- SSE/(n-pc)                  
aRsqr <- 1-(((n-1)*SSE)/((n-pc)*SST)) 

and the GLM Model

fitGLM <- glm(Y~X,family=Gamma(link = "log"))

Yhat <-exp( X%*%bhat )
SST <- sum((Y - mean(Y))^2)              
SSE <- sum((Y - Yhat)^2)               
MSE <- SSE/(n-pc)                  
aRsqr <- 1-(((n-1)*SSE)/((n-pc)*SST)) 

I am getting a negative R-square which I don't understand why? Can some one
let me know why and if I can investigate that how I do that.

Thanks



--
View this message in context: 
http://r.789695.n4.nabble.com/GLM-and-WLS-tp4648531.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to