美文网首页
P值计算的R解答

P值计算的R解答

作者: 小折线 | 来源:发表于2020-05-17 14:36 被阅读0次

Company A produces biological reagents and some laboratory equipment. The weekly production of reagent M follows the normal probability distribution with a mean of 200 and a standard deviation of 16. Recently, new production methods have been introduced and 50 reagent M were produced whose mean is 203.5

  1. The boss would like to investigate whether there has been a change in weekly production of reagent M. Test using 0.01 significance level.
  2. Suppose the boss want to know whether there has been an increase in weekly production of reagent M. To put it another way, can we conclude, because of the improved production methods, that the mean production of M was more than 200? Test using 0.01 significance level.
    Please write down the key steps to solve the problem (The process and R code)
# Q1
P_mean = 200
P_sd = 16

s_mean = 203.5

# plot the population normal distribution
x = seq(P_mean-3*P_sd, P_mean+3*P_sd, length=100)
density = dnorm(x, mean=P_mean, sd=P_sd)
plot(x, density, type='l' )
abline(v=s_mean, col='red')

# caculate the P value (two tail)
pval = (1 - pnorm(s_mean, mean=P_mean, sd=P_sd)) * 2
pval # 0.8 Not even close to 0.01

# Thus, I highly doubt the given numbers in this exercise,
# it would make much more sense if the population std is 1.6,
# 16 is simply too big


P_mean = 200
P_sd = 1.6

s_mean = 203.5

# plot the population normal distribution
x = seq(P_mean-3*P_sd, P_mean+3*P_sd, length=100)
density = dnorm(x, mean=P_mean, sd=P_sd)
plot(x, density, type='l' )
abline(v=s_mean, col='red')

# caculate the P value (two tail)
pval = (1 - pnorm(s_mean, mean=P_mean, sd=P_sd)) * 2
pval  # 0.028

# the one tail P value is  0.028/2=0.014
# if we use 0.01 as a threshold, than we can conclude 
# there is a increase or change

This question needs to use data “data.csv’’,which derives from a microarray dataset investigating gene ression of certain disease. The data has been processed,and the .rst row of the data is the sample serial number, namely, S1 - S20, and the .rst column of the data is the genes. The numbers are the expression values of each gene.Please answer the following questions (R code required)

  1. Please draw a density plot (PDF) to investigate the distribution G3 gene expression among 20 samples,and then calculate its minimum, median and variance
    using certain function in R.
  2. Please draw a boxplot to compare the distribution of all genes expression among 20 different samples. Note that you should check whether there are any outliers in
    them? If they really exist, please delete them and redo it.
# Q2
dat = read.table('./homework3-4_data.csv', header=T, row.names=1, 
    stringsAsFactors=F, sep=',')

dim(dat)
dat[1:5,1:5]

pdf(file='boxplot.pdf', width=6, height=4, pointsize=6)
boxplot(dat, outline = F, main='Boxplot without outliers')
dev.off()

pdf(file='G3_hist.pdf', width=6, height=4)
hist(unlist(dat['G3',]), main='Histgram of G3 expression')
dev.off()

# Actually .there are several different way to define outliers. 
# points outside 3 standard deviation
# points above / below 1.5*(quantile(x, .75) - quantile(x,.25))

相关文章

  • P值计算的R解答

    Company A produces biological reagents and some laborator...

  • T-test——T检验

    前面几节内容,我们了解了在回归分析中,如何判断变量之间的相关性——计算R2,如何判断相关的真实性——计算F值和P值...

  • 统计基础27:饱和模型与偏差计算R方与p值

    引言:logistic回归中,我们了解到R2和P值的计算方法。但josh starmer老师指出,广义线性模型中R...

  • P值转化为Padj

    把计算出来的储存成一个数组,然后调用函数计算, 一定是所有p值(要计算的p值集合,不能单独只计算一个p值),因为p...

  • 11统计基础- 计算P值

    计算P值 有两种p值,单侧和双侧。双侧p值是最常见的,重点是计算它们。相反,单侧p值是很少被使用。 p-value...

  • 145.如何评价个性化推荐系统的效果-2

    145.1 E值 E值表示查准率P和查全率R的加权平均值,当其中一个为0时,E值为1,其计算公式:b越大,表示查准...

  • Fisher's exact test

    目录 适用实例 计算原理 计算实例3.1 解答过程3.2 R语言代码 Fisher精确检验和卡方检验的选择 1. ...

  • R语言计算tmb值

    tmb值与免疫检查点抑制剂疗效相关,而TCGA数据库中的tmb值可以通过TCGAmutations包来计算

  • 线性回归的r方 调整r方 F值 P值计算公式(R语言实现)

    闲来无事,将线性回归效果检验的一些指标,自己复写一番,甚是自嗨;如有瑕疵,还请读者见谅。公众号地址: 一、 功能参...

  • 差异基因的方法 p-value

    上周,我们分享了用RPKM值计算差异基因的方法,这周我们继续分享另外一种方法p-value。 我们都知道,在利用R...

网友评论

      本文标题:P值计算的R解答

      本文链接:https://www.haomeiwen.com/subject/vatxmhtx.html