Friday, December 18, 2020

model summary in R

 # check that model is good fit or not

with(model, cbind(res.deviance = deviance, df = df.residual,

                   p = pchisq(deviance, df.residual, lower.tail=FALSE)))



## odds ratios and 95% CI ***********

exp(cbind(OR = coef(model), confint(model)))


# MORE SUMMARIES ###########################################


anova(model)            # Coefficients w/inferential tests


coef(model)             # Coefficients 

hist(coef(model))


confint(model)          # CI for coefficients

hist(confint(model))

resid(model)            # Residuals case-by-case

hist(residuals(model),main="model COVID 19" ) # Histogram of residuals

plot(residuals(model), main="model COVID 19" )


logLik(model)

BIC(model)

PseudoR2(model)

predict(model)

hist(predict(model))

#peseudo r square 

model$null.deviance

model$deviance

modelChi <- model$null.deviance - model$deviance

pseudo <- modelChi / model$null.deviance

pseudo

# Compute the pseudo p-value

Chidf <- model$df.null - model$df.residual

modelChi <- model$null.deviance - model$deviance

1 - pchisq(modelChi, Chidf)


#RSS(residual sum of square)

RSS <- c(crossprod(model$residuals))

RSS

#Mean square error

MSE <- RSS / length(model$residuals)

MSE

#Root MSE

RMSE <- sqrt(MSE)

RMSE

#Pearson estimated residual variance

sig2 <- RSS / model$df.residual

sig2

0 comments:

Post a Comment