I'm looking to add VIF to logistic regression in R, using the export_summs function.
This is the current code:
export_summs(model1,model2, error_format = "({p.value})", exp = TRUE)
Any ideas?
Thanks.
You can use library car package and find vif(model1) or vif(model2) to find multicollinearity
This is how you can get VIF of a logistic regression model using jtools package in r. Your_glm_model is your logistic model that is returned from glm function.
summ(`Your_glm_model`, vifs = TRUE)
Related
I am using Multinomial Model to calculate propability of a variable but when I type function pmultinom() in R, it informs could find function, could you help me what packages should I install in R?
I am trying to run a probit regression in R.
I am wondering which function suits best for it.
I had a look at the glm function. Am I right with this?
For example, does the output of the following code give the result of a probit regression with fixed effects in the "spieler"-level?:
probTc = glm(Esieg~TTRverf+ factor(spieler),family = "binomial", data = datregT)
I would like to run a cross-validation function like cv.glm on a logistic regression model built with speedglm on a large (millions of rows) data set. Does any such function exist?
I am finding that cv.glm (from boot package) and the train function from caret do not recognize speedglm models.
Thanks in advance.
I have run a few models in for the penalized logistic model in R using the
logistf package. I however wish to plot some forest plots for the data.
The sjPlot package : http://www.strengejacke.de/sjPlot/custplot/
gives excellent function for the glm output, but no function for the logistf function.
Any assistance?
The logistf objects differ in their structure compared to glm objects, but not too much. I've added support for logistf-fitted models, however, 1) model summaries can't be printed and b) predicted probability plots are currently not supported with logistf-models.
I'll update the code on GitHub tonight, so you can try the updated sjp.glm function...
library(sjPlot)
library(logistf)
data(sex2)
fit<-logistf(case ~ age+oc+vic+vicl+vis+dia, data=sex2)
# for this example, axisLimits need to be specified manually
sjp.glm(fit, axisLimits = c(0.05, 25), transformTicks = T)
I want to have a classification table for logistic regression using lrm function in rms package and then plot the roc curve.I have perfomed this using glm function.Example code
train<-sample(dim(data)[1],.8*dim(data)[1]) #80-20 training/test
datatrain<-data[train,]
datatest<-data[-train,]
fit<-glm(Target ~ ., data=datatrain,family=binomial()) #Target is 0/1 variable
prob=predict(fit,type=c("response"),datatest)
datatest$prob=prob
library(pROC)
ROC <- roc(Target==1 ~ prob, data = datatest)
plot(ROC)
confusion<-table(prob>0.5,datatest$Target)
errorrate<-sum(diag(confusion))/sum(confusion)
errorrate
How to get the confusion matrix using lrm function?
The lrm function returns a fit object that inherits from the glm-class. That is not explicitly stated in the lrm help page, but it's easy enough to verify. After running the setup code in the first example on the ?lrm page
> f <- lrm(ch ~ age)
> class(f)
[1] "lrm" "rms" "glm"
So you should be able to use the ordinary predict method you were using above. Prof Harrell advises against using split-sample validation and the use of ROC curves for model comparison. He provides mechanisms for better methods in his package.