【自留】23.3.22

模型Ⅱ回归适用于在回归方程中两个变量都是随机时,即不由研究人员控制时,应使用该回归,其具体包括:ordinaryleast squares (OLS), major axis(MA), standard major axis (SMA), and ranged major axis (RMA),我们这里说的RMA实为SMA。

r <- cor(height,weight)
n <- length(height)
r*sqrt((n-2)/(1-r^2))
# 数值上等于下面的t值
cor.test(height,weight)
> r <- cor(height,weight)
> n <- length(height)
> r*sqrt((n-2)/(1-r^2))
[1] 7.203034
> 
> cor.test(height,weight)

    Pearson's product-moment correlation

data:  height and weight
t = 7.203, df = 62, p-value = 9.567e-10
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 0.5145285 0.7897492
sample estimates:
      cor 
0.6749703 

https://wap.sciencenet.cn/home.php?mod=space&do=blog&id=1063689

# MAR反应两者关系
attach(pdt)
y=height
x=sitting.height

d <- var(y)-var(x)
b=(d+sqrt(d^2+4*cov(x,y)^2))/(2*cov(x,y))
a=mean(y)-b*mean(x)

lm(y~x)

# install.packages('smatr')
library(smatr)
sma(y~x,method='MA')


plot(x,y)
plot(x,y,pch=16)
abline(lm(y~x))
abline(sma(y~x,method='MA'),col='red',lty=2)

attach(plants)
lm(weight~height)

# weight=height*1.078-122
range(height)

summary(lm(weight~height))
summary(lm(weight~I(height^3)))

# 非线性关系
mdt <- read.csv('E:/mistletoe.csv')
attach(mdt)

par(mfrow=c(2,2))
plot(age,mistletoe,pch=16)
summary(lm(mistletoe~age))
abline(lm(mistletoe~age))

plot(log(age),mistletoe,pch=16)
summary(lm(mistletoe~log(age)))

# 半致死量,概率累积致死率不取得1
ldt <- read.csv('E:/LD50.csv')
attach(ldt)

plot(dose,deathrate,pch=16)
abline(lm(deathrate~dose))

summary(lm(deathrate~dose))

lm50 <- lm(deathrate~dose)
a <- lm50$coefficeients[1]
b <- lm50$coefficeients[2]

(100-a)/b
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值