• R语言lm()的多项式回归

    fit2 <- lm(weight ~ hight + I(height^2), data = women)
    summary(fit2)
    
    展开/折叠结果
    Call:
    lm(formula = weight ~ height + I(height^2), data = women)
    
    Residuals:
         Min       1Q   Median       3Q      Max 
    -0.50941 -0.29611 -0.00941  0.28615  0.59706 
    
    Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
    (Intercept) 261.87818   25.19677  10.393 2.36e-07 ***
    height       -7.34832    0.77769  -9.449 6.58e-07 ***
    I(height^2)   0.08306    0.00598  13.891 9.32e-09 ***
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
    
    Residual standard error: 0.3841 on 12 degrees of freedom
    Multiple R-squared:  0.9995,	Adjusted R-squared:  0.9994 
    F-statistic: 1.139e+04 on 2 and 12 DF,  p-value: < 2.2e-16
    

    $\hat{Weight}=261.88-7.35 \times Height+0.083\times Height^2$

    模型的方差解释了99.95%的方差。所有项均小于0.001,达到极显著水平。I()的作用是把一个表达式当作一个独立的项。

  • R语言的lm()函数

    lm()是R语言中线性建模的函数。lm()函数适合线性模型并用于执行回归分析。

    fit <- lm(weight~height,data=women)
    fit
    
        展开/折叠结果     
    Call:
    lm(formula = weight ~ height, data = women)
    Coefficients:
    (Intercept) height -87.52 3.45
    summary(fit)
    
        展开/折叠结果     
    Call:
    lm(formula = weight ~ height, data = women)
    
    Residuals:
        Min      1Q  Median      3Q     Max 
    -1.7333 -1.1333 -0.3833  0.7417  3.1167 
    
    Coefficients:
                 Estimate Std. Error t value Pr(>|t|)    
    (Intercept) -87.51667    5.93694  -14.74 1.71e-09 ***
    height        3.45000    0.09114   37.85 1.09e-14 ***
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
    
    Residual standard error: 1.525 on 13 degrees of freedom
    Multiple R-squared:  0.991,     Adjusted R-squared:  0.9903 
    F-statistic:  1433 on 1 and 13 DF,  p-value: 1.091e-14

    $\hat{Weight}=-87.52+3.45\times Height$

    该模型解释了99.1%的方差,残差标准误1.525可理解为身高预测体重的模型的平均误差是1.525。

  • 基因组共线性genome collinearity

    基因组共线性(Genome Collinearity)是指在不同物种或同一物种的不同个体中,基因组的某些区域在基因顺序和结构上保持一致或相近的现象。这种现象通常是由于物种间的共同祖先或基因组复制事件导致的。共线性分析在比较基因组学中非常重要,因为它可以帮助科学家理解基因组进化、基因功能保留以及物种间的进化关系。

  • JS控制台输出你好世界

    console.log("Hello, world!");
    

    注意,最后要以分号结尾,然后控制台就会输出结果。

    展开/折叠结果 Hello, world!
    undefined

  • 基因本体论Gene Ontology,GO

    基因本体论(Gene Ontology,GO)是一个生物信息学项目,旨在为基因和基因产物的功能提供统一的描述。它通过生物过程(Biological Process)、分子功能(Molecular Function)和细胞组分(Cellular Component)来组织和描述基因功能。

    本体,意味着共识,具有跨越式的一致功能注释。

  • 用R语言实现文字转拼音

    需要安装一个pinyin包。

    # 安装并加载pinyin包  
    if (!requireNamespace("pinyin", quietly = TRUE)) {  
      install.packages("pinyin")  
    }  
    library(pinyin)  
    
    # 示例中文文本  
    chinese_text <- c("赵云","马超")  
    
    # 转换为拼音  
    pinyin_result <- py(chinese_text,sep = " ")  
    
    # 打印结果  
    print(pinyin_result)
    
    展开/折叠结果 > print(pinyin_result)
    赵云 马超
    "zhào yún" "mǎ chāo"

  • R语言的apply函数

    apply函数是效率极高的函数,尤其在对大矩阵进行运算时尤其高效。

    # 创建一个矩阵  
    matrix_data <- matrix(1:9, nrow = 3, byrow = TRUE)  
    print("Original Matrix:")  
    print(matrix_data)  
    
    # 使用 apply 函数对每一行求和  
    row_sums <- apply(matrix_data, 1, sum)  
    print("Sum of each row:")  
    print(row_sums)  
    
    # 使用 apply 函数对每一列求和  
    column_sums <- apply(matrix_data, 2, sum)  
    print("Sum of each column:")  
    print(column_sums)
    
  • R语言edit函数,调用可视化编辑器编辑数据

    这个函数在Linux和windows下都可用。

    a = data.frame(1:9)
    a <- edit(a)
    

  • 道是唯一的动静结合体

    道是混沌的开始和结束,是过去、现在和未来。道本身是静态的,不依赖任何事物的存在,超脱了对立的独立存在,因此道浑然一体不可分割。道又是动态的,它的动态可以体现在道的内部一切都在变化之中,可以认为划分为阴阳,也就是对立。《道德经》有云,人法地,地法天,天法道,道法自然。说的就是,人守法于地,地守法于天,天守法于道,道守法于其自身。

  • R语言编写函数

    R语言的一大特色是可以自己编写函数。基本格式是把function赋予一个变量,例子如下:

    theData <- function(type="all"){
      switch(type,
             all=format(Sys.time(),"%Y %m %d %A"),
             part=format(Sys.time(),"%y-%m-%d"),
             cat("Please retype.")
      )
      
    }
    
    theData()
    theData("all")
    theData("part")