- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在拟合一些线条,我觉得我在告诉 R 确切如何拟合它们,但我觉得有些东西(某些因素或影响)我不知道阻止了良好的拟合。
我的实验单元是“情节”,就像野外情节一样,对不起,这令人困惑。
数据可查:https://www.dropbox.com/s/a0tplyvs8lxu1d0/rootmeansv2.csv .
和
df$plot.f<-as.factor(df$plot)
dfG<-groupedData(mass ~ year|plot.f, data=df)
dfG30<-dfG[dfG$depth == 30,]
fit <- lme(mass ~ year , random = ~ 1 | plot, data = df)
plot (augPred(fit))
我为每个实验单元(“情节”)得到了这些拟合:
最佳答案
这个答案有点百科全书,因为关于你的问题有几个要点。 tl;博士 添加 year*plot
因为随机效应是第一步,但拟合实际上有点问题,虽然一开始看起来不是这样:居中 year
变量可以解决这个问题,但对数据进行日志转换可能是一个更好的主意。
更新 : OP 正在对 subset(df,Depth==30)
进行分析.我不小心对完整数据集进行了分析,这可能使事情变得更加困难——下面记录的异方差性对于数据的一个子集可能并不那么糟糕——但我将保留它作为教学目的(出于懒惰)。
获取数据:
df <- read.csv("rootmeansv2.csv")
library(nlme)
gdf <- groupedData( mass ~ year | plot, data=df)
fit0 <- lme(mass ~ year , random = ~ year | plot, data = gdf)
year
项(斜率中的绘图方差)很小。
## Variance StdDev Corr
## (Intercept) 9.522880e-12 3.085916e-06 (Intr)
## year 7.110616e-08 2.666574e-04 0.32
## Residual 3.885373e-01 6.233276e-01
lme
summary 不会以任何其他方式表明可能有问题。但是,如果我们尝试获得置信区间,我们会发现可能存在问题:
intervals(fit0)
## Error in intervals.lme(fit0) :
## cannot get confidence intervals on var-cov components: Non-positive definite approximate variance-covariance
lme4
中拟合相同的模型。 .
library(lme4)
VarCorr(fit1 <- lmer(mass ~ year +(year | plot), data = gdf))
## Groups Name Std.Dev. Corr
## plot (Intercept) 0.66159674
## year 0.00059471 -1.000
## Residual 0.62324403
## Warning messages:
## 1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.132739 (tol = 0.002, component 1)
## 2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge: degenerate Hessian with 1 negative eigenvalues
lme4
的合身稍微好一点:
c(logLik(fit1)-logLik(fit0))
## 0.1775161
year
是从 2008 年开始的连续预测变量,截距和斜率是
极高度相关(截距是第 0 年的预测值!)。在这种情况下,我们可以通过居中来解决问题——减去最小值也是合理的(即从 0 开始年份而不是 2008 年)
c. <- function(x) scale(x,center=TRUE,scale=FALSE)
VarCorr(fit2 <- update(fit1,.~ c.(year) +(c.(year) | plot)))
## Groups Name Std.Dev. Corr
## plot (Intercept) 0.53798
## c.(year) 0.10515 1.000
## Residual 0.59634
~c.(year)+(c.(year)||plot))
将相关性强制为零,但这有其自身的问题)。
lme
:
VarCorr(fit3 <- update(fit0,
fixed.=~c.(year),
random=~c.(year)|plot,
control=lmeControl(opt="optim")))
## plot = pdLogChol(c.(year))
## Variance StdDev Corr
## (Intercept) 0.28899909 0.5375864 (Intr)
## c.(year) 0.01122497 0.1059479 0.991
## Residual 0.35559015 0.5963138
lmeControl
参数所示。)
plot(augPred(fit3))
plot(fit3)
plot(fit3,sqrt(abs(resid(.)))~fitted(.),type=c("p","smooth"))
df$logmass <- log10(df$mass) ## log10() for interpretability
gdfL <- groupedData( logmass ~ year | plot, data=df)
VarCorr(fitL1 <- lme(logmass ~ c.(year) , random = ~ c.(year) | plot,
data = gdfL))
## plot = pdLogChol(c.(year))
## Variance StdDev Corr
## (Intercept) 0.1842905872 0.42929080 (Intr)
## c.(year) 0.0009702893 0.03114947 -0.607
## Residual 0.1052946948 0.32449144
lmer
的警告当我们拟合等效模型时,我们得到相同的结果;拟合是非奇异的(没有零方差或完美的相关性);和
intervals(fitL1)
作品。
plot(augPred(fitL1))
plot(fitL1)
lme
更喜欢水平绘制箱线图——
factor(year)
告诉
lme
使用箱线图而不是散点图)。
plot(fitL1,factor(year)~resid(.))
关于r - 更适合线性模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23812039/
在我的 previous question ,已经确定,当纹理四边形时,面部被分解为三角形,纹理坐标以仿射方式插值。 不幸的是,我不知道如何解决这个问题。 provided link很有用,但没有达到
是否有简单的解决方案可以在 Qt 中为图像添加运动模糊?还没有找到任何关于模糊的好教程。我需要一些非常简单的东西,我可以理解,如果我可以改变模糊角度,那就太好了。 最佳答案 Qt 没有运动模糊过滤器。
我想构建一个有点复杂的轴,它可以处理线性数据到像素位置,直到某个值,在该值中所有内容都被归入一个类别,因此具有相同的数据到像素值。例如,考虑具有以下刻度线的 y 轴: 0%, 10%, 20%, 30
我需要确保两个 View 元素彼此相邻且垂直高度相同。我会使用基线约束来做到这一点,但目前我正在使用线性、可滚动的布局( ScrollView 中的线性布局),当我点击一个元素时,它不允许我从中获取基
考虑正则表达式 ".*?\s*$" 和一个不以空格结尾的字符串。 示例 " a" .最后\s永远无法匹配 a这就是为什么 匹配器迭代: \s\s\s\s\s - fails .\s\s\
Closed. This question needs to be more focused。它当前不接受答案。 想要改善这个问题吗?更新问题,使它仅关注editing this post的一个问题。
我正在尝试阅读英特尔软件开发人员手册以了解操作系统的工作原理,这四个寻址术语让我感到困惑。以上是我的理解,如有不对请指正。 线性地址 : 对一个孤立的程序来说,似乎是一长串以地址0开头的内存。该程序的
有很多方法可以使用正则表达式并相应地使用匹配/测试匹配来检查字符串是否有效。我正在检查包含字母(a-b)、运算符(+、-、/、*)、仅特殊字符(如(')'、'(')和数字(0-9)的表达式是否有效 我
我正在使用 iris 数据集在 R 中练习 SVM,我想从我的模型中获取特征权重/系数,但我想我可能误解了一些东西,因为我的输出给了我 32 个支持向量。假设我要分析四个变量,我会得到四个。我知道在使
我正在使用 iris 数据集在 R 中练习 SVM,我想从我的模型中获取特征权重/系数,但我想我可能误解了一些东西,因为我的输出给了我 32 个支持向量。假设我要分析四个变量,我会得到四个。我知道在使
如何向左或向右滑动线性布局。在该线性布局中,默认情况下我有一个不可见的删除按钮,还有一些其他小部件,它们都是可见状态,当向左滑动线性布局时,我需要使其可见的删除按钮,当向右滑动时,我需要隐藏该删除按钮
我正在编写一个 R 脚本,运行时会给出因变量的预测值。我的所有变量都被分类(如图所示)并分配了一个编号,总类数为101。(每个类是歌曲名称)。 所以我有一个训练数据集,其中包含 {(2,5,6,1)8
如果源栅格位于 linear RGB color space使用以下 Java 代码进行转换,应用过滤器时(最后一行)会引发 java.awt.image.ImagingOpException: Un
我想为我的多个 UIImageView 设置动画,使其从 A 点线性移动到 B 点。 我正在使用 options:UIViewAnimationOptionCurveLinear - Apple 文档
我第一次无法使用 CSS3 创建好看的渐变效果。右侧应该有从黑色到透明的渐变透明渐变。底部是页脚,所以它需要在底部另外淡化为透明。 如果可能的话,一个例子: 页面的背景是一张图片,所以不可能有非透明淡
我有一组线性代数方程,Ax=By。其中A是36x20的矩阵,x是20x1的 vector ,B是36x13,y是13x1。 排名(A)=20。因为系统是超定的,所以最小二乘解是可能的,即; x = (
我有一个带有年月数据列(yyyymm)的 Pandas 数据框。我计划将数据插入每日和每周值。下面是我的 df。 df: 201301 201302 201303
假设我想找到2条任意高维直线的“交点”。这两条线实际上不会相交,但我仍然想找到最相交的点(即尽可能靠近所有线的点)。 假设这些线有方向向量A、B和初始点C、D,我可以通过简单地设置一个线性最小二乘问题
如果我想编写一个函数(可能也是一个类),它从不可变的查找表(调用构造函数时固定)返回线性“平滑”数据,如下所示: 例如func(5.0) == 0.5。 存储查找表的最佳方式是什么? 我正在考虑使用两
给定一条线 X像素长如: 0-------|---V---|-------|-------|-------max 如果0 <= V <= max , 线性刻度 V位置将是 X/max*V像素。 如何计
我是一名优秀的程序员,十分优秀!