library(betareg)a <- read.csv(choose.files())# beta regression modelsummary(betareg(P_SPEEDING_ADJ ~ log(AVG_AADT), data=...
Friday, November 13, 2020
Poisson Model
# Step 1 - understand data# Load datap <- read.csv(file.choose())head(p)# STEP 2- EFA(exploratory factor analysis)#summary of variablessummary(p)#variancevar(p)# Dependent variable plothist(p$SPEEDING_CRASH, main = "Histogram of Speeding Crash", xlab = "Speeding Crash Number", ylab = "Frequency")#STEP 3- Poisson regression modelmodel...
Probit Model
require(aod)require(ggplot2)mydata <- read.csv("https://stats.idre.ucla.edu/stat/data/binary.csv")## convert rank to a factor (categorical variable)mydata$rank <- factor(mydata$rank)## view first few rowshead(mydata)summary(mydata)xtabs(~rank + admit, data = mydata) #myprobit <- glm(admit ~ gre + gpa + rank, family = binomial(link = "probit"), ...
Logistic Model
#Coded by Tawkir Ahmed library(ggplot2) # USed for plotting datalibrary(dplyr) # Used to extract columns in the datalibrary(rms) # Used to extract p-value from logistic modellibrary(aod)theme_set(theme_gray() ) # the default# logistic modelcovid <- read.csv(choose.files())labs <- attributes(covid)$labelssummary(covid)# collapse all missing values to NAcovid$x <- factor(covid$x,...
Negative Binomial Model
library(betareg)a <- read.csv(choose.files())# beta regression modelsummary(betareg(P_SPEEDING_ADJ ~ log(AVG_AADT), data=a))#negative binomial modelrequire(foreign)require(ggplot2)require(MASS)b<- a$P_SPEEDING_ADJc<- a$AVG_AADTd<- log(c)SPEEDING_AADT<- b*dmodel1= glm.nb(formula=SPEEDING_CRASH ~SPEEDING_AADT , data...
Subscribe to:
Posts (Atom)