R Language Linear model GLM () Logistic regression model

Source: Internet
Author: User

R Language Generalized linear Model GLM () function
GLM (formula, family=family.generator, Data,control = List (...))
Formula data relationships, such as y~x1+x2+x3
Family: Each response distribution (exponential distribution family) allows various correlation functions to correlate the mean with the linear predictor.
Common family:

Binomal (link= ' logit ')--the response variable is subject to two distributions, and the connection function is logit, i.e. logistic regression

Binomal (link= ' probit ')--the response variable is subject to two distributions, and the connection function is Probit

Poisson (link= ' identity ')--response variable follows Poisson distribution, i.e. Poisson regression

Control: Controlling algorithm error and maximum number of iterations

Glm.control (epsilon = 1e-8, Maxit = +, trace = FALSE)

-----Maxit: Maximum number of iterations of the algorithm, changing the maximum number of iterations: Control=list (maxit=100)

From
Actual combat:

Source ("SETWD.R")
# #下面read. csv error, because the table header is garbled, delete the table header, redefine
data=read.csv ("Bankloan.csv") [2:701,]
# # View the first few lines tail is the last few lines of
Head (data)
colnames (data) <-c ("x1", "X2", "X3", "X4", "X5", "X6", "x7", "x8", "y")
tail ( Data)
#logistic回归模型
glm<-glm (y~x1+x2+x3+x4+x5+x6+x7+x8,family = binomial (link = "logit"), data = data)
GLM
Summary (GLM)
# # #逐步寻优法 forward forward selection method backward
logit.step<-step (glm,direction = C (" Both "))
Summary (logit.step)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.