AI代码解释 >data(litter,package='multcomp')>attach(litter)>table(dose)dose055050020191817>aggregate(weight,by=list(dose),FUN=mean)Group.1x1032.308502529.3084235029.86611450029.64647>fit<-aov(weight~gesttime+dose)>summary(fit)Df Sum Sq Mean SqFvaluePr(>F)gesttime1134.3134.308.0490.00597**dose3137.145...
> p=ggplot(data=longdata,aes(x=Ozone,y=value,color=factor (Month))) > p+geom_point(shape=20,size=4)+facet_wrap(~variable,scales="free_y")+geom_smooth(aes(group=1),fill="gray80") 和stack()一样,melt()也有对应的函数用来还原数据:acast()用于数组,dcast()用于数据框,其中的参数formula...
p-value = 0.7269 bartlett.test(y~B,data=dat) ## ## Bartlett test of homogeneity of variances ## ## data: y by B ## Bartlett's K-squared = 2.9271, df = 3, p-value = 0.403 par(mfrow=c(1,2)) interaction.plot(A, B, y, type="b", col = c("red", "blue"), pch = c...
formula:公式的格式,由数值和组别组成,如value ~ group data:一个矩阵或数据框 该函数返回值(输出值)包含以下内容: statistic:Bartlett的K平方检验统计量 parameter:检验统计量的近似卡方分布的自由度。 p.value:检验的p值 3.3.1 具有一个自变量的Bartlett检验: 研究问题是:检验三组剂量间牙齿长度的方差是否相同。
{formula <-as.formula(paste0("class~",varibale))model <- glm(formula,family = binomial,data = df)glm <- summary(model)pvalue<-glm$coefficients[,4]unidata <- data.frame('ID'=varibale,'pvalue'= pvalue)[-1,]#这块去掉第一行...
fit1<-survfit(surv_object~rx,data=ovarian)summary(fit1)Call:survfit(formula=surv_object~rx,data=ovarian)rx=Atime n.risk n.event survival std.err lower95%CIupper95%CI591310.9230.07390.7891.0001151210.8460.10010.6711.0001561110.7690.11690.5711.0002681010.6920.12800.4820.995329910.6150.13490.4000.946431810.5380...
The output has an attribute named “pvalue”, which contains the matrix of the correlation test p-values. cor_get_pval(): extract a correlation matrix p-values from an object of class cor_mat(). cor_pmat(): compute the correlation matrix, but returns only the p-values of the ...
value.name="hp") df.l$No<-factor(df.l$No) str(df.l) ## 'data.frame': 75 obs. of 4 variables: ## $ No : Factor w/ 15 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 10 ... ## $ group: Factor w/ 3 levels "A","B","C": 1 1 1 1 1 2 2 2 2 ...
然后继续进行方差分析,此时是单纯探索时间对因变量的影响,所以注意formula的形式: # A组 f1 <- aov(hp ~ times, data = df.l[df.l$group=="A",]) # 分别看不同次方的结果 summary(f1, split=list(times=list(liner=1,quadratic=2,cubic=3,biquadrate=4))) ## Df Sum Sq Mean Sq F value Pr...
# lm(formula = size ~ weight + tail, data = mouse.data) # # Residuals: # Min 1Q Median 3Q Max # -0.99928 -0.38648 -0.06967 0.34454 1.07932 # # Coefficients: # Estimate Std. Error t value Pr(>|t|) # (Intercept) 0.7070 0.6510 1.086 0.3192 ...