zoukankan      html  css  js  c++  java
  • R 《回归分析与线性统计模型》page120,4.3

    #P120习题4.3
    rm(list = ls())
    A = read.xlsx("xiti_4.xlsx",sheet = 3)
    names(A) = c("ord","Y","K","L")
    attach(A)
    fm = lm(Y~log(K)+log(L))#线性回归模型
    ei = resid(fm)
    X = cbind(1,as.matrix(A[,3:4]))
    t = ti(ei,X)   #外部学生化残差
    plot(fitted(fm),t) #绘制残差图
    

      

     从残差图中看出来,方差不齐

    a1 = boxcox(fm,lambda = seq(0,1,by=0.1))
    

      

     从图像中看出,λ可取0,即进行对数变换

    #进行对数变换
    lm.log = lm(log(Y)~log(L)+log(K))
    coef(lm.log)
    
    summary(lm.log)
    detach(A)
    

      

    > summary(lm.log)
    
    Call:
    lm(formula = log(Y) ~ log(L) + log(K))
    
    Residuals:
        Min      1Q  Median      3Q     Max 
    -1.7251 -0.1764 -0.0059  0.1707  1.3035 
    
    Coefficients:
                Estimate Std. Error t value Pr(>|t|)    
    (Intercept)  0.38004    0.26873   1.414    0.166    
    log(L)       0.05699    0.04471   1.275    0.211    
    log(K)       0.93065    0.04131  22.526   <2e-16 ***
    ---
    Signif. codes:  
    0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
    
    Residual standard error: 0.441 on 35 degrees of freedom
    Multiple R-squared:  0.944,	Adjusted R-squared:  0.9408 
    F-statistic:   295 on 2 and 35 DF,  p-value: < 2.2e-16
    

      

  • 相关阅读:
    jquery web 國際化
    Struts2 分割字符串标签s:generator
    (55) 销售锁货功能
    (54) 记录销售单修改详细
    (53) 动态列表自定义
    exe文件作为服务启动
    (52)KeyError错误
    (51) magento集成增加到款通知
    (50)与magento集成
    (49) odoo context操作
  • 原文地址:https://www.cnblogs.com/jiaxinwei/p/11762190.html
Copyright © 2011-2022 走看看