com*_*ues 6 statistics regression r numeric glm
我们正在 Fedora 33 上使用 R 将广义线性模型拟合到一组数据。我们 3 个人拥有完全相同的数据集、完全相同的操作系统 (Fedora 33)、完全相同的 R 版本和软件包版本。sessionInfo() 输出看起来也一样。这是当前的函数调用:
probitModel <- glm(Y ~ a + b + c +
d + e + f + g,
control=glm.control(maxit=100),
start=startingval,
family = binomial(link = "probit"),
data = thisData)
Run Code Online (Sandbox Code Playgroud)
需要注意的是,正常的“lm”拟合在比较时会产生完全相同的结果。关于“glm”的一些东西在不同的计算机上会产生不同的结果。最后,结果是一致的,因为我们在同一台计算机上使用相同的数据得到相同的结果。只有当我们比较结果时才会出现问题。
我们已经检查过:
数据文件可以在这里找到。我们只是使用 load() 来设置数据,调用上面的函数,当输出应该相同时,我们得到的输出略有不同。
我的 sprintf("%.20f", probitModel$coefficients) 结果:
"-2.87521118137333120401" "-0.29134882504319664642" "0.11641651353472137753" "-0.00811350544106945529" "0.00939647781971938295" "0.00000000889056301580" "-0.00000000003021053820" "0.04553200818707187070"
Run Code Online (Sandbox Code Playgroud)
另一台电脑的结果:
"-2.87521124006409856122" "-0.29134881939721285482" "0.11641651896472486605" "-0.00811350937056383621" "0.00939647799201156347" "0.00000000889056417264" "-0.00000000003021022404" "0.04553201421062236243"
Run Code Online (Sandbox Code Playgroud)
我的跟踪输出:
Deviance = 67234.8 Iterations - 1
Deviance = 67079.56 Iterations - 2
Deviance = 67102.68 Iterations - 3
Deviance = 67088.05 Iterations - 4
Deviance = 67078.07 Iterations - 5
Deviance = 67073.77 Iterations - 6
Deviance = 67076.34 Iterations - 7
Deviance = 67074.41 Iterations - 8
Deviance = 67075.74 Iterations - 9
Deviance = 67074.77 Iterations - 10
Deviance = 67075.45 Iterations - 11
Deviance = 67074.96 Iterations - 12
Deviance = 67075.31 Iterations - 13
Deviance = 67075.06 Iterations - 14
Deviance = 67075.23 Iterations - 15
Deviance = 67075.11 Iterations - 16
Deviance = 67075.2 Iterations - 17
Deviance = 67075.13 Iterations - 18
Deviance = 67075.18 Iterations - 19
Deviance = 67075.15 Iterations - 20
Deviance = 67075.17 Iterations - 21
Deviance = 67075.15 Iterations - 22
Deviance = 67075.16 Iterations - 23
Deviance = 67075.16 Iterations - 24
Deviance = 67075.16 Iterations - 25
Deviance = 67075.16 Iterations - 26
Deviance = 67075.16 Iterations - 27
Deviance = 67075.16 Iterations - 28
Deviance = 67075.16 Iterations - 29
Deviance = 67075.16 Iterations - 30
Deviance = 67075.16 Iterations - 31
Deviance = 67075.16 Iterations - 32
Run Code Online (Sandbox Code Playgroud)
其他电脑的trace输出:
Deviance = 67234.8 Iterations - 1
Deviance = 67079.56 Iterations - 2
Deviance = 67102.68 Iterations - 3
Deviance = 67088.05 Iterations - 4
Deviance = 67078.07 Iterations - 5
Deviance = 67073.77 Iterations - 6
Deviance = 67076.34 Iterations - 7
Deviance = 67074.41 Iterations - 8
Deviance = 67075.74 Iterations - 9
Deviance = 67074.77 Iterations - 10
Deviance = 67075.45 Iterations - 11
Deviance = 67074.96 Iterations - 12
Deviance = 67075.31 Iterations - 13
Deviance = 67075.06 Iterations - 14
Deviance = 67075.23 Iterations - 15
Deviance = 67075.11 Iterations - 16
Deviance = 67075.2 Iterations - 17
Deviance = 67075.13 Iterations - 18
Deviance = 67075.18 Iterations - 19
Deviance = 67075.15 Iterations - 20
Deviance = 67075.17 Iterations - 21
Deviance = 67075.15 Iterations - 22
Deviance = 67075.16 Iterations - 23
Deviance = 67075.16 Iterations - 24
Deviance = 67075.16 Iterations - 25
Deviance = 67075.16 Iterations - 26
Deviance = 67075.16 Iterations - 27
Deviance = 67075.16 Iterations - 28
Deviance = 67075.16 Iterations - 29
Deviance = 67075.16 Iterations - 30
Deviance = 67075.16 Iterations - 31
Deviance = 67075.16 Iterations - 32
Run Code Online (Sandbox Code Playgroud)
我的 options() 输出:
$askpass
function (prompt)
{
.rs.askForPassword(prompt)
}
<environment: 0x5557fac219c8>
$asksecret
function (name, title = name, prompt = paste(name, ":", sep = ""))
{
.rs.askForSecret(name, title, prompt)
}
<environment: 0x5557fac219c8>
$bitmapType
[1] "cairo"
$CBoundsCheck
[1] FALSE
$check.bounds
[1] FALSE
$citation.bibtex.max
[1] 1
$continue
[1] "+ "
$contrasts
unordered ordered
"contr.treatment" "contr.poly"
$defaultPackages
[1] "datasets" "utils" "grDevices" "graphics" "stats" "methods"
$demo.ask
[1] "default"
$deparse.cutoff
[1] 60
$device
[1] "RStudioGD"
$device.ask.default
[1] FALSE
$digits
[1] 7
$download.file.method
[1] "libcurl"
$dvipscmd
[1] "dvips"
$echo
[1] TRUE
$editor
[1] "/usr/bin/nano"
$encoding
[1] "native.enc"
$example.ask
[1] "default"
$expressions
[1] 5000
$ggvis.renderer
[1] "svg"
$help_type
[1] "html"
$help.search.types
[1] "vignette" "demo" "help"
$help.try.all.packages
[1] FALSE
$HTTPUserAgent
[1] "RStudio Desktop (1.4.1106); R (4.0.4 x86_64-redhat-linux-gnu x86_64 linux-gnu)"
$internet.info
[1] 2
$keep.parse.data
[1] TRUE
$keep.parse.data.pkgs
[1] FALSE
$keep.source
[1] TRUE
$keep.source.pkgs
[1] FALSE
$locatorBell
[1] TRUE
$mailer
[1] "mailto"
$matprod
[1] "default"
$max.print
[1] 1000
$menu.graphics
[1] FALSE
$na.action
[1] "na.omit"
$nwarnings
[1] 50
$OutDec
[1] "."
$papersize
[1] "letter"
$PCRE_limit_recursion
[1] NA
$PCRE_study
[1] FALSE
$PCRE_use_JIT
[1] TRUE
$pdfviewer
[1] "/usr/bin/xdg-open"
$pkgType
[1] "source"
$profvis.keep_output
[1] TRUE
$profvis.print
function (x)
{
.rs.profilePrint(x)
}
<environment: 0x5557f91aadb0>
$profvis.prof_extension
[1] ".Rprof"
$prompt
[1] "> "
$repos
CRAN
"https://cran.rstudio.com/"
attr(,"RStudio")
[1] TRUE
$restart
function (afterRestartCommand = "")
{
.rs.restartR(afterRestartCommand)
}
<environment: 0x5557fac219c8>
$reticulate.initialized
function ()
{
options(reticulate.initialized = NULL)
.rs.reticulate.onPythonInitialized()
.rs.reticulate.enqueueClientEvent(.rs.reticulateEvents$PYTHON_INITIALIZED,
list())
.Call("rs_reticulateInitialized", PACKAGE = "(embedding)")
}
<environment: 0x5557f8bbf4d0>
$reticulate.repl.hook
function (buffer, contents, trimmed)
{
.rs.reticulate.replHook(buffer, contents, trimmed)
}
<environment: 0x5557f8bbf4d0>
$reticulate.repl.initialize
function ()
{
.rs.reticulate.replInitialize()
}
<environment: 0x5557f8bbf4d0>
$reticulate.repl.teardown
function ()
{
.rs.reticulate.replTeardown()
}
<environment: 0x5557f8bbf4d0>
$rl_word_breaks
[1] " \t\n\"\\'`><=%;,|&{()}"
$rsconnect.check.certificate
[1] TRUE
$rstudio.notebook.executing
[1] FALSE
$RStudioGD.antialias
[1] "default"
$RStudioGD.backend
[1] "default"
$scipen
[1] 0
$shiny.launch.browser
function (url)
{
invisible(.Call("rs_shinyviewer", url, getwd(), "window",
NULL, PACKAGE = "(embedding)"))
}
<environment: base>
attr(,"shinyViewerType")
[1] "window"
$shinygadgets.showdialog
function (caption, url, width = NULL, height = NULL)
{
if (!is.character(caption) || (length(caption) != 1))
stop("caption must be a single element character vector.",
call. = FALSE)
if (!is.character(url) || (length(url) != 1))
stop("url must be a single element character vector.",
call. = FALSE)
if (is.null(width))
width <- 600
if (is.null(height))
height <- 600
if (!is.numeric(width) || (length(width) != 1))
stop("width must be a single element numeric vector.",
call. = FALSE)
if (!is.numeric(height) || (length(height) != 1))
stop("height must be a single element numeric vector.",
call. = FALSE)
invisible(.Call("rs_showShinyGadgetDialog", caption, url,
width, height, PACKAGE = "(embedding)"))
}
<environment: 0x5557fac219c8>
$show.coef.Pvalues
[1] TRUE
$show.error.messages
[1] TRUE
$show.signif.stars
[1] TRUE
$str
$str$strict.width
[1] "no"
$str$digits.d
[1] 3
$str$vec.len
[1] 4
$str$list.len
[1] 99
$str$deparse.lines
NULL
$str$drop.deparse.attr
[1] TRUE
$str$formatNum
function (x, ...)
format(x, trim = TRUE, drop0trailing = TRUE, ...)
<environment: 0x5557f9ae0330>
$str.dendrogram.last
[1] "`"
$stringsAsFactors
[1] FALSE
$terminal.manager
$terminal.manager$terminalActivate
function (id = NULL, show = TRUE)
{
if (!is.null(id) && (!is.character(id) || (length(id) !=
1)))
stop("'id' must be NULL or a character vector of length one")
if (!is.logical(show))
stop("'show' must be TRUE or FALSE")
.Call("rs_terminalActivate", id, show)
invisible(NULL)
}
$terminal.manager$terminalCreate
function (caption = NULL, show = TRUE, shellType = NULL)
{
if (!is.null(caption) && (!is.character(caption) || (length(caption) !=
1)))
stop("'caption' must be NULL or a character vector of length one")
if (is.null(show) || !is.logical(show))
stop("'show' must be a logical vector")
if (!is.null(shellType) && (!is.character(shellType) || (length(shellType) !=
1)))
stop("'shellType' must be NULL or a character vector of length one")
validShellType = TRUE
if (!is.null(shellType)) {
validShellType <- tolower(shellType) %in% c("default",
"win-cmd", "win-ps", "win-git-bash", "win-wsl-bash",
"ps-core", "custom")
}
if (!validShellType)
stop("'shellType' must be NULL, or one of 'default', 'win-cmd', 'win-ps', 'win-git-bash', 'win-wsl-bash', 'ps-core', 'bash', 'zsh', or 'custom'.")
.Call("rs_terminalCreate", caption, show, shellType)
}
$terminal.manager$terminalClear
function (id)
{
if (is.null(id) || !is.character(id) || length(id) != 1)
stop("'id' must be a character vector of length one")
.Call("rs_terminalClear", id)
invisible(NULL)
}
$terminal.manager$terminalList
function ()
{
.Call("rs_terminalList")
}
$terminal.manager$terminalContext
function (id)
{
if (is.null(id) || !is.character(id) || (length(id) != 1))
stop("'id' must be a single element character vector")
.Call("rs_terminalContext", id)
}
$terminal.manager$terminalBuffer
function (id, stripAnsi = TRUE)
{
if (is.null(id) || !is.character(id) || (length(id) != 1))
stop("'id' must be a single element character vector")
if (is.null(stripAnsi) || !is.logical(stripAnsi))
stop("'stripAnsi' must be a logical vector")
.Call("rs_terminalBuffer", id, stripAnsi)
}
$terminal.manager$terminalVisible
function ()
{
.Call("rs_terminalVisible")
}
$terminal.manager$terminalBusy
function (id)
{
if (is.null(id) || !is.character(id))
stop("'id' must be a character vector")
.Call("rs_terminalBusy", id)
}
$terminal.manager$terminalRunning
function (id)
{
if (is.null(id) || !is.character(id))
stop("'id' must be a character vector")
.Call("rs_terminalRunning", id)
}
$terminal.manager$terminalKill
function (id)
{
if (is.null(id) || !is.character(id))
stop("'id' must be a character vector")
.Call("rs_terminalKill", id)
invisible(NULL)
}
$terminal.manager$terminalSend
function (id, text)
{
if (!is.character(text))
stop("'text' should be a character vector", call. = FALSE)
if (is.null(id) || !is.character(id) || length(id) != 1)
stop("'id' must be a character vector of length one")
.Call("rs_terminalSend", id, text)
invisible(NULL)
}
$terminal.manager$terminalExecute
function (command, workingDir = NULL, env = character(), show = TRUE)
{
if (is.null(command) || !is.character(command) || (length(command) !=
1))
stop("'command' must be a single element character vector")
if (!is.null(workingDir) && (!is.character(workingDir) ||
(length(workingDir) != 1)))
stop("'workingDir' must be a single element character vector")
if (!is.null(env) && !is.character(env))
stop("'env' must be a character vector")
if (is.null(show) || !is.logical(show))
stop("'show' must be a logical vector")
.Call("rs_terminalExecute", command, workingDir, env, show,
PACKAGE = "(embedding)")
}
$texi2dvi
[1] "/usr/bin/texi2dvi"
$timeout
[1] 60
$ts.eps
[1] 1e-05
$ts.S.compat
[1] FALSE
$unzip
[1] "/usr/bin/unzip"
$useFancyQuotes
[1] TRUE
$verbose
[1] FALSE
$viewer
function (url, height = NULL)
{
if (!is.character(url) || (length(url) != 1))
stop("url must be a single element character vector.",
call. = FALSE)
if (identical(height, "maximize"))
height <- -1
if (!is.null(height) && (!is.numeric(height) || (length(height) !=
1)))
stop("height must be a single element numeric vector or 'maximize'.",
call. = FALSE)
invisible(.Call("rs_viewer", url, height, PACKAGE = "(embedding)"))
}
<environment: 0x5557fac219c8>
$warn
[1] 0
$warning.length
[1] 1000
$width
[1] 121
Run Code Online (Sandbox Code Playgroud)
第二台计算机的 options() 输出:
$add.smooth
[1] TRUE
$askpass
function (prompt)
{
.Call("rs_askForPassword", prompt)
}
<environment: 0x55ca5c0b0978>
$asksecret
function (name, title = name, prompt = paste(name, ":", sep = ""))
{
result <- .Call("rs_askForSecret", name, title, prompt, .rs.isPackageInstalled("keyring"),
.rs.hasSecret(name))
if (is.null(result))
stop("Ask for secret operation was cancelled.")
result
}
<environment: 0x55ca5c0b0978>
$bitmapType
[1] "cairo"
$browser
function (url)
{
.Call("rs_browseURL", url)
}
<environment: 0x55ca5ca2c200>
$browserNLdisabled
[1] FALSE
$buildtools.check
function (action)
{
if (identical(.Platform$pkgType, "mac.binary.mavericks")) {
.Call("rs_canBuildCpp")
}
else {
if (!.Call("rs_canBuildCpp")) {
.rs.installBuildTools(action)
FALSE
}
else {
TRUE
}
}
}
<environment: 0x55ca5c0b0978>
$buildtools.with
function (code)
{
.rs.addRToolsToPath()
on.exit(.rs.restorePreviousPath(), add = TRUE)
force(code)
}
<environment: 0x55ca5c0b0978>
$CBoundsCheck
[1] FALSE
$check.bounds
[1] FALSE
$citation.bibtex.max
[1] 1
$connectionObserver
$connectionObserver$connectionOpened
function (type, host, displayName, icon = NULL, connectCode,
disconnect, listObjectTypes, listObjects, listColumns, previewObject,
connectionObject, actions = NULL)
{
if (!inherits(listObjectTypes, "function")) {
stop("listObjectTypes must be a function returning a list of object types",
call. = FALSE)
}
promote <- function(name, l) {
if (length(l) == 0)
return(list())
if (is.null(l$contains)) {
return(list(list(name = name, icon = l$icon, contains = "data")))
}
else {
return(unlist(append(list(list(list(name = name,
icon = l$icon, contains = names(l$contains)))),
lapply(names(l$contains), function(name) {
promote(name, l$contains[[name]])
})), recursive = FALSE))
}
return(list())
}
objectTree <- listObjectTypes()
objectTypes <- lapply(names(objectTree), function(name) {
promote(name, objectTree[[name]])
})[[1]]
connection <- list(type = type, host = host, displayName = displayName,
icon = icon, connectCode = connectCode, disconnect = disconnect,
objectTypes = objectTypes, listObjects = listObjects,
listColumns = listColumns, previewObject = previewObject,
actions = actions, connectionObject = connectionObject)
class(connection) <- "rstudioConnection"
.rs.validateConnection(connection)
cacheKey <- paste(connection$type, connection$host, .Call("rs_generateShortUuid"),
sep = "_")
assign(cacheKey, value = connection, envir = .rs.activeConnections)
invisible(.Call("rs_connectionOpened", connection))
}
<environment: 0x55ca5d0039e0>
$connectionObserver$connectionClosed
function (type, host, ...)
{
.rs.validateCharacterParams(list(type = type, host = host))
name <- .rs.findConnectionName(type, host)
if (!is.null(name))
rm(list = name, envir = .rs.activeConnections)
invisible(.Call("rs_connectionClosed", type, host))
}
<environment: 0x55ca5d0039e0>
$connectionObserver$connectionUpdated
function (type, host, hint, ...)
{
.rs.validateCharacterParams(list(type = type, host = host,
hint = hint))
invisible(.Call("rs_connectionUpdated", type, host, hint))
}
<environment: 0x55ca5d0039e0>
$continue
[1] "+ "
$contrasts
unordered ordered
"contr.treatment" "contr.poly"
$defaultPackages
[1] "datasets" "utils" "grDevices" "graphics" "stats" "methods"
$demo.ask
[1] "default"
$deparse.cutoff
[1] 60
$device
[1] "RStudioGD"
$device.ask.default
[1] FALSE
$digits
[1] 7
$download.file.method
[1] "libcurl"
$dvipscmd
[1] "dvips"
$echo
[1] TRUE
$editor
[1] "vi"
$encoding
[1] "native.enc"
$error
(function ()
{
.rs.recordTraceback(TRUE, 5, .rs.enqueueError)
})()
$example.ask
[1] "default"
$expressions
[1] 5000
$ggvis.renderer
[1] "svg"
$help_type
[1] "html"
$help.search.types
[1] "vignette" "demo" "help"
$help.try.all.packages
[1] FALSE
$HTTPUserAgent
[1] "RStudio Desktop (1.3.1093); R (4.0.4 x86_64-redhat-linux-gnu x86_64 linux-gnu)"
$internet.info
[1] 2
$keep.parse.data
[1] TRUE
$keep.parse.data.pkgs
[1] FALSE
$keep.source
[1] TRUE
$keep.source.pkgs
[1] FALSE
$locatorBell
[1] TRUE
$mailer
[1] "mailto"
$matprod
[1] "default"
$max.print
[1] 1000
$menu.graphics
[1] FALSE
$na.action
[1] "na.omit"
$nwarnings
[1] 50
$OutDec
[1] "."
$page_viewer
function (url, title = "RStudio Viewer", self_contained = FALSE)
{
if (!is.character(url) || (length(url) != 1))
stop("url must be a single element character vector.",
call. = FALSE)
if (!is.character(title) || (length(title) != 1))
stop("title must be a single element character vector.",
call. = FALSE)
if (!is.logical(self_contained) || (length(self_contained) !=
1))
stop("self_contained must be a single element logical vector.",
call. = FALSE)
invisible(.Call("rs_showPageViewer", url, title, self_contained))
}
<environment: 0x55ca5ca2c200>
$pager
function (files, header, title, delete.file)
{
for (i in 1:length(files)) {
if ((i > length(header)) || !nzchar(header[[i]]))
fileTitle <- title
else fileTitle <- header[[i]]
.Call("rs_showFile", fileTitle, files[[i]], delete.file)
}
}
<environment: 0x55ca5c0b0978>
$papersize
[1] "letter"
$PCRE_limit_recursion
[1] NA
$PCRE_study
[1] FALSE
$PCRE_use_JIT
[1] TRUE
$pdfviewer
[1] "/usr/bin/xdg-open"
$pkgType
[1] "source"
$plumber.swagger.url
function (url)
{
invisible(.Call("rs_plumberviewer", url, getwd(), "window",
PACKAGE = "(embedding)"))
}
<environment: 0x55ca5c0b0978>
attr(,"plumberViewerType")
[1] "window"
$printcmd
[1] "lpr"
$profvis.keep_output
[1] TRUE
$profvis.print
function (x)
{
envir <- as.environment(which(search() == "tools:rstudio"))
eval(substitute(.rs.profilePrint(x), list(x = x)), envir = envir)
}
<environment: 0x55ca5c99fb80>
$prompt
[1] "> "
$repos
CRAN
"https://cran.rstudio.com/"
attr(,"RStudio")
[1] TRUE
$restart
function (afterRestartCommand = "")
{
afterRestartCommand <- paste(as.character(afterRestartCommand),
collapse = "\n")
.Call("rs_restartR", afterRestartCommand, PACKAGE