我看到了这个问题的一个版本,但仍然没有看到答案.我正在尝试使用ggplot2但是得到以下错误(今天早上使用R3.0.2'frisbee sailing'与RStudio版本0.98.1102一切正常.
我更新了R和Rstudio,现在得到以下内容:
library(ggplot)
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
there is no package called ‘stringi’
Error: package or namespace load failed for ‘ggplot2’
Run Code Online (Sandbox Code Playgroud)
我很自然地尝试过:
> install.packages('stringi')
**There is a binary version available but the source version is later:
binary source needs_compilation
stringi 0.4-1 0.5-2 FALSE**
installing the source package ‘stringi’
trying URL 'http://cran.rstudio.com/src/contrib/stringi_0.5-2.tar.gz'
Content type 'application/x-gzip' length 3641292 bytes (3.5 MB)
==================================================
downloaded 3.5 MB
* installing *source* package ‘stringi’ ...
** …Run Code Online (Sandbox Code Playgroud) 我有兴趣使用交叉验证(leave-one-out或K-folds)来测试我创建的几个不同的负二项式GLM.我正在使用glm.nb()函数MASS来运行负二项式回归.
我的问题是我是否可以使用cv.glm()from boot来测试这个模型.我倾向于不,但想知道是否有人知道一个功能,让我进行K-folds验证(或留下一个).或者,也许cv.glm()对负二项式完全有效.
以下是一些来自在线示例的数据.我原以为交叉验证结果($delta)应该在0到1之间,但下面的情况并非如此(可能表明出现了问题)
http://www.ats.ucla.edu/stat/r/ DAE/nbreg.htm
我发现了一些关于解释输出的问题cv.glm(),但没有具体说明如何用R中的负二项模型进行交叉验证
require(foreign)
require(ggplot2)
require(MASS)
require(boot)
dat <- read.dta("http://www.ats.ucla.edu/stat/stata/dae/nb_data.dta")
dat <- within(dat, {
prog <- factor(prog, levels = 1:3, labels = c("General", "Academic","Vocational"))
id <- factor(id)
})
summary(m1 <- glm.nb(daysabs ~ math + prog, data = dat))
#This code will run, but is it valid for negative binomial GLM models?
cv.glm(dat,m1,K=10)
Run Code Online (Sandbox Code Playgroud)
[我不确定这个问题是属于这里还是交叉验证...]