R语言偏态分布的回归分析

偏态分布的回归分析

回归是我们经常遇到的模型,但是回归会根据Y因变量的类型,分成分类问题(Y是分类变量,如生存或死亡)与回归问题(Y是连续性变量,如身高体重)。

在R里面,建立回归模型是通过family参数指定回归类型。其实也是根据Y的分布,来确定用何种family

Family 种类

lm()函数中,常见的family 有:

image.png

当然,回归方程中还有更多的family,但是不局限于函数。详细情况请见:https://www.rdocumentation.org/packages/stats/versions/3.6.2/topics/family

常见分布类型

一般我们做回归方程时候,碰见的常见回归类型有以下四种。最常见的是正态分布。

image.png

当然,我们遇到偏态分布时候,一般有两种处理方式。

  1. 通过将偏态数据进行log变换,转成正态分布进行回归。
  2. 直接使用 family=Gamma 指定Gamma分布。

案例

可使用glm()模型构建回归方程:

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

1.Logistic Regression

# where F is a binary factor and x1-x3 are continuous predictors
fit <- glm(F~x1+x2+x3,data=mydata,family=binomial()) 

summary(fit) # display results
confint(fit) # 95% CI for the coefficients
exp(coef(fit)) # exponentiated coefficients
exp(confint(fit)) # 95% CI for exponentiated coefficients

predict(fit, type="response") # predicted values
residuals(fit, type="deviance") # residuals 

2.Poisson Regression

# Poisson Regression
# where count is a count and x1-x3 are continuous predictors
fit <- glm(count ~ x1+x2+x3, data=mydata, family=poisson())

summary(fit) display results

3.Gaussian Regression

# Gaussian Regression
# where count is a count and x1-x3 are continuous predictors
fit <- glm(count ~ x1+x2+x3, data=mydata)

summary(fit) display results

4.Gamma Regression

# set linear regression model
set.seed(1)
x = rnorm(100)
y = rgamma(100,10,3)
glm(y ~ x, family = Gamma)

参考:

  1. https://www.statmethods.net/advstats/glm.html
  2. https://bookdown.org/ndphillips/YaRrr/regression-on-non-normal-data-with-glm.html
  3. https://stats.stackexchange.com/questions/58497/using-r-for-glm-with-gamma-distribution
  4. https://rpubs.com/kaz_yos/glm-Gamma
  • 34
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 8
    评论
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

辣椒种子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值