Linear and Logistic Regression R functions


#1

Hi All,

Good day. I understand the Linear Regression is to create a model with Continous Predictions (like predicting the temperature for tomorrow) and Logistic Regression is categorical (Sunny,Rainy etc).

I would like to know what are the R functions to perform these two type of Regression.

Thank you.


#2

Hi @nagu2487

The general framework in R is glm() part of the package stats (default in R). If you want to explore the interactions consider the glmutil() package as well. There is a good explanation about this package under glmutil

Hope this help

Alain


#3

Thank you so much Lesaffrea. So you mean to say for both Linear and Logistic Regression we will use glm() ??


#4

Hi @nagu2487

Yes there is one parameter to change, the family parameter , you set it to “family=binomial(logit)” for logistic regression and to gaussian for linear regression

For logistic regression this link will help you glm

Hope this help

Alain


#5

Great thank you Lesaffrea.


#6

In R for simple linear regression we use
lm () & cor.test().

As per the best fit line, we plot a curve using spline() for logistic regression.

Take help for the syntax in R


#7

Regression assumes that variables have normal distributions. Non-normally distributed variables (highly skewed or kurtotic variables, or variables with substantial outliers) can distort relationships and significance tests.
So to Overcome i suggest you to use Box-Cox Transformation from ‘car’ Package you can use powerTransform function to get the value of lambda.
[ http://onlinestatbook.com/2/transformations/box-cox.html ]
Then you can go about to use bcPower or yjPower to get the values for your variable which will then be normally distributed.
Note that if you have a large data set then you need not worry( But do check for kurtosis)
Cheers