Saturday, January 29, 2022

Ordinal Logistic Regression model

 # Load librarylibrary(haven)# Read in data#data inputa <- read.csv(choose.files())# Load the librarylibrary(MASS)# Turn the apply variable into a factora$KABCO <- factor(a$KABCO)# Run the ordinal logistic regression modelmodel <- polr(KABCO~ Covid+ Speed+ Volume+ Drug_Alco, data=a)summary(model)#require(modEvA)...

Monday, August 2, 2021

Ordinal Logistic Regression (OLR) in Neural Network (NN) using R

 library(neuralnet)library("ISLR")#load datadata<- read.csv(file.choose())colnames(data)smp_size <- floor(0.75 * nrow(data))train_ind <- sample(seq_len(nrow(data)), size = smp_size)train <- mtcars[train_ind, ]test <- mtcars[-train_ind, ]#divide training and testing datamean_data...

Sunday, August 1, 2021

Logistic Regression with Confusion Matrix in R

 #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)library(caret)# logistic modelrail <- read.csv(choose.files())   #trainingtest<- read.csv(choose.files()) ...

Tuesday, July 27, 2021

Scatter plot in R

# install.packages("ggplot2")# install.packages("ggExtra")library(ggplot2)library(ggExtra)dat<- read.csv(file.choose())colnames(dat)# Save the scatter plot in a variablep <- ggplot(dat, aes(x = Speed_2017_to_2019, y =  Volume_2017_to_2019)) +  geom_point(shape=5, color="gray")+ ...

Histogram in R

 # Load datap <- read.csv(file.choose())colnames(p)hist(p$Speed_during, xlab = "Speed in 2020", ylab = "Frequency",      main = "",breaks= 20, xlim= c(0, 120), w=20)hist(p$Volume_during, xlab = "Volume in 2020", ylab = "Frequency", main = "",     breaks= 20,...

Thursday, July 22, 2021

No Parametric Model in R

 require(foreign)  #import data filesrequire(ggplot2)  #plotrequire(MASS)     #for Modern Applied Statistics with Slibrary("mosaic") #Statistics and Mathematics Teaching Utilities# Load datap <- read.csv(file.choose())m<- fitModel(SPEEDING_CRASH  ~               exp(LENGTH             ...

Monday, July 12, 2021

MARS in R

 #MARSlibrary(earth)require(MASS)# fit modelfit <- earth(formula=SPEEDING_CRASH ~               log(AVG_AADT)+LANDUSE_MIX+PAVEMENT_CONDITION+ISLDWIDTH+               P_BOTH_SIDEWALK_ONLY+HIGH_FREQ_TRANSIT+SIGNAL_PER_MILE+               MEDIAN_WIDTH+DAILY_TRANSIT+PAVEMENT_CONDITION+LANE_WIDTH ...