# Load library
library(haven)
# Read in data
#data input
a <- read.csv(choose.files())
# Load the library
library(MASS)
# Turn the apply variable into a factor
a$KABCO <- factor(a$KABCO)
# Run the ordinal logistic regression model
model <- polr(KABCO~ Covid+ Speed+ Volume+ Drug_Alco, data=a)
summary(model)
#require(modEvA) #for pesudo r square or
require(pscl) #for pesudo r square
#for model fit
#modEvA::RsqGLM(model=model)
#or use
write.table(pscl::pR2(model),sep="\t")
# Find the p-value for a t-value of 3.9418
pt(3.468, 400-3, lower.tail=FALSE)*2
Std. Errors:
stE<- model$Std.Errors
#2 tailed z test
z<- coef(model)/Standard_Error(model)
p<- (1-pnorm(abs(z),0,1))*2
p #pvalue