HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Program Files/R/R-4.4.0/library/survival/tests/r_tdist.Rout.save
R Under development (unstable) (2019-01-23 r76006) -- "Unsuffered Consequences"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> options(na.action=na.exclude) # preserve missings
> options(contrasts=c('contr.treatment', 'contr.poly')) #ensure constrast type
> library(survival)
> 
> #
> # Test out the t-distribution
> #
> # First, a t-dist with 500 df should be nearly identical to the Gaussian
> 
> fitig <- survreg(Surv(time, status)~voltage, 
+         dist = "gaussian", data = capacitor)
> fit1 <- survreg(Surv(time, status) ~ voltage,
+ 		 dist='t', parms=500, capacitor)
> fitig
Call:
survreg(formula = Surv(time, status) ~ voltage, data = capacitor, 
    dist = "gaussian")

Coefficients:
(Intercept)     voltage 
1917.431558   -4.087366 

Scale= 314.4748 

Loglik(model)= -249.2   Loglik(intercept only)= -258.7
	Chisq= 18.97 on 1 degrees of freedom, p= 1.32e-05 
n= 64 
> summary(fit1, corr=F)

Call:
survreg(formula = Surv(time, status) ~ voltage, data = capacitor, 
    dist = "t", parms = 500)
               Value Std. Error     z       p
(Intercept) 1918.329    219.536  8.74 < 2e-16
voltage       -4.091      0.778 -5.26 1.5e-07
Log(scale)     5.749      0.133 43.12 < 2e-16

Scale= 314 

Student-t distribution: parmameters= 500
Loglik(model)= -249.2   Loglik(intercept only)= -258.7
	Chisq= 19.01 on 1 degrees of freedom, p= 1.3e-05 
Number of Newton-Raphson Iterations: 5 
n= 64 

> 
> # A more realistic fit
> fit2 <- survreg(Surv(time, status) ~ voltage,
+ 		 dist='t', parms=5, capacitor)
> print(fit2)
Call:
survreg(formula = Surv(time, status) ~ voltage, data = capacitor, 
    dist = "t", parms = 5)

Coefficients:
(Intercept)     voltage 
1975.155951   -4.315492 

Scale= 276.799 

Loglik(model)= -250.2   Loglik(intercept only)= -261
	Chisq= 21.65 on 1 degrees of freedom, p= 3.27e-06 
n= 64 
> 
> if (FALSE) {
+ resid(fit2, type='response')
+ resid(fit2, type='deviance')
+ resid(fit2, type='working') 
+ resid(fit2, type='dfbeta')
+ resid(fit2, type='dfbetas')
+ resid(fit2, type='ldresp')
+ resid(fit2, type='ldshape')
+ resid(fit2, type='ldcase')
+ resid(fit2, type='matrix')
+ 
+ predict(fit2, type='link')
+ predict(fit2, type='terms')
+ predict(fit2, type='quantile')
+ }
> 
> proc.time()
   user  system elapsed 
  0.752   0.028   0.782